# alexpoool/caguayo architecture

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

- Interactive diagram: https://gitdiagram.com/alexpoool/caguayo
- Repository: https://github.com/alexpoool/caguayo

## Overview

ITEMLI is a white-label, multi-tenant ERP with a React web client, FastAPI backend and a legacy-data migration utility. The main workflow is a user operating business modules in the web app, which communicates with the API and tenant databases; domains include inventory, purchasing, sales, projects, HR, administration and reporting. Authentication, tenant selection and branding support that workflow. The README documents these product capabilities, but excerpts show only selected wiring, so unverified module links are omitted or dashed. ETL is a separate migration path for the original installation.

Main entry points: [`backend/main.py`](https://github.com/alexpoool/caguayo/blob/master/backend/main.py) (FastAPI application), [`frontend/src/App.tsx`](https://github.com/alexpoool/caguayo/blob/master/frontend/src/App.tsx) (Web app and routing), [`etl/main.py`](https://github.com/alexpoool/caguayo/blob/master/etl/main.py) (Migration orchestrator), [`backend/src/database/connection.py`](https://github.com/alexpoool/caguayo/blob/master/backend/src/database/connection.py) (Tenant database connections)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webapp["Web app and routing<br/>[App.tsx]"]
  node_thirdparties["Clients and accounts<br/>[casos-uso.ts]"]
  node_inventory["Inventory"]
  node_purchasing["Purchasing"]
  node_sales["Sales"]
  node_projects["Projects and services"]
  node_hr["Human resources"]
  node_reports["Reports and dashboard"]
  node_admin["Administration and branding"]
  node_mobile["Mobile client<br/>[MainActivity.kt]"]
end

subgraph group_api["API and business services"]
  node_apiapp["FastAPI application<br/>[main.py]"]
  node_auth["Authentication and access<br/>[auth_service.py]"]
  node_reportservice["Report generation"]
  node_business["Business services and calculations"]
end

subgraph group_data["Persistence and messaging"]
  node_models["ERP domain models<br/>[cliente.py]"]
  node_database[("Tenant database connections<br/>[connection.py]")]
  node_messaging["Messaging and events"]
end

subgraph group_migration["Legacy migration"]
  node_etlrunner["Migration orchestrator<br/>[main.py]"]
  node_etlconfig["Legacy and dump configuration<br/>[config.py]"]
  node_etldb["Migration database access<br/>[db.py]"]
  node_etlcustomers["Customer migration phase<br/>[migrar_clientes.py]"]
end

node_operator(("ERP user"))

node_operator -.->|"uses"| node_webapp
node_webapp -.->|"routes to"| node_thirdparties
node_webapp -.->|"routes to"| node_inventory
node_webapp -.->|"routes to"| node_purchasing
node_webapp -.->|"routes to"| node_sales
node_webapp -.->|"routes to"| node_projects
node_webapp -.->|"routes to"| node_hr
node_webapp -.->|"routes to"| node_reports
node_webapp -.->|"routes to"| node_admin
node_thirdparties -.->|"requests API"| node_apiapp
node_inventory -.->|"requests API"| node_apiapp
node_purchasing -.->|"requests API"| node_apiapp
node_sales -.->|"requests API"| node_apiapp
node_projects -.->|"requests API"| node_apiapp
node_hr -.->|"requests API"| node_apiapp
node_reports -.->|"requests API"| node_apiapp
node_admin -.->|"requests API"| node_apiapp
node_apiapp -->|"imports"| node_auth
node_apiapp -->|"sets database context"| node_database
node_apiapp -->|"routes reports"| node_reportservice
node_reportservice -.->|"reads data"| node_database
node_business -.->|"uses domain records"| node_models
node_models -.->|"persisted in"| node_database
node_mobile -.->|"connects to API"| node_apiapp
node_etlrunner -->|"checks dump config"| node_etlconfig
node_etlrunner -->|"uses database access"| node_etldb
node_etlrunner -->|"runs migration phase"| node_etlcustomers

click node_webapp "https://github.com/alexpoool/caguayo/blob/master/frontend/src/App.tsx"
click node_thirdparties "https://github.com/alexpoool/caguayo/blob/master/frontend/src/features/terceros/application/casos-uso.ts"
click node_inventory "https://github.com/alexpoool/caguayo/tree/master/frontend/src/features/inventario"
click node_purchasing "https://github.com/alexpoool/caguayo/tree/master/frontend/src/features/compra"
click node_sales "https://github.com/alexpoool/caguayo/tree/master/frontend/src/features/ventas"
click node_projects "https://github.com/alexpoool/caguayo/tree/master/frontend/src/features/proyectos"
click node_hr "https://github.com/alexpoool/caguayo/tree/master/frontend/src/features/rrhh"
click node_reports "https://github.com/alexpoool/caguayo/tree/master/frontend/src/features/reportes"
click node_admin "https://github.com/alexpoool/caguayo/tree/master/frontend/src/features/administracion"
click node_apiapp "https://github.com/alexpoool/caguayo/blob/master/backend/main.py"
click node_auth "https://github.com/alexpoool/caguayo/blob/master/backend/src/services/auth_service.py"
click node_reportservice "https://github.com/alexpoool/caguayo/blob/master/backend/src/services/reportes_service.py"
click node_business "https://github.com/alexpoool/caguayo/tree/master/backend/src/services"
click node_models "https://github.com/alexpoool/caguayo/blob/master/backend/src/models/cliente.py"
click node_database "https://github.com/alexpoool/caguayo/blob/master/backend/src/database/connection.py"
click node_messaging "https://github.com/alexpoool/caguayo/tree/master/backend/src/messaging"
click node_mobile "https://github.com/alexpoool/caguayo/blob/master/mobile/app/src/main/kotlin/com/itemli/mobile/MainActivity.kt"
click node_etlrunner "https://github.com/alexpoool/caguayo/blob/master/etl/main.py"
click node_etlconfig "https://github.com/alexpoool/caguayo/blob/master/etl/config.py"
click node_etldb "https://github.com/alexpoool/caguayo/blob/master/etl/db.py"
click node_etlcustomers "https://github.com/alexpoool/caguayo/blob/master/etl/migrar_clientes.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_webapp,node_thirdparties,node_inventory,node_purchasing,node_sales,node_projects,node_hr,node_reports,node_admin,node_mobile,node_operator toneBlue
class node_apiapp,node_auth,node_reportservice,node_business toneAmber
class node_models,node_database,node_messaging toneMint
class node_etlrunner,node_etlconfig,node_etldb,node_etlcustomers toneRose
```

## Components

### Web application

- [Web app and routing](https://github.com/alexpoool/caguayo/blob/master/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Clients and accounts](https://github.com/alexpoool/caguayo/blob/master/frontend/src/features/terceros/application/casos-uso.ts): `frontend/src/features/terceros/application/casos-uso.ts`
- [Inventory](https://github.com/alexpoool/caguayo/tree/master/frontend/src/features/inventario): `frontend/src/features/inventario`
- [Purchasing](https://github.com/alexpoool/caguayo/tree/master/frontend/src/features/compra): `frontend/src/features/compra`
- [Sales](https://github.com/alexpoool/caguayo/tree/master/frontend/src/features/ventas): `frontend/src/features/ventas`
- [Projects and services](https://github.com/alexpoool/caguayo/tree/master/frontend/src/features/proyectos): `frontend/src/features/proyectos`
- [Human resources](https://github.com/alexpoool/caguayo/tree/master/frontend/src/features/rrhh): `frontend/src/features/rrhh`
- [Reports and dashboard](https://github.com/alexpoool/caguayo/tree/master/frontend/src/features/reportes): `frontend/src/features/reportes`
- [Administration and branding](https://github.com/alexpoool/caguayo/tree/master/frontend/src/features/administracion): `frontend/src/features/administracion`
- [Mobile client](https://github.com/alexpoool/caguayo/blob/master/mobile/app/src/main/kotlin/com/itemli/mobile/MainActivity.kt): `mobile/app/src/main/kotlin/com/itemli/mobile/MainActivity.kt`

### API and business services

- [FastAPI application](https://github.com/alexpoool/caguayo/blob/master/backend/main.py): `backend/main.py`
- [Authentication and access](https://github.com/alexpoool/caguayo/blob/master/backend/src/services/auth_service.py): `backend/src/services/auth_service.py`
- [Report generation](https://github.com/alexpoool/caguayo/blob/master/backend/src/services/reportes_service.py): `backend/src/services/reportes_service.py`
- [Business services and calculations](https://github.com/alexpoool/caguayo/tree/master/backend/src/services): `backend/src/services`

### Persistence and messaging

- [ERP domain models](https://github.com/alexpoool/caguayo/blob/master/backend/src/models/cliente.py): `backend/src/models/cliente.py`
- [Tenant database connections](https://github.com/alexpoool/caguayo/blob/master/backend/src/database/connection.py): `backend/src/database/connection.py`
- [Messaging and events](https://github.com/alexpoool/caguayo/tree/master/backend/src/messaging): `backend/src/messaging`

### Legacy migration

- [Migration orchestrator](https://github.com/alexpoool/caguayo/blob/master/etl/main.py): `etl/main.py`
- [Legacy and dump configuration](https://github.com/alexpoool/caguayo/blob/master/etl/config.py): `etl/config.py`
- [Migration database access](https://github.com/alexpoool/caguayo/blob/master/etl/db.py): `etl/db.py`
- [Customer migration phase](https://github.com/alexpoool/caguayo/blob/master/etl/migrar_clientes.py): `etl/migrar_clientes.py`

### Other components

- **ERP user**

## Connections

- ERP user → Web app and routing: uses
- Web app and routing → Clients and accounts: routes to
- Web app and routing → Inventory: routes to
- Web app and routing → Purchasing: routes to
- Web app and routing → Sales: routes to
- Web app and routing → Projects and services: routes to
- Web app and routing → Human resources: routes to
- Web app and routing → Reports and dashboard: routes to
- Web app and routing → Administration and branding: routes to
- Clients and accounts → FastAPI application: requests API
- Inventory → FastAPI application: requests API
- Purchasing → FastAPI application: requests API
- Sales → FastAPI application: requests API
- Projects and services → FastAPI application: requests API
- Human resources → FastAPI application: requests API
- Reports and dashboard → FastAPI application: requests API
- Administration and branding → FastAPI application: requests API
- FastAPI application → Authentication and access: imports (evidence: `backend/main.py`)
- FastAPI application → Tenant database connections: sets database context (evidence: `backend/main.py`)
- FastAPI application → Report generation: routes reports
- Report generation → Tenant database connections: reads data
- Business services and calculations → ERP domain models: uses domain records (evidence: `backend/src/services/servicio_service.py`)
- ERP domain models → Tenant database connections: persisted in
- Mobile client → FastAPI application: connects to API
- Migration orchestrator → Legacy and dump configuration: checks dump config (evidence: `etl/main.py`)
- Migration orchestrator → Migration database access: uses database access (evidence: `etl/main.py`)
- Migration orchestrator → Customer migration phase: runs migration phase (evidence: `etl/main.py`)
