How jarrodmalkovic/auction-website works
Purpose and deployment surface
A full-stack auction platform decomposed into Node/TypeScript microservices plus a Next.js client. Kubernetes is the runtime boundary: ingress routes traffic to service deployments, while Skaffold drives local build/deploy. Primary deployment files: k8s/ingress-srv.yaml, k8s/frontend-depl.yaml, skaffold.yaml.
Shared contracts and request security
The common package defines cross-service event contracts, event publisher/listener bases, listing status types, Express authentication middleware, validation, and normalized errors. Services should communicate business changes through these typed events rather than sharing databases. Key paths: common/src/index.ts, common/src/events/base-listener.ts, common/src/middlewares/current-user.ts.
Identity and user replication
Auth owns registration, sign-in/out, password updates, and JWT-backed current-user APIs; it publishes user creation and email events. Downstream services maintain local user projections from UserCreated, avoiding synchronous ownership dependencies. Key paths: services/auth/src/index.ts, services/auth/src/routes/signup.ts, services/auth/src/events/publishers/user-created-publisher.ts.
Listings as auction state authority
Listings owns auction listing records and lifecycle endpoints (create, delete, retrieve, seller/expired/sold views). It consumes bid, expiration, payment, and user events to update local listing state, then emits listing create/update/delete events for consumers. It also exposes Socket.IO integration for live auction updates. Key paths: services/listings/src/index.ts, services/listings/src/models/listing.ts, services/listings/src/socket-io-wrapper.ts.
Bidding and real-time flow
Bid accepts creation/deletion and bid query requests, while maintaining local listing and user projections from event consumers. Successful bid mutations publish BidCreated/BidDeleted; Listings consumes these to reflect auction state and drive real-time client behavior. Key paths: services/bid/src/routes/create-bid.ts, services/bid/src/events/listeners/listing-updated-listener.ts, services/bid/src/events/publishers/bid-created-publisher.ts.
Expiration, settlement, and notifications
Expiration consumes new listings, schedules end-of-auction work in Redis, and publishes completion events. Listings consumes expiration and payment events to mark auction outcomes. Payments maintains listing projections, creates Stripe payments, and emits PaymentCreated. Email is an event sink that consumes EmailCreated for delivery. Key paths: services/expiration/src/queues/expiration-queue.ts, services/payments/src/routes/create-payment.ts, services/email/src/events/listeners/email-created-listener.ts.
Profile, client, and infrastructure boundaries
Profile independently owns editable profile data and initializes profiles from user events. The Next.js frontend provides SSR pages for browsing, selling, dashboards, settings, and profiles, using its API client and shared application context; ingress is its external entry point. Services run in Docker/Kubernetes, use MySQL per stateful domain, NATS for events, Redis for expiration, Stripe for payments, and Cloudinary for image handling. Key paths: services/profile/src/routes/update-profile.ts, services/frontend/src/pages/_app.tsx, services/frontend/src/api/base-client.js.
Main entry points: base-client.js API client · listing.ts Listings · create-payment.ts Payments · create-bid.ts Bid
Components 18
Edge & client
- Kubernetes ingress · Routes external traffic to the frontend and service deployments.
k8s/ingress-srv.yaml - Next.js frontend · SSR auction UI for browsing, selling, dashboards, settings, and profiles.
services/frontend/src/pages/_app.tsx - API client
services/frontend/src/api/base-client.js
Domain services
- Common contracts & auth · Typed events, listener/publisher bases, validation, errors, and Express auth middleware.
common/src/index.ts - Auth · Owns credentials, JWT sessions, and user-creation events.
services/auth/src/index.ts - Listings · Authoritative listing lifecycle and live auction state.
services/listings/src/models/listing.ts - Live updates
services/listings/src/socket-io-wrapper.ts - Bid · Creates and deletes bids using local listing and user projections.
services/bid/src/routes/create-bid.ts - Expiration · Schedules auction end work and publishes completion.
services/expiration/src/queues/expiration-queue.ts - Payments · Creates Stripe payments from listing projections.
services/payments/src/routes/create-payment.ts - Profile · Owns editable profile data and initializes profiles from user events.
services/profile/src/routes/update-profile.ts - Email · Delivers email creation events.
services/email/src/events/listeners/email-created-listener.ts
Eventing & infrastructure
- NATS · Carries typed domain events between services.
- MySQL databases · Each stateful service owns its own database.
- Redis
- Stripe
- Cloudinary
- Skaffold · Builds and deploys the Kubernetes development environment.
skaffold.yaml
Connections 32
- Kubernetes ingress → Next.js frontend: external requests
- Next.js frontend → API client: uses
- API client → Auth: identity API
- API client → Listings: auction API
- API client → Bid: bidding API
- API client → Payments: checkout API
- API client → Profile: profile API
- Listings → Live updates: auction updates
- Live updates → Next.js frontend: live events
- Common contracts & auth → Auth: contracts and middleware
- Common contracts & auth → Listings: event contracts
- Common contracts & auth → Bid: event contracts
- NATS → Bid: listing and user projections
- Bid → NATS: BidCreated / BidDeleted
- NATS → Listings: bids, expiration, payments
- Listings → NATS: listing lifecycle events
- NATS → Expiration: new listings
- Expiration → Redis: schedule auction end
- Expiration → NATS: expiration completed
- NATS → Payments: listing projections
- Payments → Stripe: create payment
- Payments → NATS: PaymentCreated
- Auth → NATS: user and email events
- NATS → Profile: UserCreated
- NATS → Email: EmailCreated
- Auth → MySQL databases: owned state
- Listings → MySQL databases: owned state
- Bid → MySQL databases: owned state
- Payments → MySQL databases: owned state
- Profile → MySQL databases: owned state
- Next.js frontend → Cloudinary: image handling
- Skaffold → Kubernetes ingress: builds and deploys