# dostonabdunazarov/trademanagementsystem architecture

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

- Interactive diagram: https://gitdiagram.com/dostonabdunazarov/trademanagementsystem
- Repository: https://github.com/dostonabdunazarov/trademanagementsystem
- Video tour (about a minute): https://gitdiagram.com/dostonabdunazarov/trademanagementsystem/video

## Overview

TradeMS is a multi-tenant trade-management system: users work in a React UI to manage reference data and documents, confirm transactions that affect stock and balances, and review dashboards and reports. The documented request path runs through the API into CQRS application handlers and PostgreSQL persistence. Sampled report and query handlers show direct database reads; document confirmation’s stock, balance, and account effects are documented, but its internal implementation was not sampled.

Main entry points: [`TradeMS/TradeMS.Api/Endpoints`](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Api/Endpoints) (HTTP endpoints), [`TradeMS/TradeMS.Infrastructure/Persistence/AppDbContext.cs`](https://github.com/dostonabdunazarov/trademanagementsystem/blob/main/TradeMS/TradeMS.Infrastructure/Persistence/AppDbContext.cs) (Database context), [`trade-ms-ui/src/App.tsx`](https://github.com/dostonabdunazarov/trademanagementsystem/blob/main/trade-ms-ui/src/App.tsx) (UI shell and routes), [`trade-ms-ui/src/api`](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/trade-ms-ui/src/api) (API hooks and clients)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["React application"]
  node_app["UI shell and routes<br/>[App.tsx]"]
  node_authui["Login<br/>[LoginPage.tsx]"]
  node_docsui["Document workflows"]
  node_catalogui["Catalog and parties"]
  node_reportui["Dashboard and reports"]
  node_settingsui["Settings and audit"]
  node_hooks["API hooks and clients"]
end

subgraph group_api["API and application"]
  node_api["HTTP endpoints<br/>[Endpoints]"]
  node_jwt["JWT service<br/>[JwtService.cs]"]
end

subgraph group_business["Trade operations"]
  node_auth["Authentication<br/>[Auth]"]
  node_documents["Document commands and queries<br/>[Documents]"]
  node_catalog["Products and groups<br/>[Products]"]
  node_counterparties["Counterparties<br/>[Counterparties]"]
  node_money["Currencies and accounts<br/>[Currencies]"]
  node_reports["Dashboard and reports<br/>[Reports]"]
  node_admin["Users, branches, audit<br/>[Features]"]
  node_domain["Trade entities<br/>[Entities]"]
end

subgraph group_data["Persistence"]
  node_context["Database context<br/>[AppDbContext.cs]"]
  node_db[("PostgreSQL")]
end

node_user(("Staff user"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_authui
node_app -->|"routes to"| node_docsui
node_app -->|"routes to"| node_catalogui
node_app -->|"routes to"| node_reportui
node_app -->|"routes to"| node_settingsui
node_authui -->|"requests login"| node_hooks
node_docsui -->|"requests documents"| node_hooks
node_catalogui -->|"requests data"| node_hooks
node_reportui -->|"requests reports"| node_hooks
node_settingsui -->|"requests settings"| node_hooks
node_hooks -->|"HTTP requests"| node_api
node_api -->|"dispatches"| node_auth
node_api -->|"dispatches"| node_documents
node_api -->|"dispatches"| node_catalog
node_api -->|"dispatches"| node_counterparties
node_api -->|"dispatches"| node_money
node_api -->|"dispatches"| node_reports
node_api -->|"dispatches"| node_admin
node_api -->|"uses"| node_jwt
node_documents -->|"reads and writes"| node_context
node_catalog -->|"reads and writes"| node_context
node_counterparties -->|"reads and writes"| node_context
node_money -->|"reads and writes"| node_context
node_reports -->|"reads"| node_context
node_admin -->|"reads and writes"| node_context
node_auth -->|"reads and writes"| node_context
node_context -->|"persists data"| node_db
node_documents -->|"uses entities"| node_domain
node_context -->|"maps entities"| node_domain

click node_app "https://github.com/dostonabdunazarov/trademanagementsystem/blob/main/trade-ms-ui/src/App.tsx"
click node_authui "https://github.com/dostonabdunazarov/trademanagementsystem/blob/main/trade-ms-ui/src/features/auth/LoginPage.tsx"
click node_docsui "https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/trade-ms-ui/src/features/documents"
click node_catalogui "https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/trade-ms-ui/src/features/products"
click node_reportui "https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/trade-ms-ui/src/features/dashboard"
click node_settingsui "https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/trade-ms-ui/src/features/settings"
click node_hooks "https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/trade-ms-ui/src/api"
click node_api "https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Api/Endpoints"
click node_auth "https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Application/Features/Auth"
click node_documents "https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Application/Features/Documents"
click node_catalog "https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Application/Features/Products"
click node_counterparties "https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Application/Features/Counterparties"
click node_money "https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Application/Features/Currencies"
click node_reports "https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Application/Features/Reports"
click node_admin "https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Application/Features"
click node_domain "https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Domain/Entities"
click node_context "https://github.com/dostonabdunazarov/trademanagementsystem/blob/main/TradeMS/TradeMS.Infrastructure/Persistence/AppDbContext.cs"
click node_jwt "https://github.com/dostonabdunazarov/trademanagementsystem/blob/main/TradeMS/TradeMS.Infrastructure/Services/JwtService.cs"

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_app,node_authui,node_docsui,node_catalogui,node_reportui,node_settingsui,node_hooks,node_user toneBlue
class node_api,node_jwt toneAmber
class node_auth,node_documents,node_catalog,node_counterparties,node_money,node_reports,node_admin,node_domain toneMint
class node_context,node_db toneRose
```

## Components

### React application

- [UI shell and routes](https://github.com/dostonabdunazarov/trademanagementsystem/blob/main/trade-ms-ui/src/App.tsx): `trade-ms-ui/src/App.tsx`
- [Login](https://github.com/dostonabdunazarov/trademanagementsystem/blob/main/trade-ms-ui/src/features/auth/LoginPage.tsx): `trade-ms-ui/src/features/auth/LoginPage.tsx`
- [Document workflows](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/trade-ms-ui/src/features/documents): `trade-ms-ui/src/features/documents`
- [Catalog and parties](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/trade-ms-ui/src/features/products): `trade-ms-ui/src/features/products`
- [Dashboard and reports](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/trade-ms-ui/src/features/dashboard): `trade-ms-ui/src/features/dashboard`
- [Settings and audit](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/trade-ms-ui/src/features/settings): `trade-ms-ui/src/features/settings`
- [API hooks and clients](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/trade-ms-ui/src/api): `trade-ms-ui/src/api`

### API and application

- [HTTP endpoints](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Api/Endpoints): `TradeMS/TradeMS.Api/Endpoints`
- [JWT service](https://github.com/dostonabdunazarov/trademanagementsystem/blob/main/TradeMS/TradeMS.Infrastructure/Services/JwtService.cs): `TradeMS/TradeMS.Infrastructure/Services/JwtService.cs`

### Trade operations

- [Authentication](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Application/Features/Auth): `TradeMS/TradeMS.Application/Features/Auth`
- [Document commands and queries](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Application/Features/Documents): `TradeMS/TradeMS.Application/Features/Documents`
- [Products and groups](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Application/Features/Products): `TradeMS/TradeMS.Application/Features/Products`
- [Counterparties](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Application/Features/Counterparties): `TradeMS/TradeMS.Application/Features/Counterparties`
- [Currencies and accounts](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Application/Features/Currencies): `TradeMS/TradeMS.Application/Features/Currencies`
- [Dashboard and reports](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Application/Features/Reports): `TradeMS/TradeMS.Application/Features/Reports`
- [Users, branches, audit](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Application/Features): `TradeMS/TradeMS.Application/Features`
- [Trade entities](https://github.com/dostonabdunazarov/trademanagementsystem/tree/main/TradeMS/TradeMS.Domain/Entities): `TradeMS/TradeMS.Domain/Entities`

### Persistence

- [Database context](https://github.com/dostonabdunazarov/trademanagementsystem/blob/main/TradeMS/TradeMS.Infrastructure/Persistence/AppDbContext.cs): `TradeMS/TradeMS.Infrastructure/Persistence/AppDbContext.cs`
- **PostgreSQL**

### Other components

- **Staff user**

## Connections

- Staff user → UI shell and routes: uses
- UI shell and routes → Login: routes to
- UI shell and routes → Document workflows: routes to
- UI shell and routes → Catalog and parties: routes to
- UI shell and routes → Dashboard and reports: routes to
- UI shell and routes → Settings and audit: routes to
- Login → API hooks and clients: requests login
- Document workflows → API hooks and clients: requests documents
- Catalog and parties → API hooks and clients: requests data
- Dashboard and reports → API hooks and clients: requests reports
- Settings and audit → API hooks and clients: requests settings
- API hooks and clients → HTTP endpoints: HTTP requests
- HTTP endpoints → Authentication: dispatches
- HTTP endpoints → Document commands and queries: dispatches
- HTTP endpoints → Products and groups: dispatches
- HTTP endpoints → Counterparties: dispatches
- HTTP endpoints → Currencies and accounts: dispatches
- HTTP endpoints → Dashboard and reports: dispatches
- HTTP endpoints → Users, branches, audit: dispatches
- HTTP endpoints → JWT service: uses
- Document commands and queries → Database context: reads and writes
- Products and groups → Database context: reads and writes
- Counterparties → Database context: reads and writes
- Currencies and accounts → Database context: reads and writes
- Dashboard and reports → Database context: reads
- Users, branches, audit → Database context: reads and writes
- Authentication → Database context: reads and writes
- Database context → PostgreSQL: persists data
- Document commands and queries → Trade entities: uses entities
- Database context → Trade entities: maps entities
