Case study · E-commerce / Marketplace
4U2 Inc Marketplace
A full-stack listings marketplace with seller accounts, moderation, enquiries and subscription billing, being hardened for public launch.
01Overview
A marketplace where sellers list items and buyers send enquiries, with package plans and subscriptions for sellers. It is built as a production system, with moderation, abuse handling, billing and observability, not as a demo.
02The solution
A Next.js application with a relational data model covering sellers, categories with custom attributes, listings, enquiries, reports, package plans, subscriptions and billing events, plus admin tools for moderation and triage.
03Technical architecture
Next.js App Router with TypeScript on PostgreSQL via Prisma. Authentication uses Better Auth. Images upload to S3 with validated types, sizes and object keys. Upstash Redis provides rate limiting and caching for expensive public queries. Resend sends transactional email, and Stripe handles billing through webhook events. Forms are validated with React Hook Form and Zod, and data fetching uses TanStack Query. Tested with Vitest and Playwright.
04Technology choices
- Next.js
- Pages, API routes and server rendering in one TypeScript codebase.
- PostgreSQL + Prisma
- A relational model for sellers, listings, enquiries and billing, with typed queries.
- Upstash Redis
- Rate limits and caches shared across serverless instances.
- AWS S3
- Object storage for listing images, kept out of the database.
- Stripe
- Subscription billing for seller packages, driven by webhook events.
- Resend
- Transactional email such as enquiry notifications to sellers.
05Implementation decisions
Rate limiting backed by Redis
Authentication endpoints, enquiries and abuse reports are rate limited with Redis counters, so limits hold across serverless instances instead of resetting for each instance.
Explicit CSRF and security review
Every endpoint that changes data was reviewed for CSRF, security headers are set centrally, and production database connections must verify certificates (sslmode=verify-full).
Idempotent billing webhooks
Each incoming billing event is recorded with a unique constraint on provider and event ID, so a webhook delivered twice is processed only once. The same table doubles as an audit trail.
A launch checklist sorted by risk
Launch work is tracked as P0, P1 and P2, so items that are critical for safety are finished before new features.
06Current status
Pre-launch. Core marketplace, moderation, enquiry and security work is complete. Billing go-live and paid featured listings remain, and the site is not yet open to the public.
Built · 6
- Registration, login, password reset and email verification
- Seller listings with image uploads
- Admin listing moderation and abuse reports
- Buyer enquiries with spam protection and seller emails
- Seller dashboard with enquiry inbox and analytics
- Weighted listing search
In progress · 1
- Marketplace packages and subscription billing
Planned · 1
- Paid featured-listing upgrades