# ddxahmed/order architecture

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

- Interactive diagram: https://gitdiagram.com/ddxahmed/order
- Repository: https://github.com/ddxahmed/order

## Overview

OrderTrofy manages game-account inventory and delivers Steam Guard verification codes through a customer portal or Telegram, with a separate admin experience for operations. The principal flow is order activation, account assignment, verification request, mailbox scanning, code extraction and protected delivery. Admin capabilities include inventory and order management, CSV import, customer and mailbox administration, audit and Salla integration. The source index shows the API entry point importing core services; several feature links rely on README descriptions because their route implementations were not sampled.

Main entry points: [`app/main.py`](https://github.com/ddxahmed/order/blob/main/app/main.py) (FastAPI application), [`app/worker.py`](https://github.com/ddxahmed/order/blob/main/app/worker.py) (Background worker), [`frontend/src/pages/customer/CustomerPortal.jsx`](https://github.com/ddxahmed/order/blob/main/frontend/src/pages/customer/CustomerPortal.jsx) (Customer portal), [`frontend/src/pages/admin`](https://github.com/ddxahmed/order/tree/main/frontend/src/pages/admin) (Admin views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Customer and admin UI"]
  node_portal["Customer portal<br/>[CustomerPortal.jsx]"]
  node_adminui["Admin views"]
  node_app["UI route selection<br/>[App.jsx]"]
  node_client["API client<br/>[client.js]"]
end

subgraph group_api["API and operations"]
  node_api_entry["FastAPI application<br/>[main.py]"]
  node_auth["Authentication routes<br/>[auth.py]"]
  node_admin_routes["Admin operations routes"]
  node_csv["CSV import<br/>[csv_import.py]"]
end

subgraph group_domain["Orders and verification"]
  node_customer_svc["Customer access<br/>[customer.py]"]
  node_inventory["Inventory allocation<br/>[inventory.py]"]
  node_verification["Code verification<br/>[verification.py]"]
  node_worker["Background worker<br/>[worker.py]"]
end

subgraph group_integrations["External integrations"]
  node_telegram["Telegram bot<br/>[bot.py]"]
  node_mail["Mailbox providers<br/>[imap_provider.py]"]
  node_microsoft["Microsoft Graph mail<br/>[microsoft.py]"]
  node_salla["Salla integration<br/>[salla.py]"]
  node_salla_notify["Salla notifications"]
end

subgraph group_foundation["Persistence and security"]
  node_db["Database session<br/>[db.py]"]
  node_models[("Domain records<br/>[models.py]")]
  node_security["Security utilities<br/>[security.py]"]
  node_audit["Audit logging<br/>[audit.py]"]
end

node_customer(("Customer"))
node_admin(("Administrator"))
node_postgres[("PostgreSQL")]
node_email["Mailbox services"]
node_salla_external["Salla"]

node_customer -->|"uses"| node_portal
node_admin -->|"uses"| node_adminui
node_portal -->|"renders through"| node_app
node_adminui -->|"routes through"| node_app
node_portal -.->|"requests API"| node_client
node_adminui -.->|"requests API"| node_client
node_client -.->|"calls API"| node_api_entry
node_api_entry -->|"registers routes"| node_auth
node_api_entry -->|"registers routes"| node_admin_routes
node_api_entry -->|"uses"| node_customer_svc
node_api_entry -->|"uses"| node_inventory
node_api_entry -->|"uses"| node_csv
node_auth -->|"verifies credentials"| node_security
node_auth -->|"records events"| node_audit
node_api_entry -->|"uses sessions"| node_db
node_db -->|"connects"| node_postgres
node_db -->|"persists records"| node_models
node_customer_svc -->|"reads assignments"| node_inventory
node_customer_svc -->|"records events"| node_audit
node_worker -->|"processes requests"| node_verification
node_worker -->|"delivers results"| node_telegram
node_worker -->|"polls notifications"| node_salla_notify
node_verification -->|"reads messages"| node_mail
node_verification -->|"protects codes"| node_security
node_microsoft -->|"shares message model"| node_mail
node_mail -->|"reads inbox"| node_email
node_salla_notify -->|"uses integration"| node_salla
node_salla -.->|"connects"| node_salla_external
node_inventory -->|"reads and writes"| node_models
node_security -->|"protects stored secrets"| node_models

click node_portal "https://github.com/ddxahmed/order/blob/main/frontend/src/pages/customer/CustomerPortal.jsx"
click node_adminui "https://github.com/ddxahmed/order/tree/main/frontend/src/pages/admin"
click node_app "https://github.com/ddxahmed/order/blob/main/frontend/src/App.jsx"
click node_client "https://github.com/ddxahmed/order/blob/main/frontend/src/api/client.js"
click node_api_entry "https://github.com/ddxahmed/order/blob/main/app/main.py"
click node_auth "https://github.com/ddxahmed/order/blob/main/app/api/routers/auth.py"
click node_admin_routes "https://github.com/ddxahmed/order/tree/main/app/api/routers"
click node_csv "https://github.com/ddxahmed/order/blob/main/app/services/csv_import.py"
click node_customer_svc "https://github.com/ddxahmed/order/blob/main/app/services/customer.py"
click node_inventory "https://github.com/ddxahmed/order/blob/main/app/services/inventory.py"
click node_verification "https://github.com/ddxahmed/order/blob/main/app/services/verification.py"
click node_worker "https://github.com/ddxahmed/order/blob/main/app/worker.py"
click node_telegram "https://github.com/ddxahmed/order/blob/main/app/bot.py"
click node_mail "https://github.com/ddxahmed/order/blob/main/app/mail/imap_provider.py"
click node_microsoft "https://github.com/ddxahmed/order/blob/main/app/mail/microsoft.py"
click node_salla "https://github.com/ddxahmed/order/blob/main/app/integrations/salla.py"
click node_salla_notify "https://github.com/ddxahmed/order/blob/main/app/services/salla_notifications.py"
click node_db "https://github.com/ddxahmed/order/blob/main/app/db.py"
click node_models "https://github.com/ddxahmed/order/blob/main/app/models.py"
click node_security "https://github.com/ddxahmed/order/blob/main/app/security.py"
click node_audit "https://github.com/ddxahmed/order/blob/main/app/audit.py"

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_portal,node_adminui,node_app,node_client toneBlue
class node_api_entry,node_auth,node_admin_routes,node_csv,node_postgres toneAmber
class node_customer_svc,node_inventory,node_verification,node_worker toneMint
class node_telegram,node_mail,node_microsoft,node_salla,node_salla_notify toneRose
class node_db,node_models,node_security,node_audit,node_customer,node_admin,node_email,node_salla_external toneIndigo
```

## Components

### Customer and admin UI

- [Customer portal](https://github.com/ddxahmed/order/blob/main/frontend/src/pages/customer/CustomerPortal.jsx): `frontend/src/pages/customer/CustomerPortal.jsx`
- [Admin views](https://github.com/ddxahmed/order/tree/main/frontend/src/pages/admin): `frontend/src/pages/admin`
- [UI route selection](https://github.com/ddxahmed/order/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [API client](https://github.com/ddxahmed/order/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`

### API and operations

- [FastAPI application](https://github.com/ddxahmed/order/blob/main/app/main.py): `app/main.py`
- [Authentication routes](https://github.com/ddxahmed/order/blob/main/app/api/routers/auth.py): `app/api/routers/auth.py`
- [Admin operations routes](https://github.com/ddxahmed/order/tree/main/app/api/routers): `app/api/routers`
- [CSV import](https://github.com/ddxahmed/order/blob/main/app/services/csv_import.py): `app/services/csv_import.py`

### Orders and verification

- [Customer access](https://github.com/ddxahmed/order/blob/main/app/services/customer.py): `app/services/customer.py`
- [Inventory allocation](https://github.com/ddxahmed/order/blob/main/app/services/inventory.py): `app/services/inventory.py`
- [Code verification](https://github.com/ddxahmed/order/blob/main/app/services/verification.py): `app/services/verification.py`
- [Background worker](https://github.com/ddxahmed/order/blob/main/app/worker.py): `app/worker.py`

### External integrations

- [Telegram bot](https://github.com/ddxahmed/order/blob/main/app/bot.py): `app/bot.py`
- [Mailbox providers](https://github.com/ddxahmed/order/blob/main/app/mail/imap_provider.py): `app/mail/imap_provider.py`
- [Microsoft Graph mail](https://github.com/ddxahmed/order/blob/main/app/mail/microsoft.py): `app/mail/microsoft.py`
- [Salla integration](https://github.com/ddxahmed/order/blob/main/app/integrations/salla.py): `app/integrations/salla.py`
- [Salla notifications](https://github.com/ddxahmed/order/blob/main/app/services/salla_notifications.py): `app/services/salla_notifications.py`

### Persistence and security

- [Database session](https://github.com/ddxahmed/order/blob/main/app/db.py): `app/db.py`
- [Domain records](https://github.com/ddxahmed/order/blob/main/app/models.py): `app/models.py`
- [Security utilities](https://github.com/ddxahmed/order/blob/main/app/security.py): `app/security.py`
- [Audit logging](https://github.com/ddxahmed/order/blob/main/app/audit.py): `app/audit.py`

### Other components

- **Customer**
- **Administrator**
- **PostgreSQL**
- **Mailbox services**
- **Salla**

## Connections

- Customer → Customer portal: uses
- Administrator → Admin views: uses
- Customer portal → UI route selection: renders through (evidence: `frontend/src/App.jsx`)
- Admin views → UI route selection: routes through (evidence: `frontend/src/App.jsx`)
- Customer portal → API client: requests API
- Admin views → API client: requests API
- API client → FastAPI application: calls API
- FastAPI application → Authentication routes: registers routes (evidence: `app/main.py`)
- FastAPI application → Admin operations routes: registers routes (evidence: `app/main.py`)
- FastAPI application → Customer access: uses (evidence: `app/main.py`)
- FastAPI application → Inventory allocation: uses (evidence: `app/main.py`)
- FastAPI application → CSV import: uses (evidence: `app/main.py`)
- Authentication routes → Security utilities: verifies credentials (evidence: `app/api/routers/auth.py`)
- Authentication routes → Audit logging: records events (evidence: `app/api/routers/auth.py`)
- FastAPI application → Database session: uses sessions (evidence: `app/main.py`)
- Database session → PostgreSQL: connects (evidence: `app/db.py`)
- Database session → Domain records: persists records (evidence: `app/db.py`)
- Customer access → Inventory allocation: reads assignments (evidence: `app/services/customer.py`)
- Customer access → Audit logging: records events (evidence: `app/services/customer.py`)
- Background worker → Code verification: processes requests (evidence: `app/worker.py`)
- Background worker → Telegram bot: delivers results (evidence: `app/worker.py`)
- Background worker → Salla notifications: polls notifications (evidence: `app/worker.py`)
- Code verification → Mailbox providers: reads messages (evidence: `app/services/verification.py`)
- Code verification → Security utilities: protects codes (evidence: `app/services/verification.py`)
- Microsoft Graph mail → Mailbox providers: shares message model (evidence: `app/mail/microsoft.py`)
- Mailbox providers → Mailbox services: reads inbox (evidence: `app/mail/imap_provider.py`)
- Salla notifications → Salla integration: uses integration (evidence: `app/services/salla_notifications.py`)
- Salla integration → Salla: connects
- Inventory allocation → Domain records: reads and writes (evidence: `app/services/inventory.py`)
- Security utilities → Domain records: protects stored secrets (evidence: `app/security.py`)
