# jarrodmalkovic/auction-website architecture

> Architecture diagram of the GitHub repository jarrodmalkovic/auction-website, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jarrodmalkovic/auction-website
- Repository: https://github.com/jarrodmalkovic/auction-website

## Overview

#### 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: [`services/frontend/src/api/base-client.js`](https://github.com/jarrodmalkovic/auction-website/blob/main/services/frontend/src/api/base-client.js) (API client), [`services/listings/src/models/listing.ts`](https://github.com/jarrodmalkovic/auction-website/blob/main/services/listings/src/models/listing.ts) (Listings), [`services/payments/src/routes/create-payment.ts`](https://github.com/jarrodmalkovic/auction-website/blob/main/services/payments/src/routes/create-payment.ts) (Payments), [`services/bid/src/routes/create-bid.ts`](https://github.com/jarrodmalkovic/auction-website/blob/main/services/bid/src/routes/create-bid.ts) (Bid)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Edge &amp; client"]
  node_ingress{{"Kubernetes ingress<br/>routing<br/>[ingress-srv.yaml]"}}
  node_frontend["Next.js frontend<br/>web client<br/>[_app.tsx]"]
  node_api_client["API client<br/>frontend integration<br/>[base-client.js]"]
end

subgraph group_services["Domain services"]
  node_common["Common contracts &amp; auth<br/>shared TypeScript package<br/>[index.ts]"]
  node_auth["Auth<br/>identity service<br/>[index.ts]"]
  node_listings["Listings<br/>auction state service<br/>[listing.ts]"]
  node_listing_socket["Live updates<br/>Socket.IO gateway"]
  node_bid["Bid<br/>[create-bid.ts]"]
  node_expiration["Expiration<br/>auction scheduler"]
  node_payments["Payments<br/>settlement service<br/>[create-payment.ts]"]
  node_profile["Profile<br/>[update-profile.ts]"]
  node_email["Email<br/>notification service"]
end

subgraph group_platform["Eventing &amp; infrastructure"]
  node_nats["NATS<br/>event bus"]
  node_mysql[("MySQL databases<br/>domain storage")]
  node_redis[("Redis<br/>expiration queue storage")]
  node_stripe["Stripe<br/>payment provider"]
  node_cloudinary["Cloudinary<br/>image provider"]
  node_skaffold["Skaffold<br/>local deploy pipeline<br/>[skaffold.yaml]"]
end

node_ingress -->|"external requests"| node_frontend
node_frontend -->|"uses"| node_api_client
node_api_client -->|"identity API"| node_auth
node_api_client -->|"auction API"| node_listings
node_api_client -->|"bidding API"| node_bid
node_api_client -->|"checkout API"| node_payments
node_api_client -->|"profile API"| node_profile
node_listings -->|"auction updates"| node_listing_socket
node_listing_socket -->|"live events"| node_frontend
node_common -.->|"contracts and middleware"| node_auth
node_common -.->|"event contracts"| node_listings
node_common -.->|"event contracts"| node_bid
node_nats -->|"listing and user projections"| node_bid
node_bid -->|"BidCreated / BidDeleted"| node_nats
node_nats -->|"bids, expiration, payments"| node_listings
node_listings -->|"listing lifecycle events"| node_nats
node_nats -->|"new listings"| node_expiration
node_expiration -->|"schedule auction end"| node_redis
node_expiration -->|"expiration completed"| node_nats
node_nats -->|"listing projections"| node_payments
node_payments -->|"create payment"| node_stripe
node_payments -->|"PaymentCreated"| node_nats
node_auth -->|"user and email events"| node_nats
node_nats -->|"UserCreated"| node_profile
node_nats -->|"EmailCreated"| node_email
node_auth -->|"owned state"| node_mysql
node_listings -->|"owned state"| node_mysql
node_bid -->|"owned state"| node_mysql
node_payments -->|"owned state"| node_mysql
node_profile -->|"owned state"| node_mysql
node_frontend -->|"image handling"| node_cloudinary
node_skaffold -.->|"builds and deploys"| node_ingress

