# mohamedtantawey/payops architecture

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

- Interactive diagram: https://gitdiagram.com/mohamedtantawey/payops
- Repository: https://github.com/mohamedtantawey/payops

## Overview

PayOps is a payment-orchestration demo with a React control center, Express API, Redis-backed worker, PostgreSQL state, and simulated PSPs. The main flow is merchant/API client → authenticated payment-intent route → vault and routing/connector execution → persisted payment state; the control center also exposes hosted checkout, routing, invoices, webhooks, billing, and administration. Background jobs handle webhook delivery, invoice generation, billing, and analytics. Edges reflect shown imports/calls or README statements; several unsampled route and worker details are represented only at subsystem level.

Main entry points: [`frontend/src/App.jsx`](https://github.com/mohamedtantawey/payops/blob/main/frontend/src/App.jsx) (Control center), [`backend/src/server.js`](https://github.com/mohamedtantawey/payops/blob/main/backend/src/server.js) (Express API), [`backend/src/routes/payments.js`](https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/payments.js) (Payments routes), [`frontend/src/api.js`](https://github.com/mohamedtantawey/payops/blob/main/frontend/src/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Control center"]
  node_control["Control center<br/>[App.jsx]"]
  node_client_api["API client<br/>[api.js]"]
  node_checkout_ui["Hosted checkout UI<br/>[HostedCheckout.jsx]"]
  node_payments_ui["Payments table<br/>[PaymentsTable.jsx]"]
  node_routing_ui["Routing editor<br/>[RoutingEditor.jsx]"]
  node_invoice_ui["Invoice list<br/>[InvoiceList.jsx]"]
  node_webhook_ui["Webhook log<br/>[WebhookLog.jsx]"]
  node_rbac_ui["RBAC manager<br/>[RbacManager.jsx]"]
  node_status_ui["Status banner<br/>[StatusBanner.jsx]"]
end

subgraph group_api["API and payments"]
  node_api_server["Express API<br/>[server.js]"]
  node_auth["API-key RBAC<br/>[authRbac.js]"]
  node_payments["Payments routes<br/>[payments.js]"]
  node_routing_routes["Routing routes<br/>[routing.js]"]
  node_admin_routes["Administration<br/>[admin.js]"]
  node_invoice_routes["Invoice routes<br/>[invoices.js]"]
  node_billing_routes["Billing routes<br/>[billing.js]"]
  node_webhook_routes["Webhook routes<br/>[webhooks.js]"]
  node_status_routes["Status routes<br/>[status.js]"]
  node_payment_flow["Payment orchestration<br/>[routingEngine.js]"]
  node_state_machine["Payment state machine"]
  node_vault["Vault tokenization<br/>[vaultClient.js]"]
  node_connector["PSP connector adapter"]
  node_hosted_checkout["Checkout service<br/>[hostedCheckout.js]"]
end

subgraph group_async["Background jobs"]
  node_jobs["Redis job queue<br/>[jobQueue.js]"]
  node_worker["Job worker<br/>[worker.js]"]
  node_webhook_handler["Webhook delivery<br/>[webhookHandler.js]"]
  node_invoice_handler["Invoice generation<br/>[invoiceHandler.js]"]
  node_billing_handler["Billing runs<br/>[billingHandler.js]"]
  node_analytics["Analytics consumer"]
end

subgraph group_infra["State and integrations"]
  node_database[("PostgreSQL<br/>[db.js]")]
  node_redis[("Redis services<br/>[redis.js]")]
  node_mock_psp["Simulated PSP<br/>external system"]
end

node_merchant(("Merchant / operator"))
node_webhook_receiver(("Webhook receiver<br/>external system"))

node_merchant -->|"operates"| node_control
node_merchant -->|"calls"| node_client_api
node_control -->|"renders"| node_payments_ui
node_control -->|"renders"| node_routing_ui
node_control -->|"renders"| node_invoice_ui
node_control -->|"renders"| node_webhook_ui
node_control -->|"renders"| node_rbac_ui
node_control -->|"renders"| node_status_ui
node_control -->|"renders"| node_checkout_ui
node_payments_ui -->|"requests"| node_client_api
node_routing_ui -->|"requests"| node_client_api
node_invoice_ui -->|"requests"| node_client_api
node_webhook_ui -->|"requests"| node_client_api
node_rbac_ui -->|"requests"| node_client_api
node_client_api -->|"sends requests"| node_api_server
node_api_server -->|"routes to"| node_payments
node_api_server -->|"routes to"| node_routing_routes
node_api_server -->|"routes to"| node_admin_routes
node_api_server -->|"routes to"| node_invoice_routes
node_api_server -->|"routes to"| node_billing_routes
node_api_server -->|"routes to"| node_webhook_routes
node_api_server -->|"routes to"| node_status_routes
node_payments -->|"authenticates with"| node_auth
node_routing_routes -->|"authenticates with"| node_auth
node_admin_routes -->|"authorizes with"| node_auth
node_payments -->|"executes"| node_payment_flow
node_payments -->|"transitions"| node_state_machine
node_payments -->|"tokenizes with"| node_vault
node_payments -->|"uses"| node_hosted_checkout
node_payment_flow -->|"transitions"| node_state_machine
node_payment_flow -->|"detokenizes with"| node_vault
node_payment_flow -->|"authorizes through"| node_connector
node_connector -->|"reads credentials"| node_database
node_connector -.->|"calls PSP"| node_mock_psp
node_payments -->|"enqueues jobs"| node_jobs
node_invoice_routes -->|"enqueues generation"| node_jobs
node_billing_routes -->|"enqueues runs"| node_jobs
node_webhook_routes -->|"enqueues dispatch"| node_jobs
node_jobs -->|"pushes jobs"| node_redis
node_worker -->|"consumes queue"| node_jobs
node_worker -->|"dispatches to"| node_webhook_handler
node_worker -->|"dispatches to"| node_invoice_handler
node_worker -->|"dispatches to"| node_billing_handler
node_worker -->|"dispatches to"| node_analytics
node_webhook_handler -->|"records deliveries"| node_database
node_webhook_handler -->|"posts signed events"| node_webhook_receiver
node_invoice_handler -->|"reads and writes"| node_database
node_billing_handler -->|"executes payments"| node_payment_flow

click node_control "https://github.com/mohamedtantawey/payops/blob/main/frontend/src/App.jsx"
click node_client_api "https://github.com/mohamedtantawey/payops/blob/main/frontend/src/api.js"
click node_checkout_ui "https://github.com/mohamedtantawey/payops/blob/main/frontend/src/components/HostedCheckout.jsx"
click node_payments_ui "https://github.com/mohamedtantawey/payops/blob/main/frontend/src/components/PaymentsTable.jsx"
click node_routing_ui "https://github.com/mohamedtantawey/payops/blob/main/frontend/src/components/RoutingEditor.jsx"
click node_invoice_ui "https://github.com/mohamedtantawey/payops/blob/main/frontend/src/components/InvoiceList.jsx"
click node_webhook_ui "https://github.com/mohamedtantawey/payops/blob/main/frontend/src/components/WebhookLog.jsx"
click node_rbac_ui "https://github.com/mohamedtantawey/payops/blob/main/frontend/src/components/RbacManager.jsx"
click node_status_ui "https://github.com/mohamedtantawey/payops/blob/main/frontend/src/components/StatusBanner.jsx"
click node_api_server "https://github.com/mohamedtantawey/payops/blob/main/backend/src/server.js"
click node_auth "https://github.com/mohamedtantawey/payops/blob/main/backend/src/middleware/authRbac.js"
click node_payments "https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/payments.js"
click node_routing_routes "https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/routing.js"
click node_admin_routes "https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/admin.js"
click node_invoice_routes "https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/invoices.js"
click node_billing_routes "https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/billing.js"
click node_webhook_routes "https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/webhooks.js"
click node_status_routes "https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/status.js"
click node_payment_flow "https://github.com/mohamedtantawey/payops/blob/main/backend/src/core/routingEngine.js"
click node_state_machine "https://github.com/mohamedtantawey/payops/blob/main/backend/src/core/paymentStateMachine.js"
click node_vault "https://github.com/mohamedtantawey/payops/blob/main/backend/src/core/vaultClient.js"
click node_connector "https://github.com/mohamedtantawey/payops/blob/main/backend/src/core/connectorAdapter.js"
click node_hosted_checkout "https://github.com/mohamedtantawey/payops/blob/main/backend/src/core/hostedCheckout.js"
click node_jobs "https://github.com/mohamedtantawey/payops/blob/main/backend/src/queue/jobQueue.js"
click node_worker "https://github.com/mohamedtantawey/payops/blob/main/worker/src/worker.js"
click node_webhook_handler "https://github.com/mohamedtantawey/payops/blob/main/worker/src/handlers/webhookHandler.js"
click node_invoice_handler "https://github.com/mohamedtantawey/payops/blob/main/worker/src/handlers/invoiceHandler.js"
click node_billing_handler "https://github.com/mohamedtantawey/payops/blob/main/worker/src/handlers/billingHandler.js"
click node_analytics "https://github.com/mohamedtantawey/payops/blob/main/worker/src/handlers/analyticsConsumer.js"
click node_database "https://github.com/mohamedtantawey/payops/blob/main/backend/src/shared/db.js"
click node_redis "https://github.com/mohamedtantawey/payops/blob/main/backend/src/shared/redis.js"
click node_mock_psp "https://github.com/mohamedtantawey/payops/blob/main/mock-psp/src/server.js"

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_control,node_client_api,node_checkout_ui,node_payments_ui,node_routing_ui,node_invoice_ui,node_webhook_ui,node_rbac_ui,node_status_ui toneBlue
class node_api_server,node_auth,node_payments,node_routing_routes,node_admin_routes,node_invoice_routes,node_billing_routes,node_webhook_routes,node_status_routes,node_payment_flow,node_state_machine,node_vault,node_connector,node_hosted_checkout toneAmber
class node_jobs,node_worker,node_webhook_handler,node_invoice_handler,node_billing_handler,node_analytics,node_webhook_receiver toneMint
class node_database,node_redis,node_mock_psp toneRose
class node_merchant toneIndigo
```

## Components

### Control center

- [Control center](https://github.com/mohamedtantawey/payops/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [API client](https://github.com/mohamedtantawey/payops/blob/main/frontend/src/api.js): `frontend/src/api.js`
- [Hosted checkout UI](https://github.com/mohamedtantawey/payops/blob/main/frontend/src/components/HostedCheckout.jsx): `frontend/src/components/HostedCheckout.jsx`
- [Payments table](https://github.com/mohamedtantawey/payops/blob/main/frontend/src/components/PaymentsTable.jsx): `frontend/src/components/PaymentsTable.jsx`
- [Routing editor](https://github.com/mohamedtantawey/payops/blob/main/frontend/src/components/RoutingEditor.jsx): `frontend/src/components/RoutingEditor.jsx`
- [Invoice list](https://github.com/mohamedtantawey/payops/blob/main/frontend/src/components/InvoiceList.jsx): `frontend/src/components/InvoiceList.jsx`
- [Webhook log](https://github.com/mohamedtantawey/payops/blob/main/frontend/src/components/WebhookLog.jsx): `frontend/src/components/WebhookLog.jsx`
- [RBAC manager](https://github.com/mohamedtantawey/payops/blob/main/frontend/src/components/RbacManager.jsx): `frontend/src/components/RbacManager.jsx`
- [Status banner](https://github.com/mohamedtantawey/payops/blob/main/frontend/src/components/StatusBanner.jsx): `frontend/src/components/StatusBanner.jsx`

### API and payments

- [Express API](https://github.com/mohamedtantawey/payops/blob/main/backend/src/server.js): `backend/src/server.js`
- [API-key RBAC](https://github.com/mohamedtantawey/payops/blob/main/backend/src/middleware/authRbac.js): `backend/src/middleware/authRbac.js`
- [Payments routes](https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/payments.js): `backend/src/routes/payments.js`
- [Routing routes](https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/routing.js): `backend/src/routes/routing.js`
- [Administration](https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/admin.js): `backend/src/routes/admin.js`
- [Invoice routes](https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/invoices.js): `backend/src/routes/invoices.js`
- [Billing routes](https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/billing.js): `backend/src/routes/billing.js`
- [Webhook routes](https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/webhooks.js): `backend/src/routes/webhooks.js`
- [Status routes](https://github.com/mohamedtantawey/payops/blob/main/backend/src/routes/status.js): `backend/src/routes/status.js`
- [Payment orchestration](https://github.com/mohamedtantawey/payops/blob/main/backend/src/core/routingEngine.js): `backend/src/core/routingEngine.js`
- [Payment state machine](https://github.com/mohamedtantawey/payops/blob/main/backend/src/core/paymentStateMachine.js): `backend/src/core/paymentStateMachine.js`
- [Vault tokenization](https://github.com/mohamedtantawey/payops/blob/main/backend/src/core/vaultClient.js): `backend/src/core/vaultClient.js`
- [PSP connector adapter](https://github.com/mohamedtantawey/payops/blob/main/backend/src/core/connectorAdapter.js): `backend/src/core/connectorAdapter.js`
- [Checkout service](https://github.com/mohamedtantawey/payops/blob/main/backend/src/core/hostedCheckout.js): `backend/src/core/hostedCheckout.js`

### Background jobs

- [Redis job queue](https://github.com/mohamedtantawey/payops/blob/main/backend/src/queue/jobQueue.js): `backend/src/queue/jobQueue.js`
- [Job worker](https://github.com/mohamedtantawey/payops/blob/main/worker/src/worker.js): `worker/src/worker.js`
- [Webhook delivery](https://github.com/mohamedtantawey/payops/blob/main/worker/src/handlers/webhookHandler.js): `worker/src/handlers/webhookHandler.js`
- [Invoice generation](https://github.com/mohamedtantawey/payops/blob/main/worker/src/handlers/invoiceHandler.js): `worker/src/handlers/invoiceHandler.js`
- [Billing runs](https://github.com/mohamedtantawey/payops/blob/main/worker/src/handlers/billingHandler.js): `worker/src/handlers/billingHandler.js`
- [Analytics consumer](https://github.com/mohamedtantawey/payops/blob/main/worker/src/handlers/analyticsConsumer.js): `worker/src/handlers/analyticsConsumer.js`

### State and integrations

- [PostgreSQL](https://github.com/mohamedtantawey/payops/blob/main/backend/src/shared/db.js): `backend/src/shared/db.js`
- [Redis services](https://github.com/mohamedtantawey/payops/blob/main/backend/src/shared/redis.js): `backend/src/shared/redis.js`
- [Simulated PSP](https://github.com/mohamedtantawey/payops/blob/main/mock-psp/src/server.js): external system · `mock-psp/src/server.js`

### Other components

- **Merchant / operator**
- **Webhook receiver**: external system

## Connections

- Merchant / operator → Control center: operates (evidence: `README.md`)
- Merchant / operator → API client: calls (evidence: `README.md`)
- Control center → Payments table: renders (evidence: `frontend/src/App.jsx`)
- Control center → Routing editor: renders (evidence: `frontend/src/App.jsx`)
- Control center → Invoice list: renders (evidence: `frontend/src/App.jsx`)
- Control center → Webhook log: renders (evidence: `frontend/src/App.jsx`)
- Control center → RBAC manager: renders (evidence: `frontend/src/App.jsx`)
- Control center → Status banner: renders (evidence: `frontend/src/App.jsx`)
- Control center → Hosted checkout UI: renders (evidence: `frontend/src/App.jsx`)
- Payments table → API client: requests (evidence: `frontend/src/components/PaymentsTable.jsx`)
- Routing editor → API client: requests (evidence: `frontend/src/components/RoutingEditor.jsx`)
- Invoice list → API client: requests (evidence: `frontend/src/components/InvoiceList.jsx`)
- Webhook log → API client: requests (evidence: `frontend/src/components/WebhookLog.jsx`)
- RBAC manager → API client: requests (evidence: `frontend/src/components/RbacManager.jsx`)
- API client → Express API: sends requests (evidence: `README.md`)
- Express API → Payments routes: routes to (evidence: `backend/src/server.js`)
- Express API → Routing routes: routes to (evidence: `backend/src/server.js`)
- Express API → Administration: routes to (evidence: `backend/src/server.js`)
- Express API → Invoice routes: routes to (evidence: `backend/src/server.js`)
- Express API → Billing routes: routes to (evidence: `backend/src/server.js`)
- Express API → Webhook routes: routes to (evidence: `backend/src/server.js`)
- Express API → Status routes: routes to (evidence: `backend/src/server.js`)
- Payments routes → API-key RBAC: authenticates with (evidence: `backend/src/routes/payments.js`)
- Routing routes → API-key RBAC: authenticates with (evidence: `backend/src/routes/routing.js`)
- Administration → API-key RBAC: authorizes with (evidence: `backend/src/routes/admin.js`)
- Payments routes → Payment orchestration: executes (evidence: `backend/src/routes/payments.js`)
- Payments routes → Payment state machine: transitions (evidence: `backend/src/routes/payments.js`)
- Payments routes → Vault tokenization: tokenizes with (evidence: `backend/src/routes/payments.js`)
- Payments routes → Checkout service: uses (evidence: `backend/src/routes/payments.js`)
- Payment orchestration → Payment state machine: transitions (evidence: `backend/src/core/routingEngine.js`)
- Payment orchestration → Vault tokenization: detokenizes with (evidence: `backend/src/core/routingEngine.js`)
- Payment orchestration → PSP connector adapter: authorizes through (evidence: `backend/src/core/routingEngine.js`)
- PSP connector adapter → PostgreSQL: reads credentials (evidence: `backend/src/core/connectorAdapter.js`)
- PSP connector adapter → Simulated PSP: calls PSP
- Payments routes → Redis job queue: enqueues jobs (evidence: `backend/src/routes/payments.js`)
- Invoice routes → Redis job queue: enqueues generation (evidence: `backend/src/routes/invoices.js`)
- Billing routes → Redis job queue: enqueues runs (evidence: `backend/src/routes/billing.js`)
- Webhook routes → Redis job queue: enqueues dispatch (evidence: `backend/src/routes/webhooks.js`)
- Redis job queue → Redis services: pushes jobs (evidence: `backend/src/queue/jobQueue.js`)
- Job worker → Redis job queue: consumes queue (evidence: `worker/src/worker.js`)
- Job worker → Webhook delivery: dispatches to (evidence: `worker/src/worker.js`)
- Job worker → Invoice generation: dispatches to (evidence: `worker/src/worker.js`)
- Job worker → Billing runs: dispatches to (evidence: `worker/src/worker.js`)
- Job worker → Analytics consumer: dispatches to (evidence: `worker/src/worker.js`)
- Webhook delivery → PostgreSQL: records deliveries (evidence: `worker/src/handlers/webhookHandler.js`)
- Webhook delivery → Webhook receiver: posts signed events (evidence: `worker/src/handlers/webhookHandler.js`)
- Invoice generation → PostgreSQL: reads and writes (evidence: `worker/src/handlers/invoiceHandler.js`)
- Billing runs → Payment orchestration: executes payments (evidence: `worker/src/handlers/billingHandler.js`)
