# jotapekk/erp architecture

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

- Interactive diagram: https://gitdiagram.com/jotapekk/erp
- Repository: https://github.com/jotapekk/erp

## Overview

This is a small FastAPI ERP for managing products, categories, and suppliers, with a static web interface. A client reaches the application entry point, which exposes health and domain routes and serves static files. The domain workflow covers catalog CRUD, product reference validation, and safeguards against disabling categories or suppliers that still have active products. SQLAlchemy models and a shared database session support persistence. The README is empty, so capabilities are inferred from the sampled routes; unsampled static UI behavior and database configuration details are not assumed.

Main entry points: [`app/database.py`](https://github.com/jotapekk/erp/blob/main/app/database.py) (Database sessions), [`app/main.py`](https://github.com/jotapekk/erp/blob/main/app/main.py) (FastAPI application), [`app/routers/produtos.py`](https://github.com/jotapekk/erp/blob/main/app/routers/produtos.py) (Product API), [`app/routers/categorias.py`](https://github.com/jotapekk/erp/blob/main/app/routers/categorias.py) (Category API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_app["FastAPI application<br/>[main.py]"]
  node_static_ui["Static interface<br/>[index.html]"]
end

subgraph group_catalog["ERP catalog"]
  node_category_routes["Category API<br/>[categorias.py]"]
  node_category_schema["Category schemas<br/>[categoria.py]"]
  node_category_model["Category model<br/>[categoria.py]"]
  node_supplier_routes["Supplier API<br/>[fornecedores.py]"]
  node_supplier_schema["Supplier schemas<br/>[fornecedor.py]"]
  node_supplier_model["Supplier model<br/>[fornecedor.py]"]
  node_product_routes["Product API<br/>[produtos.py]"]
  node_product_schema["Product schemas<br/>[produto.py]"]
  node_product_model["Product model<br/>[produto.py]"]
end

subgraph group_rules["Integrity rules"]
  node_integrity["Integrity checks<br/>[integridade.py]"]
end

subgraph group_storage["Persistence"]
  node_database_layer["Database sessions<br/>[database.py]"]
  node_db_config["Database configuration<br/>[config.py]"]
end

node_client(("Client"))

node_client -->|"requests"| node_app
node_app -->|"registers routes"| node_category_routes
node_app -->|"registers routes"| node_supplier_routes
node_app -->|"registers routes"| node_product_routes
node_app -->|"creates tables"| node_database_layer
node_app -->|"serves files"| node_static_ui
node_category_routes -->|"validates data"| node_category_schema
node_category_routes -->|"queries and updates"| node_category_model
node_category_routes -->|"gets sessions"| node_database_layer
node_category_routes -->|"checks active products"| node_integrity
node_supplier_routes -->|"validates data"| node_supplier_schema
node_supplier_routes -->|"queries and updates"| node_supplier_model
node_supplier_routes -->|"gets sessions"| node_database_layer
node_supplier_routes -->|"checks active products"| node_integrity
node_product_routes -->|"validates data"| node_product_schema
node_product_routes -->|"queries and updates"| node_product_model
node_product_routes -->|"checks category"| node_category_model
node_product_routes -->|"checks supplier"| node_supplier_model
node_product_routes -->|"gets sessions"| node_database_layer
node_integrity -->|"counts active products"| node_product_model
node_category_model -->|"uses ORM base"| node_database_layer
node_supplier_model -->|"uses ORM base"| node_database_layer
node_product_model -->|"uses ORM base"| node_database_layer
node_database_layer -->|"loads URL"| node_db_config

click node_app "https://github.com/jotapekk/erp/blob/main/app/main.py"
click node_static_ui "https://github.com/jotapekk/erp/blob/main/static/index.html"
click node_category_routes "https://github.com/jotapekk/erp/blob/main/app/routers/categorias.py"
click node_category_schema "https://github.com/jotapekk/erp/blob/main/app/schemas/categoria.py"
click node_category_model "https://github.com/jotapekk/erp/blob/main/app/models/categoria.py"
click node_supplier_routes "https://github.com/jotapekk/erp/blob/main/app/routers/fornecedores.py"
click node_supplier_schema "https://github.com/jotapekk/erp/blob/main/app/schemas/fornecedor.py"
click node_supplier_model "https://github.com/jotapekk/erp/blob/main/app/models/fornecedor.py"
click node_product_routes "https://github.com/jotapekk/erp/blob/main/app/routers/produtos.py"
click node_product_schema "https://github.com/jotapekk/erp/blob/main/app/schemas/produto.py"
click node_product_model "https://github.com/jotapekk/erp/blob/main/app/models/produto.py"
click node_integrity "https://github.com/jotapekk/erp/blob/main/app/services/integridade.py"
click node_database_layer "https://github.com/jotapekk/erp/blob/main/app/database.py"
click node_db_config "https://github.com/jotapekk/erp/blob/main/app/config.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_app,node_static_ui,node_client toneBlue
class node_category_routes,node_category_schema,node_category_model,node_supplier_routes,node_supplier_schema,node_supplier_model,node_product_routes,node_product_schema,node_product_model toneAmber
class node_integrity toneMint
class node_database_layer,node_db_config toneRose
```

## Components

### Application entry

- [FastAPI application](https://github.com/jotapekk/erp/blob/main/app/main.py): `app/main.py`
- [Static interface](https://github.com/jotapekk/erp/blob/main/static/index.html): `static/index.html`

### ERP catalog

- [Category API](https://github.com/jotapekk/erp/blob/main/app/routers/categorias.py): `app/routers/categorias.py`
- [Category schemas](https://github.com/jotapekk/erp/blob/main/app/schemas/categoria.py): `app/schemas/categoria.py`
- [Category model](https://github.com/jotapekk/erp/blob/main/app/models/categoria.py): `app/models/categoria.py`
- [Supplier API](https://github.com/jotapekk/erp/blob/main/app/routers/fornecedores.py): `app/routers/fornecedores.py`
- [Supplier schemas](https://github.com/jotapekk/erp/blob/main/app/schemas/fornecedor.py): `app/schemas/fornecedor.py`
- [Supplier model](https://github.com/jotapekk/erp/blob/main/app/models/fornecedor.py): `app/models/fornecedor.py`
- [Product API](https://github.com/jotapekk/erp/blob/main/app/routers/produtos.py): `app/routers/produtos.py`
- [Product schemas](https://github.com/jotapekk/erp/blob/main/app/schemas/produto.py): `app/schemas/produto.py`
- [Product model](https://github.com/jotapekk/erp/blob/main/app/models/produto.py): `app/models/produto.py`

### Integrity rules

- [Integrity checks](https://github.com/jotapekk/erp/blob/main/app/services/integridade.py): `app/services/integridade.py`

### Persistence

- [Database sessions](https://github.com/jotapekk/erp/blob/main/app/database.py): `app/database.py`
- [Database configuration](https://github.com/jotapekk/erp/blob/main/app/config.py): `app/config.py`

### Other components

- **Client**

## Connections

- Client → FastAPI application: requests (evidence: `app/main.py`)
- FastAPI application → Category API: registers routes (evidence: `app/main.py`)
- FastAPI application → Supplier API: registers routes (evidence: `app/main.py`)
- FastAPI application → Product API: registers routes (evidence: `app/main.py`)
- FastAPI application → Database sessions: creates tables (evidence: `app/main.py`)
- FastAPI application → Static interface: serves files (evidence: `app/main.py`)
- Category API → Category schemas: validates data (evidence: `app/routers/categorias.py`)
- Category API → Category model: queries and updates (evidence: `app/routers/categorias.py`)
- Category API → Database sessions: gets sessions (evidence: `app/routers/categorias.py`)
- Category API → Integrity checks: checks active products (evidence: `app/routers/categorias.py`)
- Supplier API → Supplier schemas: validates data (evidence: `app/routers/fornecedores.py`)
- Supplier API → Supplier model: queries and updates (evidence: `app/routers/fornecedores.py`)
- Supplier API → Database sessions: gets sessions (evidence: `app/routers/fornecedores.py`)
- Supplier API → Integrity checks: checks active products (evidence: `app/routers/fornecedores.py`)
- Product API → Product schemas: validates data (evidence: `app/routers/produtos.py`)
- Product API → Product model: queries and updates (evidence: `app/routers/produtos.py`)
- Product API → Category model: checks category (evidence: `app/routers/produtos.py`)
- Product API → Supplier model: checks supplier (evidence: `app/routers/produtos.py`)
- Product API → Database sessions: gets sessions (evidence: `app/routers/produtos.py`)
- Integrity checks → Product model: counts active products (evidence: `app/services/integridade.py`)
- Category model → Database sessions: uses ORM base (evidence: `app/models/categoria.py`)
- Supplier model → Database sessions: uses ORM base (evidence: `app/models/fornecedor.py`)
- Product model → Database sessions: uses ORM base (evidence: `app/models/produto.py`)
- Database sessions → Database configuration: loads URL (evidence: `app/database.py`)
