KwadMarket Docs

Architecture

Monorepo layout, apps, packages and how data flows through the system

KwadMarket is a pnpm + turborepo monorepo. Three deployable apps share a Prisma database package and a common types package.

Repository layout

Stack

LayerTechnology
FrontendNext.js 16 (App Router), TanStack Query, react-hook-form + zod, Tailwind, socket.io client
APINestJS (REST, global prefix /api), Passport JWT, class-validator DTOs, Socket.IO gateway
WorkerNestJS + BullMQ (Redis), BrightData for scraping
DataPostgreSQL via Prisma, Meilisearch (product search), Redis (queues, sockets), S3-compatible storage (images)
AuthLocal email/password + Google + Facebook OAuth; JWT in an HttpOnly cookie set by Next route handlers

Data flow

  • Server components fetch via apps/web/lib/api/server.ts (serverFetch + cached helpers). Public data uses revalidate; authed data is no-store.
  • Client components call the API through lib/api/http.ts, which goes through the /api/proxy rewrite so the HttpOnly cookie flows same-origin. Endpoint strings live in exactly one features/*/api.ts per domain.
  • Real-time: the chat socket lives in ChatProvider; unread counts are socket-pushed to a user:{id} room.
  • Scraping: back owns the catalog and enqueues jobs; scraper consumes BullMQ jobs, talks to BrightData, and writes only Scraper* / ScrapedProduct tables. Catalog writes (Product, Spec, Shop) stay in back's ProductsService.

App boundary rule

apps/scraper must never import from apps/back/src (and vice versa). Job payload types belong in @marketplace/types, declared once for producer and consumer.

Domain model (core entities)

EntityRole
Product / Spec / Brand / CategoryThe retail catalog, populated by the scraper + admin
ShopA retail listing of a product (price, availability, URL) — powers new-price comparison
DealA user's secondhand listing; links to catalog products via DealProduct; moderated (DRAFT → PENDING → PUBLISHED/DECLINED → SOLD/ARCHIVED/EXPIRED)
Discussion / MessageBuyer–seller chat per deal, real-time via Socket.IO
ScrapedProductRaw scraper output awaiting review/import into the catalog
ProductComponentParent/component relation for drone builds

Where things run

ServiceDevNotes
Weblocalhost:3000Next.js dev server
APIlocalhost:3001Global prefix /api
PostgreSQL, Redis, MeilisearchDocker ComposeSee root compose files
Docs (this site)localhost:3000 (pnpm --filter docs dev)Docker: apps/docs/docker-compose.yml maps host port 3002

On this page