# marcelocperi/erp_colosal_quart architecture

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

- Interactive diagram: https://gitdiagram.com/marcelocperi/erp_colosal_quart
- Repository: https://github.com/marcelocperi/erp_colosal_quart

## Overview

#### Purpose and entry points
Colosal is a Python ERP/backoffice system spanning sales, purchasing, inventory, treasury, accounting, production, logistics, library, and external customer/supplier portals. The main web application is likely assembled in `app.py`, with WSGI deployment support in `wsgi.py`. A separate mobile/collection application is exposed through `recoleccion_app.py`; async/ASGI-oriented launch paths are present in `run_hypercorn.py`.

#### Application composition
The system is organized as domain route modules that render server-side templates and invoke shared services. Core application governance, authentication, authorization, enterprise administration, and cross-cutting routes reside in `core/routes.py`, `core/decorators.py`, and `core/enterprise_admin.py`. Blueprint-oriented assembly appears centralized in `core/blueprint_factory.py`, creating a boundary between application bootstrapping and domain modules.

#### Commercial and operational flows
Sales handles customers, quotations/budgets, orders, invoicing, returns, and customer account views through `ventas/routes.py` and `ventas/presupuesto_service.py`. Purchasing covers suppliers, sourcing/RFQ, purchase orders, receiving, importation, and subcontracting through `compras/routes.py`, `compras/rfq_routes.py`, and `compras/importaciones_routes.py`. These flows converge on shared order, receiving, quotation, and ERP master-data services such as `services/order_service.py`, `services/receiving_service.py`, and `services/erp_master_service.py`.

#### Inventory, logistics, and production
Inventory is a first-class operational subsystem for articles, warehouses, movements, transfers, serials, labels, and stock-taking, exposed from `stock/routes.py`; enrichment is separated into a processing pipeline under `stock/enrichment/processor.py` and strategy implementations in `stock/enrichment/strategies.py`. Field/mobile collection functions are isolated in `recoleccion/routes.py`. Production supports projects, engineering, BIM assets, document management, and costing through `produccion/routes.py` and `services/industrial_costing_service.py`.

#### Finance, accounting, and fiscal compliance
Treasury/cash, bank reconciliation, receipts, payment media, and tax configuration are exposed by `fondos/routes.py` and supported by `services/finance_service.py`, `services/receipt_service.py`, and `services/cash_session_service.py`. Accounting is divided into focused route areas—management, configuration, reporting, and audit—under `contabilidad/routes/gestion.py`, `contabilidad/routes/reportes.py`, and `contabilidad/routes/auditoria.py`. Fiscal integration and tax computation are service boundaries in `services/afip_service.py`, `services/tax_engine.py`, and `services/iibb_service.py`.

#### Security, multi-enterprise control, and audit
The system appears multi-enterprise/SaaS-aware, with enterprise models in `models/enterprise.py`, initialization in `services/enterprise_init.py`, and enterprise administrative controls in `core/enterprise_admin.py`. Role/permission enforcement and segregation-of-duties logic are explicit architectural concerns via `services/sod_service.py`, `core/safety_logic.py`, and `services/audit_certification_service.py`. Authentication sessions and security utilities are separated into `services/session_service.py` and `core/security_utils.py`.

#### Persistence, integrations, and operations
Persistence is database-centric, with shared access foundations in `database.py`, generated/domain models in `models/auto_models.py`, and repository abstraction in `repositories/base_repository.py`. The repository contains extensive schema evolution assets under `migrations/`, including portal buffering and tax/AFIP-related tables. External boundaries include AFIP fiscal services, BCRA data, georeferencing, email/WhatsApp, barcode/printing, vessel tracking, and AI chat, represented by `services/afip_service.py`, `services/bcra_service.py`, and `services/ai_chat_routes.py`. MariaDB is strongly indicated by migration and diagnostic naming, while Windows/Linux service installers support deployed operation.

