# tangahubservice/excledge architecture

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

- Interactive diagram: https://gitdiagram.com/tangahubservice/excledge
- Repository: https://github.com/tangahubservice/excledge

## Overview

Excledge ERP is a multi-tenant inventory and retail operations system. Users enter through the React application, which calls the Express API; the API supports organization and branch-scoped access, product and stock management, point-of-sale sales, fiscalization, and reporting. Subscription and administration capabilities are represented from the repository tree and README, but their internal call paths were not sampled. The graph emphasizes evidenced routes and calls; other links are documented at a high level, and unsampled subsystem wiring is omitted.

Main entry points: [`Backend/src/controllers/sales.controller.ts`](https://github.com/tangahubservice/excledge/blob/main/Backend/src/controllers/sales.controller.ts) (Sales operations), [`Backend/src/routes/sales.routes.ts`](https://github.com/tangahubservice/excledge/blob/main/Backend/src/routes/sales.routes.ts) (Sales routes), [`Backend/src/routes/report.routes.ts`](https://github.com/tangahubservice/excledge/blob/main/Backend/src/routes/report.routes.ts) (Report routes), [`Frontend/src/App.tsx`](https://github.com/tangahubservice/excledge/blob/main/Frontend/src/App.tsx) (Application routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Application routes<br/>[App.tsx]"]
  node_api["API client<br/>[api-client.ts]"]
end

subgraph group_access["API and access"]
  node_server["Express API<br/>[index.ts]"]
  node_sales_routes["Sales routes<br/>[sales.routes.ts]"]
  node_report_routes["Report routes<br/>[report.routes.ts]"]
  node_branch_access["Branch access"]
  node_auth_access["Authentication<br/>[auth.middleware.ts]"]
end

subgraph group_operations["Inventory and sales"]
  node_inventory["Product inventory"]
  node_ledger["Inventory ledger"]
  node_sales["Sales operations"]
  node_sale_commit["Sale commit"]
end

subgraph group_fiscal["Fiscal and reports"]
  node_fiscal_service["RRA EBM<br/>[rra-ebm.service.ts]"]
  node_outbox["Fiscal outbox"]
  node_reports["Business reports"]
  node_profit["Profit analysis<br/>[profit.service.ts]"]
end

subgraph group_platform["Organization platform"]
  node_organization["Organization management"]
  node_subscriptions["Subscriptions"]
  node_payments["Payment providers<br/>[payment.service.ts]"]
  node_prisma["Prisma data access<br/>[prisma.ts]"]
  node_database[("PostgreSQL")]
end

node_user(("ERP user"))

node_user -->|"uses"| node_app
node_app -.->|"requests data"| node_api
node_api -->|"calls API"| node_server
node_server -.->|"serves routes"| node_sales_routes
node_sales_routes -->|"routes requests"| node_sales
node_report_routes -->|"routes requests"| node_reports
node_sales_routes -->|"authenticates"| node_auth_access
node_sales_routes -->|"checks branch"| node_branch_access
node_report_routes -->|"authenticates"| node_auth_access
node_report_routes -->|"checks branch"| node_branch_access
node_sales -->|"commits sale"| node_sale_commit
node_sales -->|"restores stock"| node_ledger
node_inventory -.->|"records movements"| node_ledger
node_reports -->|"gets profit report"| node_profit
node_prisma -->|"persists data"| node_database
node_organization -.->|"uses database"| node_prisma
node_subscriptions -.->|"handles billing"| node_payments
node_sales -.->|"fiscalizes sale"| node_fiscal_service
node_sales -.->|"queues fiscal work"| node_outbox

click node_app "https://github.com/tangahubservice/excledge/blob/main/Frontend/src/App.tsx"
click node_api "https://github.com/tangahubservice/excledge/blob/main/Frontend/src/lib/api-client.ts"
click node_server "https://github.com/tangahubservice/excledge/blob/main/Backend/src/index.ts"
click node_sales_routes "https://github.com/tangahubservice/excledge/blob/main/Backend/src/routes/sales.routes.ts"
click node_report_routes "https://github.com/tangahubservice/excledge/blob/main/Backend/src/routes/report.routes.ts"
click node_branch_access "https://github.com/tangahubservice/excledge/blob/main/Backend/src/middleware/branchAuth.middleware.ts"
click node_auth_access "https://github.com/tangahubservice/excledge/blob/main/Backend/src/middleware/auth.middleware.ts"
click node_inventory "https://github.com/tangahubservice/excledge/blob/main/Backend/src/controllers/inventory.controller.ts"
click node_ledger "https://github.com/tangahubservice/excledge/blob/main/Backend/src/services/inventory-ledger.service.ts"
click node_sales "https://github.com/tangahubservice/excledge/blob/main/Backend/src/controllers/sales.controller.ts"
click node_sale_commit "https://github.com/tangahubservice/excledge/blob/main/Backend/src/services/sale-commit.service.ts"
click node_fiscal_service "https://github.com/tangahubservice/excledge/blob/main/Backend/src/services/rra-ebm.service.ts"
click node_outbox "https://github.com/tangahubservice/excledge/blob/main/Backend/src/services/ebm-outbox.service.ts"
click node_reports "https://github.com/tangahubservice/excledge/blob/main/Backend/src/controllers/report.controller.ts"
click node_profit "https://github.com/tangahubservice/excledge/blob/main/Backend/src/services/profit.service.ts"
click node_organization "https://github.com/tangahubservice/excledge/blob/main/Backend/src/controllers/organization.controller.ts"
click node_subscriptions "https://github.com/tangahubservice/excledge/blob/main/Backend/src/services/subscription.service.ts"
click node_payments "https://github.com/tangahubservice/excledge/blob/main/Backend/src/services/payment.service.ts"
click node_prisma "https://github.com/tangahubservice/excledge/blob/main/Backend/src/lib/prisma.ts"

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_api,node_user toneBlue
class node_server,node_sales_routes,node_report_routes,node_branch_access,node_auth_access toneAmber
class node_inventory,node_ledger,node_sales,node_sale_commit toneMint
class node_fiscal_service,node_outbox,node_reports,node_profit toneRose
class node_organization,node_subscriptions,node_payments,node_prisma,node_database toneIndigo
```

## Components

### Web client

- [Application routes](https://github.com/tangahubservice/excledge/blob/main/Frontend/src/App.tsx): `Frontend/src/App.tsx`
- [API client](https://github.com/tangahubservice/excledge/blob/main/Frontend/src/lib/api-client.ts): `Frontend/src/lib/api-client.ts`

### API and access

- [Express API](https://github.com/tangahubservice/excledge/blob/main/Backend/src/index.ts): `Backend/src/index.ts`
- [Sales routes](https://github.com/tangahubservice/excledge/blob/main/Backend/src/routes/sales.routes.ts): `Backend/src/routes/sales.routes.ts`
- [Report routes](https://github.com/tangahubservice/excledge/blob/main/Backend/src/routes/report.routes.ts): `Backend/src/routes/report.routes.ts`
- [Branch access](https://github.com/tangahubservice/excledge/blob/main/Backend/src/middleware/branchAuth.middleware.ts): `Backend/src/middleware/branchAuth.middleware.ts`
- [Authentication](https://github.com/tangahubservice/excledge/blob/main/Backend/src/middleware/auth.middleware.ts): `Backend/src/middleware/auth.middleware.ts`

### Inventory and sales

- [Product inventory](https://github.com/tangahubservice/excledge/blob/main/Backend/src/controllers/inventory.controller.ts): `Backend/src/controllers/inventory.controller.ts`
- [Inventory ledger](https://github.com/tangahubservice/excledge/blob/main/Backend/src/services/inventory-ledger.service.ts): `Backend/src/services/inventory-ledger.service.ts`
- [Sales operations](https://github.com/tangahubservice/excledge/blob/main/Backend/src/controllers/sales.controller.ts): `Backend/src/controllers/sales.controller.ts`
- [Sale commit](https://github.com/tangahubservice/excledge/blob/main/Backend/src/services/sale-commit.service.ts): `Backend/src/services/sale-commit.service.ts`

### Fiscal and reports

- [RRA EBM](https://github.com/tangahubservice/excledge/blob/main/Backend/src/services/rra-ebm.service.ts): `Backend/src/services/rra-ebm.service.ts`
- [Fiscal outbox](https://github.com/tangahubservice/excledge/blob/main/Backend/src/services/ebm-outbox.service.ts): `Backend/src/services/ebm-outbox.service.ts`
- [Business reports](https://github.com/tangahubservice/excledge/blob/main/Backend/src/controllers/report.controller.ts): `Backend/src/controllers/report.controller.ts`
- [Profit analysis](https://github.com/tangahubservice/excledge/blob/main/Backend/src/services/profit.service.ts): `Backend/src/services/profit.service.ts`

### Organization platform

- [Organization management](https://github.com/tangahubservice/excledge/blob/main/Backend/src/controllers/organization.controller.ts): `Backend/src/controllers/organization.controller.ts`
- [Subscriptions](https://github.com/tangahubservice/excledge/blob/main/Backend/src/services/subscription.service.ts): `Backend/src/services/subscription.service.ts`
- [Payment providers](https://github.com/tangahubservice/excledge/blob/main/Backend/src/services/payment.service.ts): `Backend/src/services/payment.service.ts`
- [Prisma data access](https://github.com/tangahubservice/excledge/blob/main/Backend/src/lib/prisma.ts): `Backend/src/lib/prisma.ts`
- **PostgreSQL**

### Other components

- **ERP user**

## Connections

- ERP user → Application routes: uses (evidence: `README.md`)
- Application routes → API client: requests data
- API client → Express API: calls API (evidence: `README.md`)
- Express API → Sales routes: serves routes (evidence: `Backend/src/index.ts`)
- Sales routes → Sales operations: routes requests (evidence: `Backend/src/routes/sales.routes.ts`)
- Report routes → Business reports: routes requests (evidence: `Backend/src/routes/report.routes.ts`)
- Sales routes → Authentication: authenticates (evidence: `Backend/src/routes/sales.routes.ts`)
- Sales routes → Branch access: checks branch (evidence: `Backend/src/routes/sales.routes.ts`)
- Report routes → Authentication: authenticates (evidence: `Backend/src/routes/report.routes.ts`)
- Report routes → Branch access: checks branch (evidence: `Backend/src/routes/report.routes.ts`)
- Sales operations → Sale commit: commits sale (evidence: `Backend/src/controllers/sales.controller.ts`)
- Sales operations → Inventory ledger: restores stock (evidence: `Backend/src/controllers/sales.controller.ts`)
- Product inventory → Inventory ledger: records movements (evidence: `Backend/src/controllers/inventory.controller.ts`)
- Business reports → Profit analysis: gets profit report (evidence: `Backend/src/controllers/report.controller.ts`)
- Prisma data access → PostgreSQL: persists data (evidence: `README.md`)
- Organization management → Prisma data access: uses database
- Subscriptions → Payment providers: handles billing
- Sales operations → RRA EBM: fiscalizes sale (evidence: `Backend/src/controllers/sales.controller.ts`)
- Sales operations → Fiscal outbox: queues fiscal work (evidence: `Backend/src/controllers/sales.controller.ts`)
