# orafaeldantas/exactum-api architecture

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

- Interactive diagram: https://gitdiagram.com/orafaeldantas/exactum-api
- Repository: https://github.com/orafaeldantas/exactum-api

## Overview

Exactum is a multi-tenant retail ERP: users authenticate and enter tenant-scoped product, sales/PDV, and analytics workflows, while super-admins manage tenants and platform operations. The graph highlights those product stages plus authorization and observability. Route-to-controller and selected service calls are supported by excerpts or the SOURCE INDEX; broader UI/API and unsampled domain wiring is shown only where documented, or omitted when the specific link is uncertain.

Main entry points: [`frontend/src/App.jsx`](https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/App.jsx) (Web app and routes), [`backend/app/domains/rbac/decorators/permissions.py`](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/rbac/decorators/permissions.py) (Permission checks), [`frontend/src/services/api.js`](https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/services/api.js) (API client), [`backend/app/domains/user/user_routes.py`](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/user/user_routes.py) (User management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_web_app["Web app and routes<br/>[App.jsx]"]
  node_auth_state["Auth context<br/>[AuthContext.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_dashboard_ui["Business dashboards<br/>[Dashboard.jsx]"]
  node_sales_ui["Sales and PDV screens<br/>[LocalSales.jsx]"]
  node_products_ui["Product screens<br/>[ListProducts.jsx]"]
  node_tenant_ui["Tenant administration"]
end

subgraph group_identity["Identity and tenancy"]
  node_auth_routes["Authentication routes<br/>[auth_routes.py]"]
  node_auth_controller["Authentication controller<br/>[auth_controller.py]"]
  node_auth_service["Sessions and impersonation<br/>[auth_service.py]"]
  node_cache[("Session cache<br/>[cache_service.py]")]
  node_tenant_domain["Tenant lifecycle<br/>[tenant_routes.py]"]
  node_user_domain["User management<br/>[user_routes.py]"]
  node_user_model[("Tenant user records<br/>[user.py]")]
end

subgraph group_commerce["Retail operations"]
  node_product_domain["Product inventory<br/>[product_routes.py]"]
  node_sale_domain["Sales and PDV<br/>[sale_routes.py]"]
  node_analytics_domain["Sales analytics"]
end

subgraph group_access["Authorization"]
  node_rbac_routes["Role management<br/>[rbac_routes.py]"]
  node_permission_guard["Permission checks<br/>[permissions.py]"]
  node_rbac_service["Effective permissions<br/>[rbac_service.py]"]
end

subgraph group_operations["Platform operations"]
  node_audit["Tenant audit logs<br/>[audit_service.py]"]
  node_platform_routes["Platform operations API<br/>[platform_routes.py]"]
  node_platform_controller["Platform operations"]
  node_health["Health checks<br/>[health_routes.py]"]
end

node_user_actor(("Retail user"))
node_admin_actor(("Platform admin"))

node_user_actor -->|"uses"| node_web_app
node_admin_actor -->|"administers"| node_web_app
node_web_app -->|"reads auth"| node_auth_state
node_auth_state -->|"requests bootstrap"| node_api_client
node_web_app -->|"routes to"| node_dashboard_ui
node_web_app -->|"routes to"| node_sales_ui
node_web_app -->|"routes to"| node_products_ui
node_web_app -->|"routes to"| node_tenant_ui
node_api_client -.->|"calls API"| node_auth_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"delegates"| node_auth_service
node_auth_service -->|"stores sessions"| node_cache
node_tenant_domain -->|"checks access"| node_permission_guard
node_user_domain -->|"checks access"| node_permission_guard
node_user_domain -->|"uses records"| node_user_model
node_product_domain -->|"checks access"| node_permission_guard
node_sale_domain -->|"checks access"| node_permission_guard
node_rbac_routes -->|"checks access"| node_permission_guard
node_permission_guard -->|"resolves permissions"| node_rbac_service
node_platform_routes -->|"dispatches"| node_platform_controller
node_platform_controller -.->|"records events"| node_audit
node_analytics_domain -.->|"analyzes sales"| node_sale_domain
node_health -.->|"serves status"| node_api_client

click node_web_app "https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/App.jsx"
click node_auth_state "https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/context/AuthContext.jsx"
click node_api_client "https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/services/api.js"
click node_dashboard_ui "https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/pages/dashboard/Dashboard.jsx"
click node_sales_ui "https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/pages/pdv/LocalSales.jsx"
click node_products_ui "https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/pages/products/ListProducts.jsx"
click node_tenant_ui "https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/pages/platform/ManageCompanies.jsx"
click node_auth_routes "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/auth/auth_routes.py"
click node_auth_controller "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/auth/auth_controller.py"
click node_auth_service "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/auth/auth_service.py"
click node_cache "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/core/cache/cache_service.py"
click node_tenant_domain "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/tenant/tenant_routes.py"
click node_user_domain "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/user/user_routes.py"
click node_user_model "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/models/user.py"
click node_product_domain "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/product/product_routes.py"
click node_sale_domain "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/sale/routes/sale_routes.py"
click node_analytics_domain "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/sale/services/revenue_analytics_service.py"
click node_rbac_routes "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/rbac/rbac_routes.py"
click node_permission_guard "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/rbac/decorators/permissions.py"
click node_rbac_service "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/rbac/rbac_service.py"
click node_audit "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/observability/audit_service.py"
click node_platform_routes "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/platform/platform_routes.py"
click node_platform_controller "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/platform/platform_controller.py"
click node_health "https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/core/monitoring/health_routes.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_web_app,node_auth_state,node_api_client,node_dashboard_ui,node_sales_ui,node_products_ui,node_tenant_ui,node_user_actor toneBlue
class node_auth_routes,node_auth_controller,node_auth_service,node_cache,node_tenant_domain,node_user_domain,node_user_model toneAmber
class node_product_domain,node_sale_domain,node_analytics_domain toneMint
class node_rbac_routes,node_permission_guard,node_rbac_service toneRose
class node_audit,node_platform_routes,node_platform_controller,node_health,node_admin_actor toneIndigo
```

## Components

### Web application

- [Web app and routes](https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth context](https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [API client](https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Business dashboards](https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/pages/dashboard/Dashboard.jsx): `frontend/src/pages/dashboard/Dashboard.jsx`
- [Sales and PDV screens](https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/pages/pdv/LocalSales.jsx): `frontend/src/pages/pdv/LocalSales.jsx`
- [Product screens](https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/pages/products/ListProducts.jsx): `frontend/src/pages/products/ListProducts.jsx`
- [Tenant administration](https://github.com/orafaeldantas/exactum-api/blob/main/frontend/src/pages/platform/ManageCompanies.jsx): `frontend/src/pages/platform/ManageCompanies.jsx`

### Identity and tenancy

- [Authentication routes](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/auth/auth_routes.py): `backend/app/domains/auth/auth_routes.py`
- [Authentication controller](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/auth/auth_controller.py): `backend/app/domains/auth/auth_controller.py`
- [Sessions and impersonation](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/auth/auth_service.py): `backend/app/domains/auth/auth_service.py`
- [Session cache](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/core/cache/cache_service.py): `backend/app/core/cache/cache_service.py`
- [Tenant lifecycle](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/tenant/tenant_routes.py): `backend/app/domains/tenant/tenant_routes.py`
- [User management](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/user/user_routes.py): `backend/app/domains/user/user_routes.py`
- [Tenant user records](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/models/user.py): `backend/app/models/user.py`

### Retail operations

- [Product inventory](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/product/product_routes.py): `backend/app/domains/product/product_routes.py`
- [Sales and PDV](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/sale/routes/sale_routes.py): `backend/app/domains/sale/routes/sale_routes.py`
- [Sales analytics](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/sale/services/revenue_analytics_service.py): `backend/app/domains/sale/services/revenue_analytics_service.py`

### Authorization

- [Role management](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/rbac/rbac_routes.py): `backend/app/domains/rbac/rbac_routes.py`
- [Permission checks](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/rbac/decorators/permissions.py): `backend/app/domains/rbac/decorators/permissions.py`
- [Effective permissions](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/rbac/rbac_service.py): `backend/app/domains/rbac/rbac_service.py`

### Platform operations

- [Tenant audit logs](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/observability/audit_service.py): `backend/app/domains/observability/audit_service.py`
- [Platform operations API](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/platform/platform_routes.py): `backend/app/domains/platform/platform_routes.py`
- [Platform operations](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/domains/platform/platform_controller.py): `backend/app/domains/platform/platform_controller.py`
- [Health checks](https://github.com/orafaeldantas/exactum-api/blob/main/backend/app/core/monitoring/health_routes.py): `backend/app/core/monitoring/health_routes.py`

### Other components

- **Retail user**
- **Platform admin**

## Connections

- Retail user → Web app and routes: uses
- Platform admin → Web app and routes: administers
- Web app and routes → Auth context: reads auth (evidence: `frontend/src/App.jsx`)
- Auth context → API client: requests bootstrap (evidence: `frontend/src/context/AuthContext.jsx`)
- Web app and routes → Business dashboards: routes to (evidence: `frontend/src/App.jsx`)
- Web app and routes → Sales and PDV screens: routes to (evidence: `frontend/src/App.jsx`)
- Web app and routes → Product screens: routes to (evidence: `frontend/src/App.jsx`)
- Web app and routes → Tenant administration: routes to (evidence: `frontend/src/App.jsx`)
- API client → Authentication routes: calls API
- Authentication routes → Authentication controller: dispatches (evidence: `backend/app/domains/auth/auth_controller.py`)
- Authentication controller → Sessions and impersonation: delegates (evidence: `backend/app/domains/auth/auth_controller.py`)
- Sessions and impersonation → Session cache: stores sessions (evidence: `backend/app/domains/auth/auth_service.py`)
- Tenant lifecycle → Permission checks: checks access (evidence: `backend/app/domains/tenant/tenant_routes.py`)
- User management → Permission checks: checks access (evidence: `backend/app/domains/user/user_routes.py`)
- User management → Tenant user records: uses records (evidence: `backend/app/domains/user/user_routes.py`)
- Product inventory → Permission checks: checks access (evidence: `backend/app/domains/product/product_routes.py`)
- Sales and PDV → Permission checks: checks access (evidence: `backend/app/domains/sale/routes/sale_routes.py`)
- Role management → Permission checks: checks access (evidence: `backend/app/domains/rbac/rbac_routes.py`)
- Permission checks → Effective permissions: resolves permissions (evidence: `backend/app/domains/rbac/decorators/permissions.py`)
- Platform operations API → Platform operations: dispatches (evidence: `backend/app/domains/platform/platform_routes.py`)
- Platform operations → Tenant audit logs: records events
- Sales analytics → Sales and PDV: analyzes sales
- Health checks → API client: serves status