Main entry points: [`core/blueprint_factory.py`](https://github.com/marcelocperi/erp_colosal_quart/blob/main/core/blueprint_factory.py) (Blueprint Factory), [`database.py`](https://github.com/marcelocperi/erp_colosal_quart/blob/main/database.py) (Persistence Layer), [`services/order_service.py`](https://github.com/marcelocperi/erp_colosal_quart/blob/main/services/order_service.py) (Order & Receiving Services), [`stock/routes.py`](https://github.com/marcelocperi/erp_colosal_quart/blob/main/stock/routes.py) (Inventory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application Entry"]
  node_web_app["Web Application<br/>Flask assembly<br/>[app.py]"]
  node_wsgi["WSGI Deployment<br/>WSGI entry<br/>[wsgi.py]"]
  node_hypercorn["ASGI Launch<br/>async launcher<br/>[run_hypercorn.py]"]
  node_mobile_app["Collection App<br/>mobile entry<br/>[recoleccion_app.py]"]
end

subgraph group_domains["Domain Modules"]
  node_sales["Sales<br/>domain routes<br/>[routes.py]"]
  node_purchasing["Purchasing<br/>domain routes<br/>[routes.py]"]
  node_inventory["Inventory<br/>domain routes<br/>[routes.py]"]
  node_enrichment["Stock Enrichment<br/>processing pipeline<br/>[processor.py]"]
  node_field_collection["Field Collection<br/>mobile routes<br/>[routes.py]"]
  node_production["Production<br/>domain routes<br/>[routes.py]"]
end

subgraph group_shared["Shared Services &amp; Control"]
  node_blueprints["Blueprint Factory<br/>application composition"]
  node_core_control["Core Governance<br/>auth and authorization<br/>[routes.py]"]
  node_operations["Order &amp; Receiving Services<br/>ERP workflow services<br/>[order_service.py]"]
  node_enterprise_security["Enterprise Security<br/>multi-tenant control<br/>[enterprise_init.py]"]
end

subgraph group_finance["Finance &amp; Compliance"]
  node_treasury["Treasury<br/>domain routes<br/>[routes.py]"]
  node_accounting["Accounting<br/>domain routes<br/>[gestion.py]"]
  node_fiscal["Fiscal &amp; Tax Services<br/>compliance services<br/>[afip_service.py]"]
end

subgraph group_data["Data &amp; External Systems"]
  node_persistence[("Persistence Layer<br/>database access<br/>[database.py]")]
  node_models["Domain Models<br/>generated models<br/>[auto_models.py]"]
  node_migrations["Schema Migrations<br/>schema evolution"]
  node_external{{"External Integrations<br/>service adapters<br/>[bcra_service.py]"}}
end

node_wsgi -->|"serves"| node_web_app
node_hypercorn -->|"launches"| node_web_app
node_web_app -->|"composes"| node_blueprints
node_mobile_app -->|"exposes"| node_field_collection
node_blueprints -->|"registers"| node_core_control
node_blueprints -->|"registers"| node_sales
node_blueprints -->|"registers"| node_purchasing
node_blueprints -->|"registers"| node_inventory
node_blueprints -->|"registers"| node_production
node_blueprints -->|"registers"| node_treasury
node_blueprints -->|"registers"| node_accounting
node_core_control -->|"enforces"| node_enterprise_security
node_sales -->|"uses"| node_operations
node_purchasing -->|"uses"| node_operations
node_inventory -->|"enriches stock through"| node_enrichment
node_production -.->|"uses ERP workflows"| node_operations
node_treasury -->|"calculates and reports taxes"| node_fiscal
node_accounting -->|"uses compliance services"| node_fiscal
node_fiscal -->|"integrates with AFIP"| node_external
node_enterprise_security -->|"stores enterprise controls"| node_persistence
node_operations -->|"persists workflows"| node_persistence
node_inventory -->|"persists stock"| node_persistence
node_treasury -->|"persists financial records"| node_persistence
node_accounting -->|"persists ledger data"| node_persistence
node_persistence -->|"maps"| node_models
node_migrations -.->|"evolves schema"| node_persistence

click node_web_app "https://github.com/marcelocperi/erp_colosal_quart/blob/main/app.py"
click node_wsgi "https://github.com/marcelocperi/erp_colosal_quart/blob/main/wsgi.py"
click node_hypercorn "https://github.com/marcelocperi/erp_colosal_quart/blob/main/run_hypercorn.py"
click node_mobile_app "https://github.com/marcelocperi/erp_colosal_quart/blob/main/recoleccion_app.py"
click node_blueprints "https://github.com/marcelocperi/erp_colosal_quart/blob/main/core/blueprint_factory.py"
click node_core_control "https://github.com/marcelocperi/erp_colosal_quart/blob/main/core/routes.py"
click node_sales "https://github.com/marcelocperi/erp_colosal_quart/blob/main/ventas/routes.py"
click node_purchasing "https://github.com/marcelocperi/erp_colosal_quart/blob/main/compras/routes.py"
click node_operations "https://github.com/marcelocperi/erp_colosal_quart/blob/main/services/order_service.py"
click node_inventory "https://github.com/marcelocperi/erp_colosal_quart/blob/main/stock/routes.py"
click node_enrichment "https://github.com/marcelocperi/erp_colosal_quart/blob/main/stock/enrichment/processor.py"
click node_field_collection "https://github.com/marcelocperi/erp_colosal_quart/blob/main/recoleccion/routes.py"
click node_production "https://github.com/marcelocperi/erp_colosal_quart/blob/main/produccion/routes.py"
click node_treasury "https://github.com/marcelocperi/erp_colosal_quart/blob/main/fondos/routes.py"
click node_accounting "https://github.com/marcelocperi/erp_colosal_quart/blob/main/contabilidad/routes/gestion.py"
click node_fiscal "https://github.com/marcelocperi/erp_colosal_quart/blob/main/services/afip_service.py"
click node_enterprise_security "https://github.com/marcelocperi/erp_colosal_quart/blob/main/services/enterprise_init.py"
click node_persistence "https://github.com/marcelocperi/erp_colosal_quart/blob/main/database.py"
click node_models "https://github.com/marcelocperi/erp_colosal_quart/blob/main/models/auto_models.py"
click node_external "https://github.com/marcelocperi/erp_colosal_quart/blob/main/services/bcra_service.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_wsgi,node_hypercorn,node_mobile_app toneBlue
class node_sales,node_purchasing,node_inventory,node_enrichment,node_field_collection,node_production toneAmber
class node_blueprints,node_core_control,node_operations,node_enterprise_security toneMint
class node_treasury,node_accounting,node_fiscal toneRose
class node_persistence,node_models,node_migrations,node_external toneIndigo
```

## Components

### Application Entry

- [Web Application](https://github.com/marcelocperi/erp_colosal_quart/blob/main/app.py): Flask assembly · Primary server-rendered ERP application. · `app.py`
- [WSGI Deployment](https://github.com/marcelocperi/erp_colosal_quart/blob/main/wsgi.py): WSGI entry · `wsgi.py`
- [ASGI Launch](https://github.com/marcelocperi/erp_colosal_quart/blob/main/run_hypercorn.py): async launcher · `run_hypercorn.py`
- [Collection App](https://github.com/marcelocperi/erp_colosal_quart/blob/main/recoleccion_app.py): mobile entry · `recoleccion_app.py`

### Domain Modules

- [Sales](https://github.com/marcelocperi/erp_colosal_quart/blob/main/ventas/routes.py): domain routes · Customers, quotations, orders, invoicing, and returns. · `ventas/routes.py`
- [Purchasing](https://github.com/marcelocperi/erp_colosal_quart/blob/main/compras/routes.py): domain routes · Supplier sourcing, purchase orders, receiving, and imports. · `compras/routes.py`
- [Inventory](https://github.com/marcelocperi/erp_colosal_quart/blob/main/stock/routes.py): domain routes · Articles, warehouses, stock movements, transfers, and counts. · `stock/routes.py`
- [Stock Enrichment](https://github.com/marcelocperi/erp_colosal_quart/blob/main/stock/enrichment/processor.py): processing pipeline · Processes inventory enrichment through strategies. · `stock/enrichment/processor.py`
- [Field Collection](https://github.com/marcelocperi/erp_colosal_quart/blob/main/recoleccion/routes.py): mobile routes · `recoleccion/routes.py`
- [Production](https://github.com/marcelocperi/erp_colosal_quart/blob/main/produccion/routes.py): domain routes · Projects, engineering, BIM, documents, and costing. · `produccion/routes.py`

### Shared Services & Control

- [Blueprint Factory](https://github.com/marcelocperi/erp_colosal_quart/blob/main/core/blueprint_factory.py): application composition · Registers domain route modules. · `core/blueprint_factory.py`
- [Core Governance](https://github.com/marcelocperi/erp_colosal_quart/blob/main/core/routes.py): auth and authorization · Shared routes, decorators, and enterprise administration. · `core/routes.py`
- [Order & Receiving Services](https://github.com/marcelocperi/erp_colosal_quart/blob/main/services/order_service.py): ERP workflow services · `services/order_service.py`
- [Enterprise Security](https://github.com/marcelocperi/erp_colosal_quart/blob/main/services/enterprise_init.py): multi-tenant control · Enterprise initialization, sessions, segregation of duties, and audit certification. · `services/enterprise_init.py`

### Finance & Compliance

- [Treasury](https://github.com/marcelocperi/erp_colosal_quart/blob/main/fondos/routes.py): domain routes · Cash, banks, receipts, payment media, and taxes. · `fondos/routes.py`
- [Accounting](https://github.com/marcelocperi/erp_colosal_quart/blob/main/contabilidad/routes/gestion.py): domain routes · Management, reporting, configuration, and audit areas. · `contabilidad/routes/gestion.py`
- [Fiscal & Tax Services](https://github.com/marcelocperi/erp_colosal_quart/blob/main/services/afip_service.py): compliance services · AFIP integration and tax computation boundary. · `services/afip_service.py`

### Data & External Systems

- [Persistence Layer](https://github.com/marcelocperi/erp_colosal_quart/blob/main/database.py): database access · Shared database access, models, and repository abstraction. · `database.py`
- [Domain Models](https://github.com/marcelocperi/erp_colosal_quart/blob/main/models/auto_models.py): generated models · `models/auto_models.py`
- **Schema Migrations**: schema evolution · Includes portal and fiscal schema changes.
- [External Integrations](https://github.com/marcelocperi/erp_colosal_quart/blob/main/services/bcra_service.py): service adapters · Fiscal, banking, messaging, geospatial, printing, tracking, and AI boundaries. · `services/bcra_service.py`

## Connections

- WSGI Deployment → Web Application: serves
- ASGI Launch → Web Application: launches
- Web Application → Blueprint Factory: composes
- Collection App → Field Collection: exposes
- Blueprint Factory → Core Governance: registers
- Blueprint Factory → Sales: registers
- Blueprint Factory → Purchasing: registers
- Blueprint Factory → Inventory: registers
- Blueprint Factory → Production: registers
- Blueprint Factory → Treasury: registers
- Blueprint Factory → Accounting: registers
- Core Governance → Enterprise Security: enforces
- Sales → Order & Receiving Services: uses
- Purchasing → Order & Receiving Services: uses
- Inventory → Stock Enrichment: enriches stock through
- Production → Order & Receiving Services: uses ERP workflows
- Treasury → Fiscal & Tax Services: calculates and reports taxes
- Accounting → Fiscal & Tax Services: uses compliance services
- Fiscal & Tax Services → External Integrations: integrates with AFIP
- Enterprise Security → Persistence Layer: stores enterprise controls
- Order & Receiving Services → Persistence Layer: persists workflows
- Inventory → Persistence Layer: persists stock
- Treasury → Persistence Layer: persists financial records
- Accounting → Persistence Layer: persists ledger data
- Persistence Layer → Domain Models: maps
- Schema Migrations → Persistence Layer: evolves schema
