# cypher682/nexuspay-platform architecture

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

- Interactive diagram: https://gitdiagram.com/cypher682/nexuspay-platform
- Repository: https://github.com/cypher682/nexuspay-platform

## Overview

NexusPay is a four-service payment platform. Clients enter through the API gateway, which routes requests to identity, payment, and notification capabilities. Payments support an idempotent lifecycle, ledger, provider webhooks, and reconciliation; payment and auth events feed asynchronous notification delivery. The graph preserves these documented capabilities and separates service-owned data stores. Source excerpts substantiate several internal calls; broader service routing and event flows are documented in the README, so unsampled implementation details are not inferred.

Main entry points: [`services/payments-service/src/services/payments.service.ts`](https://github.com/cypher682/nexuspay-platform/blob/main/services/payments-service/src/services/payments.service.ts) (Payment lifecycle and ledger), [`services/api-gateway/src/app.ts`](https://github.com/cypher682/nexuspay-platform/blob/main/services/api-gateway/src/app.ts) (API gateway), [`services/notifications-service/src/services/notifications.service.ts`](https://github.com/cypher682/nexuspay-platform/blob/main/services/notifications-service/src/services/notifications.service.ts) (Notification delivery), [`services/auth-service/src/services/auth.service.ts`](https://github.com/cypher682/nexuspay-platform/blob/main/services/auth-service/src/services/auth.service.ts) (Identity and IAM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry"]
  node_gateway["API gateway<br/>[app.ts]"]
  node_gateway_controls["Gateway controls"]
end

subgraph group_identity["Identity and access"]
  node_auth_api["Auth API<br/>[auth.routes.ts]"]
  node_auth_core["Identity and IAM<br/>[auth.service.ts]"]
  node_auth_store[("Auth database")]
end

subgraph group_payments["Payment processing"]
  node_payments_api["Payments API<br/>[payments.routes.ts]"]
  node_payment_core["Payment lifecycle and ledger"]
  node_state_machine["Payment state machine"]
  node_payment_jobs["Payment worker<br/>[payment.worker.ts]"]
  node_reconciliation["Reconciliation"]
  node_webhooks["Provider webhooks"]
  node_payment_store[("Payments database")]
end

subgraph group_messaging["Notifications"]
  node_notifications_api["Notifications API"]
  node_notification_core["Notification delivery"]
  node_notification_workers["Notification workers"]
  node_templates_senders["Templates and senders"]
  node_notification_store[("Notification database")]
end

node_client(("Client"))
node_auth_cache[("Redis")]
node_provider["Simulated payment provider"]
node_broker["RabbitMQ"]
node_delivery["Email and SMS transports"]

node_client -->|"sends requests"| node_gateway
node_gateway -->|"applies controls"| node_gateway_controls
node_gateway -->|"routes requests"| node_auth_api
node_gateway -->|"routes requests"| node_payments_api
node_gateway -->|"routes requests"| node_notifications_api
node_auth_api -->|"invokes"| node_auth_core
node_auth_core -->|"reads and writes"| node_auth_store
node_auth_core -->|"uses"| node_auth_cache
node_auth_core -->|"publishes auth events"| node_broker
node_payments_api -->|"invokes"| node_payment_core
node_payment_core -->|"reads and writes"| node_payment_store
node_payment_core -->|"checks transitions"| node_state_machine
node_payment_core -->|"enqueues work"| node_payment_jobs
node_payment_jobs -.->|"processes payments"| node_payment_core
node_payment_core -->|"publishes outcomes"| node_broker
node_payments_api -->|"routes reconciliation"| node_reconciliation
node_webhooks -.->|"handles provider events"| node_payment_core
node_provider -.->|"sends webhooks"| node_webhooks
node_broker -->|"delivers events"| node_notification_workers
node_notification_workers -->|"dispatches delivery"| node_notification_core
node_notifications_api -->|"invokes"| node_notification_core
node_notification_core -->|"reads and writes"| node_notification_store
node_notification_core -->|"publishes notification jobs"| node_broker
node_notification_core -->|"renders and selects"| node_templates_senders
node_templates_senders -->|"sends messages"| node_delivery

click node_gateway "https://github.com/cypher682/nexuspay-platform/blob/main/services/api-gateway/src/app.ts"
click node_gateway_controls "https://github.com/cypher682/nexuspay-platform/tree/main/services/api-gateway/src/middleware"
click node_auth_api "https://github.com/cypher682/nexuspay-platform/blob/main/services/auth-service/src/api/routes/auth.routes.ts"
click node_auth_core "https://github.com/cypher682/nexuspay-platform/blob/main/services/auth-service/src/services/auth.service.ts"
click node_payments_api "https://github.com/cypher682/nexuspay-platform/blob/main/services/payments-service/src/api/routes/payments.routes.ts"
click node_payment_core "https://github.com/cypher682/nexuspay-platform/blob/main/services/payments-service/src/services/payments.service.ts"
click node_state_machine "https://github.com/cypher682/nexuspay-platform/blob/main/services/payments-service/src/services/payment-state-machine.ts"
click node_payment_jobs "https://github.com/cypher682/nexuspay-platform/blob/main/services/payments-service/src/workers/payment.worker.ts"
click node_reconciliation "https://github.com/cypher682/nexuspay-platform/blob/main/services/payments-service/src/services/reconciliation.service.ts"
click node_webhooks "https://github.com/cypher682/nexuspay-platform/blob/main/services/payments-service/src/services/provider-webhooks.service.ts"
click node_notifications_api "https://github.com/cypher682/nexuspay-platform/blob/main/services/notifications-service/src/api/routes/notifications.routes.ts"
click node_notification_core "https://github.com/cypher682/nexuspay-platform/blob/main/services/notifications-service/src/services/notifications.service.ts"
click node_notification_workers "https://github.com/cypher682/nexuspay-platform/tree/main/services/notifications-service/src/workers"
click node_templates_senders "https://github.com/cypher682/nexuspay-platform/tree/main/services/notifications-service/src/lib"

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_gateway,node_gateway_controls,node_client toneBlue
class node_auth_api,node_auth_core,node_auth_store,node_auth_cache toneAmber
class node_payments_api,node_payment_core,node_state_machine,node_payment_jobs,node_reconciliation,node_webhooks,node_payment_store toneMint
class node_notifications_api,node_notification_core,node_notification_workers,node_templates_senders,node_notification_store toneRose
class node_provider,node_broker,node_delivery toneIndigo
```

## Components

### API entry

- [API gateway](https://github.com/cypher682/nexuspay-platform/blob/main/services/api-gateway/src/app.ts): `services/api-gateway/src/app.ts`
- [Gateway controls](https://github.com/cypher682/nexuspay-platform/tree/main/services/api-gateway/src/middleware): `services/api-gateway/src/middleware`

### Identity and access

- [Auth API](https://github.com/cypher682/nexuspay-platform/blob/main/services/auth-service/src/api/routes/auth.routes.ts): `services/auth-service/src/api/routes/auth.routes.ts`
- [Identity and IAM](https://github.com/cypher682/nexuspay-platform/blob/main/services/auth-service/src/services/auth.service.ts): `services/auth-service/src/services/auth.service.ts`
- **Auth database**

### Payment processing

- [Payments API](https://github.com/cypher682/nexuspay-platform/blob/main/services/payments-service/src/api/routes/payments.routes.ts): `services/payments-service/src/api/routes/payments.routes.ts`
- [Payment lifecycle and ledger](https://github.com/cypher682/nexuspay-platform/blob/main/services/payments-service/src/services/payments.service.ts): `services/payments-service/src/services/payments.service.ts`
- [Payment state machine](https://github.com/cypher682/nexuspay-platform/blob/main/services/payments-service/src/services/payment-state-machine.ts): `services/payments-service/src/services/payment-state-machine.ts`
- [Payment worker](https://github.com/cypher682/nexuspay-platform/blob/main/services/payments-service/src/workers/payment.worker.ts): `services/payments-service/src/workers/payment.worker.ts`
- [Reconciliation](https://github.com/cypher682/nexuspay-platform/blob/main/services/payments-service/src/services/reconciliation.service.ts): `services/payments-service/src/services/reconciliation.service.ts`
- [Provider webhooks](https://github.com/cypher682/nexuspay-platform/blob/main/services/payments-service/src/services/provider-webhooks.service.ts): `services/payments-service/src/services/provider-webhooks.service.ts`
- **Payments database**

### Notifications

- [Notifications API](https://github.com/cypher682/nexuspay-platform/blob/main/services/notifications-service/src/api/routes/notifications.routes.ts): `services/notifications-service/src/api/routes/notifications.routes.ts`
- [Notification delivery](https://github.com/cypher682/nexuspay-platform/blob/main/services/notifications-service/src/services/notifications.service.ts): `services/notifications-service/src/services/notifications.service.ts`
- [Notification workers](https://github.com/cypher682/nexuspay-platform/tree/main/services/notifications-service/src/workers): `services/notifications-service/src/workers`
- [Templates and senders](https://github.com/cypher682/nexuspay-platform/tree/main/services/notifications-service/src/lib): `services/notifications-service/src/lib`
- **Notification database**

### Other components

- **Client**
- **Redis**
- **Simulated payment provider**
- **RabbitMQ**
- **Email and SMS transports**

## Connections

- Client → API gateway: sends requests
- API gateway → Gateway controls: applies controls (evidence: `services/api-gateway/src/app.ts`)
- API gateway → Auth API: routes requests
- API gateway → Payments API: routes requests
- API gateway → Notifications API: routes requests
- Auth API → Identity and IAM: invokes (evidence: `services/auth-service/src/api/routes/auth.routes.ts`)
- Identity and IAM → Auth database: reads and writes (evidence: `services/auth-service/src/services/auth.service.ts`)
- Identity and IAM → Redis: uses (evidence: `services/auth-service/src/services/auth.service.ts`)
- Identity and IAM → RabbitMQ: publishes auth events (evidence: `services/auth-service/src/services/auth.service.ts`)
- Payments API → Payment lifecycle and ledger: invokes (evidence: `services/payments-service/src/api/routes/payments.routes.ts`)
- Payment lifecycle and ledger → Payments database: reads and writes (evidence: `services/payments-service/src/services/payments.service.ts`)
- Payment lifecycle and ledger → Payment state machine: checks transitions (evidence: `services/payments-service/src/services/payments.service.ts`)
- Payment lifecycle and ledger → Payment worker: enqueues work (evidence: `services/payments-service/src/services/payments.service.ts`)
- Payment worker → Payment lifecycle and ledger: processes payments
- Payment lifecycle and ledger → RabbitMQ: publishes outcomes (evidence: `services/payments-service/src/services/payments.service.ts`)
- Payments API → Reconciliation: routes reconciliation
- Provider webhooks → Payment lifecycle and ledger: handles provider events
- Simulated payment provider → Provider webhooks: sends webhooks
- RabbitMQ → Notification workers: delivers events
- Notification workers → Notification delivery: dispatches delivery (evidence: `services/notifications-service/src/main.ts`)
- Notifications API → Notification delivery: invokes (evidence: `services/notifications-service/src/services/notifications.service.ts`)
- Notification delivery → Notification database: reads and writes (evidence: `services/notifications-service/src/services/notifications.service.ts`)
- Notification delivery → RabbitMQ: publishes notification jobs (evidence: `services/notifications-service/src/services/notifications.service.ts`)
- Notification delivery → Templates and senders: renders and selects (evidence: `services/notifications-service/src/services/notifications.service.ts`)
- Templates and senders → Email and SMS transports: sends messages
