# renan-crs/printgest-erp architecture

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

- Interactive diagram: https://gitdiagram.com/renan-crs/printgest-erp
- Repository: https://github.com/renan-crs/printgest-erp

## Overview

PrintGest is a desktop ERP for print shops backed by a FastAPI service and PostgreSQL. The primary workflow runs from desktop sign-in and license checks into business screens, whose API client sends requests to the backend for domain operations and persistence. The graph preserves the README’s major business capabilities, plus licensing, fiscal integration, and multi-branch synchronization. Some domain modules were not sampled; their capabilities are documented, but uncertain implementation links are omitted. Based on the excerpts and SOURCE INDEX, not a full source review.

Main entry points: [`backend/app/api`](https://github.com/renan-crs/printgest-erp/tree/main/backend/app/api) (API routes), [`desktop/printgest/core/api.py`](https://github.com/renan-crs/printgest-erp/blob/main/desktop/printgest/core/api.py) (API client), [`desktop/printgest/ui/tela_principal.py`](https://github.com/renan-crs/printgest-erp/blob/main/desktop/printgest/ui/tela_principal.py) (ERP workspace), [`backend/app/main.py`](https://github.com/renan-crs/printgest-erp/blob/main/backend/app/main.py) (FastAPI service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop client"]
  node_desktop_app["Desktop startup<br/>[main.py]"]
  node_activation["Activation UI<br/>[ativacao.py]"]
  node_desktop_api["API client<br/>[api.py]"]
  node_workspace["ERP workspace<br/>[tela_principal.py]"]
  node_os_ui["OS and quotes<br/>[os.py]"]
  node_pdv_ui["Counter sales<br/>[venda_balcao.py]"]
  node_business_ui["Business modules"]
end

subgraph group_backend["API and domain"]
  node_api_entry["FastAPI service<br/>[main.py]"]
  node_api_routes["API routes"]
  node_auth["Authentication<br/>[auth_service.py]"]
  node_os_service["Production orders<br/>[os_service.py]"]
  node_sales_service["Sales operations<br/>[venda_service.py]"]
  node_finance_service["Finance operations"]
  node_projects_service["Kanban projects"]
  node_fiscal_service["Fiscal documents<br/>[fiscal_service.py]"]
  node_license_service["License management<br/>[licensa_service.py]"]
end

subgraph group_data["Persistence and sync"]
  node_db[("Database access<br/>[db.py]")]
  node_models["ERP data models"]
  node_tenant_service["Tenant and branches<br/>[tenants.py]"]
  node_sync_service["Branch synchronization<br/>[sync_service.py]"]
end

subgraph group_integrations["External services"]
  node_neon[("Neon PostgreSQL")]
  node_redgest["RedGest licensing"]
  node_fiscal_gateway["Fiscal gateway<br/>[fiscal_gateway.py]"]
end

node_user(("Print-shop user"))

node_user -->|"uses"| node_desktop_app
node_desktop_app -->|"opens"| node_activation
node_desktop_app -->|"creates"| node_desktop_api
node_desktop_app -->|"opens"| node_workspace
node_activation -->|"calls"| node_desktop_api
node_workspace -->|"requests"| node_desktop_api
node_workspace -.->|"navigates to"| node_os_ui
node_workspace -.->|"navigates to"| node_pdv_ui
node_workspace -->|"navigates to"| node_business_ui
node_os_ui -->|"requests"| node_desktop_api
node_pdv_ui -.->|"requests"| node_desktop_api
node_desktop_api -->|"HTTP requests"| node_api_entry
node_api_entry -->|"registers"| node_api_routes
node_api_entry -->|"checks license"| node_license_service
node_api_entry -->|"runs"| node_finance_service
node_api_entry -->|"starts sync"| node_sync_service
node_api_routes -->|"dispatches"| node_auth
node_api_routes -.->|"dispatches"| node_os_service
node_api_routes -.->|"dispatches"| node_sales_service
node_api_routes -.->|"dispatches"| node_projects_service
node_api_routes -.->|"dispatches"| node_fiscal_service
node_os_service -->|"reads and writes"| node_models
node_projects_service -->|"reads and writes"| node_models
node_auth -->|"persists sessions"| node_db
node_auth -->|"resolves users"| node_tenant_service
node_fiscal_service -->|"calls"| node_fiscal_gateway
node_license_service -->|"validates license"| node_redgest
node_finance_service -.->|"reads and writes"| node_db
node_sales_service -.->|"reads and writes"| node_db
node_db -->|"connects"| node_neon
node_sync_service -->|"synchronizes"| node_neon
node_tenant_service -->|"uses tenant data"| node_models

click node_desktop_app "https://github.com/renan-crs/printgest-erp/blob/main/desktop/printgest/main.py"
click node_activation "https://github.com/renan-crs/printgest-erp/blob/main/desktop/printgest/ui/ativacao.py"
click node_desktop_api "https://github.com/renan-crs/printgest-erp/blob/main/desktop/printgest/core/api.py"
click node_workspace "https://github.com/renan-crs/printgest-erp/blob/main/desktop/printgest/ui/tela_principal.py"
click node_os_ui "https://github.com/renan-crs/printgest-erp/blob/main/desktop/printgest/ui/modulos/os.py"
click node_pdv_ui "https://github.com/renan-crs/printgest-erp/blob/main/desktop/printgest/ui/modulos/venda_balcao.py"
click node_business_ui "https://github.com/renan-crs/printgest-erp/tree/main/desktop/printgest/ui/modulos"
click node_api_entry "https://github.com/renan-crs/printgest-erp/blob/main/backend/app/main.py"
click node_api_routes "https://github.com/renan-crs/printgest-erp/tree/main/backend/app/api"
click node_auth "https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/auth_service.py"
click node_os_service "https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/os_service.py"
click node_sales_service "https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/venda_service.py"
click node_finance_service "https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/financeiro_service.py"
click node_projects_service "https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/projetos_service.py"
click node_fiscal_service "https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/fiscal_service.py"
click node_license_service "https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/licensa_service.py"
click node_db "https://github.com/renan-crs/printgest-erp/blob/main/backend/app/db.py"
click node_models "https://github.com/renan-crs/printgest-erp/tree/main/backend/app/models"
click node_tenant_service "https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/tenants.py"
click node_sync_service "https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/sync_service.py"
click node_fiscal_gateway "https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/fiscal_gateway.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_desktop_app,node_activation,node_desktop_api,node_workspace,node_os_ui,node_pdv_ui,node_business_ui,node_user toneBlue
class node_api_entry,node_api_routes,node_auth,node_os_service,node_sales_service,node_finance_service,node_projects_service,node_fiscal_service,node_license_service toneAmber
class node_db,node_models,node_tenant_service,node_sync_service toneMint
class node_neon,node_redgest,node_fiscal_gateway toneRose
```

## Components

### Desktop client

- [Desktop startup](https://github.com/renan-crs/printgest-erp/blob/main/desktop/printgest/main.py): `desktop/printgest/main.py`
- [Activation UI](https://github.com/renan-crs/printgest-erp/blob/main/desktop/printgest/ui/ativacao.py): `desktop/printgest/ui/ativacao.py`
- [API client](https://github.com/renan-crs/printgest-erp/blob/main/desktop/printgest/core/api.py): `desktop/printgest/core/api.py`
- [ERP workspace](https://github.com/renan-crs/printgest-erp/blob/main/desktop/printgest/ui/tela_principal.py): `desktop/printgest/ui/tela_principal.py`
- [OS and quotes](https://github.com/renan-crs/printgest-erp/blob/main/desktop/printgest/ui/modulos/os.py): `desktop/printgest/ui/modulos/os.py`
- [Counter sales](https://github.com/renan-crs/printgest-erp/blob/main/desktop/printgest/ui/modulos/venda_balcao.py): `desktop/printgest/ui/modulos/venda_balcao.py`
- [Business modules](https://github.com/renan-crs/printgest-erp/tree/main/desktop/printgest/ui/modulos): `desktop/printgest/ui/modulos`

### API and domain

- [FastAPI service](https://github.com/renan-crs/printgest-erp/blob/main/backend/app/main.py): `backend/app/main.py`
- [API routes](https://github.com/renan-crs/printgest-erp/tree/main/backend/app/api): `backend/app/api`
- [Authentication](https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/auth_service.py): `backend/app/services/auth_service.py`
- [Production orders](https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/os_service.py): `backend/app/services/os_service.py`
- [Sales operations](https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/venda_service.py): `backend/app/services/venda_service.py`
- [Finance operations](https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/financeiro_service.py): `backend/app/services/financeiro_service.py`
- [Kanban projects](https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/projetos_service.py): `backend/app/services/projetos_service.py`
- [Fiscal documents](https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/fiscal_service.py): `backend/app/services/fiscal_service.py`
- [License management](https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/licensa_service.py): `backend/app/services/licensa_service.py`

### Persistence and sync

- [Database access](https://github.com/renan-crs/printgest-erp/blob/main/backend/app/db.py): `backend/app/db.py`
- [ERP data models](https://github.com/renan-crs/printgest-erp/tree/main/backend/app/models): `backend/app/models`
- [Tenant and branches](https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/tenants.py): `backend/app/services/tenants.py`
- [Branch synchronization](https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/sync_service.py): `backend/app/services/sync_service.py`

### External services

- **Neon PostgreSQL**
- **RedGest licensing**
- [Fiscal gateway](https://github.com/renan-crs/printgest-erp/blob/main/backend/app/services/fiscal_gateway.py): `backend/app/services/fiscal_gateway.py`

### Other components

- **Print-shop user**

## Connections

- Print-shop user → Desktop startup: uses (evidence: `desktop/printgest/main.py`)
- Desktop startup → Activation UI: opens (evidence: `desktop/printgest/main.py`)
- Desktop startup → API client: creates (evidence: `desktop/printgest/main.py`)
- Desktop startup → ERP workspace: opens (evidence: `desktop/printgest/main.py`)
- Activation UI → API client: calls (evidence: `desktop/printgest/ui/ativacao.py`)
- ERP workspace → API client: requests (evidence: `desktop/printgest/ui/tela_principal.py`)
- ERP workspace → OS and quotes: navigates to (evidence: `desktop/printgest/ui/tela_principal.py`)
- ERP workspace → Counter sales: navigates to (evidence: `README.md`)
- ERP workspace → Business modules: navigates to (evidence: `desktop/printgest/ui/tela_principal.py`)
- OS and quotes → API client: requests (evidence: `desktop/printgest/ui/modulos/os.py`)
- Counter sales → API client: requests
- API client → FastAPI service: HTTP requests (evidence: `desktop/printgest/core/api.py`)
- FastAPI service → API routes: registers (evidence: `backend/app/main.py`)
- FastAPI service → License management: checks license (evidence: `backend/app/main.py`)
- FastAPI service → Finance operations: runs (evidence: `backend/app/main.py`)
- FastAPI service → Branch synchronization: starts sync (evidence: `backend/app/main.py`)
- API routes → Authentication: dispatches (evidence: `backend/app/api/auth.py`)
- API routes → Production orders: dispatches
- API routes → Sales operations: dispatches
- API routes → Kanban projects: dispatches
- API routes → Fiscal documents: dispatches
- Production orders → ERP data models: reads and writes (evidence: `backend/app/services/os_service.py`)
- Kanban projects → ERP data models: reads and writes (evidence: `backend/app/services/projetos_service.py`)
- Authentication → Database access: persists sessions (evidence: `backend/app/services/auth_service.py`)
- Authentication → Tenant and branches: resolves users (evidence: `backend/app/services/auth_service.py`)
- Fiscal documents → Fiscal gateway: calls (evidence: `backend/app/services/fiscal_service.py`)
- License management → RedGest licensing: validates license (evidence: `backend/app/services/licensa_service.py`)
- Finance operations → Database access: reads and writes
- Sales operations → Database access: reads and writes
- Database access → Neon PostgreSQL: connects (evidence: `backend/app/db.py`)
- Branch synchronization → Neon PostgreSQL: synchronizes
- Tenant and branches → ERP data models: uses tenant data (evidence: `backend/app/services/tenants.py`)