click node_ingress "https://github.com/jarrodmalkovic/auction-website/blob/main/k8s/ingress-srv.yaml"
click node_frontend "https://github.com/jarrodmalkovic/auction-website/blob/main/services/frontend/src/pages/_app.tsx"
click node_api_client "https://github.com/jarrodmalkovic/auction-website/blob/main/services/frontend/src/api/base-client.js"
click node_common "https://github.com/jarrodmalkovic/auction-website/blob/main/common/src/index.ts"
click node_auth "https://github.com/jarrodmalkovic/auction-website/blob/main/services/auth/src/index.ts"
click node_listings "https://github.com/jarrodmalkovic/auction-website/blob/main/services/listings/src/models/listing.ts"
click node_listing_socket "https://github.com/jarrodmalkovic/auction-website/blob/main/services/listings/src/socket-io-wrapper.ts"
click node_bid "https://github.com/jarrodmalkovic/auction-website/blob/main/services/bid/src/routes/create-bid.ts"
click node_expiration "https://github.com/jarrodmalkovic/auction-website/blob/main/services/expiration/src/queues/expiration-queue.ts"
click node_payments "https://github.com/jarrodmalkovic/auction-website/blob/main/services/payments/src/routes/create-payment.ts"
click node_profile "https://github.com/jarrodmalkovic/auction-website/blob/main/services/profile/src/routes/update-profile.ts"
click node_email "https://github.com/jarrodmalkovic/auction-website/blob/main/services/email/src/events/listeners/email-created-listener.ts"
click node_skaffold "https://github.com/jarrodmalkovic/auction-website/blob/main/skaffold.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ingress,node_frontend,node_api_client toneBlue
class node_common,node_auth,node_listings,node_listing_socket,node_bid,node_expiration,node_payments,node_profile,node_email toneAmber
class node_nats,node_mysql,node_redis,node_stripe,node_cloudinary,node_skaffold toneMint
```

## Components

### Edge & client

- [Kubernetes ingress](https://github.com/jarrodmalkovic/auction-website/blob/main/k8s/ingress-srv.yaml): routing · Routes external traffic to the frontend and service deployments. · `k8s/ingress-srv.yaml`
- [Next.js frontend](https://github.com/jarrodmalkovic/auction-website/blob/main/services/frontend/src/pages/_app.tsx): web client · SSR auction UI for browsing, selling, dashboards, settings, and profiles. · `services/frontend/src/pages/_app.tsx`
- [API client](https://github.com/jarrodmalkovic/auction-website/blob/main/services/frontend/src/api/base-client.js): frontend integration · `services/frontend/src/api/base-client.js`

### Domain services

- [Common contracts & auth](https://github.com/jarrodmalkovic/auction-website/blob/main/common/src/index.ts): shared TypeScript package · Typed events, listener/publisher bases, validation, errors, and Express auth middleware. · `common/src/index.ts`
- [Auth](https://github.com/jarrodmalkovic/auction-website/blob/main/services/auth/src/index.ts): identity service · Owns credentials, JWT sessions, and user-creation events. · `services/auth/src/index.ts`
- [Listings](https://github.com/jarrodmalkovic/auction-website/blob/main/services/listings/src/models/listing.ts): auction state service · Authoritative listing lifecycle and live auction state. · `services/listings/src/models/listing.ts`
- [Live updates](https://github.com/jarrodmalkovic/auction-website/blob/main/services/listings/src/socket-io-wrapper.ts): Socket.IO gateway · `services/listings/src/socket-io-wrapper.ts`
- [Bid](https://github.com/jarrodmalkovic/auction-website/blob/main/services/bid/src/routes/create-bid.ts): bidding service · Creates and deletes bids using local listing and user projections. · `services/bid/src/routes/create-bid.ts`
- [Expiration](https://github.com/jarrodmalkovic/auction-website/blob/main/services/expiration/src/queues/expiration-queue.ts): auction scheduler · Schedules auction end work and publishes completion. · `services/expiration/src/queues/expiration-queue.ts`
- [Payments](https://github.com/jarrodmalkovic/auction-website/blob/main/services/payments/src/routes/create-payment.ts): settlement service · Creates Stripe payments from listing projections. · `services/payments/src/routes/create-payment.ts`
- [Profile](https://github.com/jarrodmalkovic/auction-website/blob/main/services/profile/src/routes/update-profile.ts): profile service · Owns editable profile data and initializes profiles from user events. · `services/profile/src/routes/update-profile.ts`
- [Email](https://github.com/jarrodmalkovic/auction-website/blob/main/services/email/src/events/listeners/email-created-listener.ts): notification service · Delivers email creation events. · `services/email/src/events/listeners/email-created-listener.ts`

### Eventing & infrastructure

- **NATS**: event bus · Carries typed domain events between services.
- **MySQL databases**: domain storage · Each stateful service owns its own database.
- **Redis**: expiration queue storage
- **Stripe**: payment provider
- **Cloudinary**: image provider
- [Skaffold](https://github.com/jarrodmalkovic/auction-website/blob/main/skaffold.yaml): local deploy pipeline · Builds and deploys the Kubernetes development environment. · `skaffold.yaml`

## Connections

- 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
