# dheeram/sgticketing architecture

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

- Interactive diagram: https://gitdiagram.com/dheeram/sgticketing
- Repository: https://github.com/dheeram/sgticketing

## Overview

This is a ticket marketplace built from a browser client and separate authentication, ticket, order, payment, and expiration services. The principal workflow is account access, ticket discovery or creation, reservation through an order with an expiration window, and payment; services also coordinate updates and cancellations through events. The excerpts establish several HTTP routes and internal calls, while cross-service event wiring is partly inferred from the service layout and therefore shown as unverified. The README is empty, and unsampled route behavior is not assumed.

Main entry points: [`client/pages`](https://github.com/dheeram/sgticketing/tree/master/client/pages) (Ticketing UI), [`orders/src/routes/new.ts`](https://github.com/dheeram/sgticketing/blob/master/orders/src/routes/new.ts) (Order creation), [`payments/src/routes/new.ts`](https://github.com/dheeram/sgticketing/blob/master/payments/src/routes/new.ts) (Payment creation), [`common/src/errors`](https://github.com/dheeram/sgticketing/tree/master/common/src/errors) (Errors and middleware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web["Ticketing UI"]
  node_request["API request hook<br/>[use-request.js]"]
end

subgraph group_api["HTTP services"]
  node_auth["Authentication<br/>[app.ts]"]
  node_user[("User model<br/>[user.ts]")]
  node_tickets["Ticket service<br/>[app.ts]"]
  node_ticketmodel[("Ticket model<br/>[ticket.ts]")]
  node_ticketupdate["Ticket updates<br/>[update.ts]"]
  node_orders["Order service<br/>[app.ts]"]
  node_ordercreate["Order creation<br/>[new.ts]"]
  node_ordermodel[("Order model<br/>[order.ts]")]
  node_orderlines[("Order ticket model<br/>[ticket.ts]")]
  node_payments["Payment service<br/>[app.ts]"]
  node_paymentcreate["Payment creation<br/>[new.ts]"]
  node_paymentmodels[("Payment records<br/>[payment.ts]")]
end

subgraph group_events["Event services"]
  node_expiration["Expiration worker"]
  node_expirationqueue["Expiration queue"]
  node_orderlisteners["Order event listeners"]
  node_ticketlisteners["Ticket event listeners"]
  node_paymentlisteners["Payment event listeners"]
end

subgraph group_shared["Shared contracts"]
  node_contracts["Event contracts"]
  node_errors["Errors and middleware"]
end

node_browser(("Customer"))
node_stripe["Stripe"]
node_nats["NATS messaging"]

node_browser -->|"uses"| node_web
node_web -->|"submits requests"| node_request
node_web -.->|"accesses account"| node_auth
node_web -.->|"browses tickets"| node_tickets
node_web -.->|"manages orders"| node_orders
node_web -.->|"pays orders"| node_payments
node_auth -->|"authenticates users"| node_user
node_tickets -->|"routes requests"| node_ticketupdate
node_ticketupdate -->|"updates"| node_ticketmodel
node_ticketupdate -->|"publishes updates"| node_nats
node_orders -->|"routes requests"| node_ordercreate
node_ordercreate -->|"loads ticket"| node_orderlines
node_ordercreate -->|"saves order"| node_ordermodel
node_ordercreate -->|"publishes creation"| node_nats
node_payments -->|"routes requests"| node_paymentcreate
node_paymentcreate -->|"charges card"| node_stripe
node_paymentcreate -->|"saves payment"| node_paymentmodels
node_paymentcreate -->|"publishes payment"| node_nats
node_expiration -->|"schedules expiry"| node_expirationqueue
node_expirationqueue -->|"publishes completion"| node_nats
node_orderlisteners -->|"updates order"| node_ordermodel
node_orderlisteners -->|"publishes cancellation"| node_nats
node_ticketlisteners -->|"updates ticket"| node_ticketmodel
node_ticketlisteners -->|"publishes ticket update"| node_nats
node_paymentlisteners -.->|"receives events"| node_nats
node_nats -.->|"transports events"| node_contracts
node_auth -->|"handles errors"| node_errors
node_tickets -->|"handles errors"| node_errors
node_orders -->|"handles errors"| node_errors
node_payments -->|"handles errors"| node_errors

click node_web "https://github.com/dheeram/sgticketing/tree/master/client/pages"
click node_request "https://github.com/dheeram/sgticketing/blob/master/client/hooks/use-request.js"
click node_auth "https://github.com/dheeram/sgticketing/blob/master/auth/src/app.ts"
click node_user "https://github.com/dheeram/sgticketing/blob/master/auth/src/models/user.ts"
click node_tickets "https://github.com/dheeram/sgticketing/blob/master/tickets/src/app.ts"
click node_ticketmodel "https://github.com/dheeram/sgticketing/blob/master/tickets/src/models/ticket.ts"
click node_ticketupdate "https://github.com/dheeram/sgticketing/blob/master/tickets/src/routes/update.ts"
click node_orders "https://github.com/dheeram/sgticketing/blob/master/orders/src/app.ts"
click node_ordercreate "https://github.com/dheeram/sgticketing/blob/master/orders/src/routes/new.ts"
click node_ordermodel "https://github.com/dheeram/sgticketing/blob/master/orders/src/models/order.ts"
click node_orderlines "https://github.com/dheeram/sgticketing/blob/master/orders/src/models/ticket.ts"
click node_payments "https://github.com/dheeram/sgticketing/blob/master/payments/src/app.ts"
click node_paymentcreate "https://github.com/dheeram/sgticketing/blob/master/payments/src/routes/new.ts"
click node_paymentmodels "https://github.com/dheeram/sgticketing/blob/master/payments/src/models/payment.ts"
click node_expiration "https://github.com/dheeram/sgticketing/blob/master/expiration/src/events/listeners/order-created-listener.ts"
click node_expirationqueue "https://github.com/dheeram/sgticketing/blob/master/expiration/src/queues/expiration-queue.ts"
click node_orderlisteners "https://github.com/dheeram/sgticketing/blob/master/orders/src/events/listeners/expiration-complete-listener.ts"
click node_ticketlisteners "https://github.com/dheeram/sgticketing/blob/master/tickets/src/events/listeners/order-created-listener.ts"
click node_paymentlisteners "https://github.com/dheeram/sgticketing/blob/master/payments/src/events/listeners/order-cancelled-listener.ts"
click node_contracts "https://github.com/dheeram/sgticketing/tree/master/common/src/events"
click node_errors "https://github.com/dheeram/sgticketing/tree/master/common/src/errors"

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_web,node_request toneBlue
class node_auth,node_user,node_tickets,node_ticketmodel,node_ticketupdate,node_orders,node_ordercreate,node_ordermodel,node_orderlines,node_payments,node_paymentcreate,node_paymentmodels toneAmber
class node_expiration,node_expirationqueue,node_orderlisteners,node_ticketlisteners,node_paymentlisteners toneMint
class node_contracts,node_errors toneRose
class node_browser,node_stripe,node_nats toneIndigo
```

## Components

### Web client

- [Ticketing UI](https://github.com/dheeram/sgticketing/tree/master/client/pages): `client/pages`
- [API request hook](https://github.com/dheeram/sgticketing/blob/master/client/hooks/use-request.js): `client/hooks/use-request.js`

### HTTP services

- [Authentication](https://github.com/dheeram/sgticketing/blob/master/auth/src/app.ts): `auth/src/app.ts`
- [User model](https://github.com/dheeram/sgticketing/blob/master/auth/src/models/user.ts): `auth/src/models/user.ts`
- [Ticket service](https://github.com/dheeram/sgticketing/blob/master/tickets/src/app.ts): `tickets/src/app.ts`
- [Ticket model](https://github.com/dheeram/sgticketing/blob/master/tickets/src/models/ticket.ts): `tickets/src/models/ticket.ts`
- [Ticket updates](https://github.com/dheeram/sgticketing/blob/master/tickets/src/routes/update.ts): `tickets/src/routes/update.ts`
- [Order service](https://github.com/dheeram/sgticketing/blob/master/orders/src/app.ts): `orders/src/app.ts`
- [Order creation](https://github.com/dheeram/sgticketing/blob/master/orders/src/routes/new.ts): `orders/src/routes/new.ts`
- [Order model](https://github.com/dheeram/sgticketing/blob/master/orders/src/models/order.ts): `orders/src/models/order.ts`
- [Order ticket model](https://github.com/dheeram/sgticketing/blob/master/orders/src/models/ticket.ts): `orders/src/models/ticket.ts`
- [Payment service](https://github.com/dheeram/sgticketing/blob/master/payments/src/app.ts): `payments/src/app.ts`
- [Payment creation](https://github.com/dheeram/sgticketing/blob/master/payments/src/routes/new.ts): `payments/src/routes/new.ts`
- [Payment records](https://github.com/dheeram/sgticketing/blob/master/payments/src/models/payment.ts): `payments/src/models/payment.ts`

### Event services

- [Expiration worker](https://github.com/dheeram/sgticketing/blob/master/expiration/src/events/listeners/order-created-listener.ts): `expiration/src/events/listeners/order-created-listener.ts`
- [Expiration queue](https://github.com/dheeram/sgticketing/blob/master/expiration/src/queues/expiration-queue.ts): `expiration/src/queues/expiration-queue.ts`
- [Order event listeners](https://github.com/dheeram/sgticketing/blob/master/orders/src/events/listeners/expiration-complete-listener.ts): `orders/src/events/listeners/expiration-complete-listener.ts`
- [Ticket event listeners](https://github.com/dheeram/sgticketing/blob/master/tickets/src/events/listeners/order-created-listener.ts): `tickets/src/events/listeners/order-created-listener.ts`
- [Payment event listeners](https://github.com/dheeram/sgticketing/blob/master/payments/src/events/listeners/order-cancelled-listener.ts): `payments/src/events/listeners/order-cancelled-listener.ts`

### Shared contracts

- [Event contracts](https://github.com/dheeram/sgticketing/tree/master/common/src/events): `common/src/events`
- [Errors and middleware](https://github.com/dheeram/sgticketing/tree/master/common/src/errors): `common/src/errors`

### Other components

- **Customer**
- **Stripe**
- **NATS messaging**

## Connections

- Customer → Ticketing UI: uses
- Ticketing UI → API request hook: submits requests (evidence: `client/pages/orders/[orderId].js`)
- Ticketing UI → Authentication: accesses account
- Ticketing UI → Ticket service: browses tickets
- Ticketing UI → Order service: manages orders
- Ticketing UI → Payment service: pays orders
- Authentication → User model: authenticates users
- Ticket service → Ticket updates: routes requests (evidence: `tickets/src/app.ts`)
- Ticket updates → Ticket model: updates (evidence: `tickets/src/routes/update.ts`)
- Ticket updates → NATS messaging: publishes updates (evidence: `tickets/src/routes/update.ts`)
- Order service → Order creation: routes requests (evidence: `orders/src/app.ts`)
- Order creation → Order ticket model: loads ticket (evidence: `orders/src/routes/new.ts`)
- Order creation → Order model: saves order (evidence: `orders/src/routes/new.ts`)
- Order creation → NATS messaging: publishes creation (evidence: `orders/src/routes/new.ts`)
- Payment service → Payment creation: routes requests (evidence: `payments/src/app.ts`)
- Payment creation → Stripe: charges card (evidence: `payments/src/routes/new.ts`)
- Payment creation → Payment records: saves payment (evidence: `payments/src/routes/new.ts`)
- Payment creation → NATS messaging: publishes payment (evidence: `payments/src/routes/new.ts`)
- Expiration worker → Expiration queue: schedules expiry (evidence: `expiration/src/events/listeners/order-created-listener.ts`)
- Expiration queue → NATS messaging: publishes completion (evidence: `expiration/src/queues/expiration-queue.ts`)
- Order event listeners → Order model: updates order (evidence: `orders/src/events/listeners/expiration-complete-listener.ts`)
- Order event listeners → NATS messaging: publishes cancellation (evidence: `orders/src/events/listeners/expiration-complete-listener.ts`)
- Ticket event listeners → Ticket model: updates ticket (evidence: `tickets/src/events/listeners/order-created-listener.ts`)
- Ticket event listeners → NATS messaging: publishes ticket update (evidence: `tickets/src/events/listeners/order-created-listener.ts`)
- Payment event listeners → NATS messaging: receives events
- NATS messaging → Event contracts: transports events
- Authentication → Errors and middleware: handles errors (evidence: `auth/src/app.ts`)
- Ticket service → Errors and middleware: handles errors (evidence: `tickets/src/app.ts`)
- Order service → Errors and middleware: handles errors (evidence: `orders/src/app.ts`)
- Payment service → Errors and middleware: handles errors (evidence: `payments/src/app.ts`)
