# denysrd/pedweb architecture

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

- Interactive diagram: https://gitdiagram.com/denysrd/pedweb
- Repository: https://github.com/denysrd/pedweb

## Overview

PeDWeb is a bakery-management ERP with a React frontend and FastAPI/PostgreSQL backend. Users work through operational areas—purchasing, inventory, recipes, production planning and execution, sales, and finance—alongside administration and reporting. The frontend entry point mounts routing and initializes authentication; the backend registers domain routers. Evidence is uneven: sampled source confirms application wiring, selected service dependencies, and the AI job dispatch, while many domain routes and screens are represented only by the tree or README, so their internal call paths are not inferred.

Main entry points: [`backend/app/main.py`](https://github.com/denysrd/pedweb/blob/main/backend/app/main.py) (FastAPI application), [`frontend/src/App.tsx`](https://github.com/denysrd/pedweb/blob/main/frontend/src/App.tsx) (React application), [`backend/app/modules/ai_agent/agent_routes.py`](https://github.com/denysrd/pedweb/blob/main/backend/app/modules/ai_agent/agent_routes.py) (AI endpoints), [`frontend/src/screens/vendas`](https://github.com/denysrd/pedweb/tree/main/frontend/src/screens/vendas) (Sales screens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["React application<br/>[App.tsx]"]
  node_sales_ui["Sales screens"]
  node_sales_api_client["Sales API client<br/>[vendas.js]"]
end

subgraph group_platform["Backend platform"]
  node_server["FastAPI application<br/>[main.py]"]
  node_database[("SQLAlchemy database<br/>[database.py]")]
  node_auth["Authentication and roles"]
end

subgraph group_operations["Operations"]
  node_purchases["Purchasing and NF-e"]
  node_inventory["Inventory"]
  node_recipes["Recipes"]
  node_planning["Production planning"]
  node_production["Production orders"]
  node_ingredients["Ingredients and costs"]
end

subgraph group_business["Business management"]
  node_sales["Sales and orders"]
  node_finance["Finance"]
  node_suppliers["Suppliers"]
  node_catalog["Catalog and branding"]
  node_settings["Configuration"]
  node_dashboard["Dashboard"]
end

subgraph group_intelligence["AI assistance"]
  node_ai_routes["AI endpoints<br/>[agent_routes.py]"]
  node_job_queue["ARQ job queue<br/>[arq_pool.py]"]
  node_ai_worker["AI worker<br/>[ai_worker.py]"]
  node_ai_service["Recipe suggestions<br/>[agent_service.py]"]
end

node_user(("Bakery staff"))

node_user -->|"uses"| node_app
node_app -.->|"calls API"| node_server
node_app -->|"routes to"| node_sales_ui
node_sales_ui -->|"requests data"| node_sales_api_client
node_server -->|"registers routes"| node_auth
node_server -->|"registers routes"| node_purchases
node_server -->|"registers routes"| node_inventory
node_server -->|"registers routes"| node_recipes
node_server -->|"registers routes"| node_production
node_server -->|"registers routes"| node_sales
node_server -->|"registers routes"| node_finance
node_server -->|"registers routes"| node_suppliers
node_server -->|"registers routes"| node_catalog
node_server -->|"registers routes"| node_ingredients
node_server -->|"registers routes"| node_planning
node_server -->|"registers routes"| node_dashboard
node_server -->|"registers routes"| node_settings
node_ai_routes -->|"enqueues job"| node_job_queue
node_job_queue -.->|"dispatches task"| node_ai_worker
node_ai_worker -->|"runs suggestions"| node_ai_service
node_ai_routes -->|"reads AI key"| node_settings

click node_app "https://github.com/denysrd/pedweb/blob/main/frontend/src/App.tsx"
click node_sales_ui "https://github.com/denysrd/pedweb/tree/main/frontend/src/screens/vendas"
click node_sales_api_client "https://github.com/denysrd/pedweb/blob/main/frontend/src/api/vendas.js"
click node_server "https://github.com/denysrd/pedweb/blob/main/backend/app/main.py"
click node_database "https://github.com/denysrd/pedweb/blob/main/backend/app/core/database.py"
click node_purchases "https://github.com/denysrd/pedweb/tree/main/backend/app/modules/compras"
click node_inventory "https://github.com/denysrd/pedweb/tree/main/backend/app/modules/estoque"
click node_recipes "https://github.com/denysrd/pedweb/tree/main/backend/app/modules/receitas"
click node_planning "https://github.com/denysrd/pedweb/tree/main/backend/app/modules/planejamento"
click node_production "https://github.com/denysrd/pedweb/tree/main/backend/app/modules/producao"
click node_ingredients "https://github.com/denysrd/pedweb/tree/main/backend/app/modules/ingredientes"
click node_sales "https://github.com/denysrd/pedweb/tree/main/backend/app/modules/vendas"
click node_finance "https://github.com/denysrd/pedweb/tree/main/backend/app/modules/financeiro"
click node_suppliers "https://github.com/denysrd/pedweb/tree/main/backend/app/modules/fornecedores"
click node_catalog "https://github.com/denysrd/pedweb/tree/main/backend/app/modules/catalogo"
click node_settings "https://github.com/denysrd/pedweb/tree/main/backend/app/modules/configuracoes"
click node_dashboard "https://github.com/denysrd/pedweb/tree/main/backend/app/modules/dashboard"
click node_auth "https://github.com/denysrd/pedweb/tree/main/backend/app/modules/auth"
click node_ai_routes "https://github.com/denysrd/pedweb/blob/main/backend/app/modules/ai_agent/agent_routes.py"
click node_job_queue "https://github.com/denysrd/pedweb/blob/main/backend/app/core/arq_pool.py"
click node_ai_worker "https://github.com/denysrd/pedweb/blob/main/backend/app/workers/ai_worker.py"
click node_ai_service "https://github.com/denysrd/pedweb/blob/main/backend/app/modules/ai_agent/agent_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_app,node_sales_ui,node_sales_api_client toneBlue
class node_server,node_database,node_auth toneAmber
class node_purchases,node_inventory,node_recipes,node_planning,node_production,node_ingredients toneMint
class node_sales,node_finance,node_suppliers,node_catalog,node_settings,node_dashboard toneRose
class node_ai_routes,node_job_queue,node_ai_worker,node_ai_service,node_user toneIndigo
```

## Components

### Web client

- [React application](https://github.com/denysrd/pedweb/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Sales screens](https://github.com/denysrd/pedweb/tree/main/frontend/src/screens/vendas): `frontend/src/screens/vendas`
- [Sales API client](https://github.com/denysrd/pedweb/blob/main/frontend/src/api/vendas.js): `frontend/src/api/vendas.js`

### Backend platform

- [FastAPI application](https://github.com/denysrd/pedweb/blob/main/backend/app/main.py): `backend/app/main.py`
- [SQLAlchemy database](https://github.com/denysrd/pedweb/blob/main/backend/app/core/database.py): `backend/app/core/database.py`
- [Authentication and roles](https://github.com/denysrd/pedweb/tree/main/backend/app/modules/auth): `backend/app/modules/auth`

### Operations

- [Purchasing and NF-e](https://github.com/denysrd/pedweb/tree/main/backend/app/modules/compras): `backend/app/modules/compras`
- [Inventory](https://github.com/denysrd/pedweb/tree/main/backend/app/modules/estoque): `backend/app/modules/estoque`
- [Recipes](https://github.com/denysrd/pedweb/tree/main/backend/app/modules/receitas): `backend/app/modules/receitas`
- [Production planning](https://github.com/denysrd/pedweb/tree/main/backend/app/modules/planejamento): `backend/app/modules/planejamento`
- [Production orders](https://github.com/denysrd/pedweb/tree/main/backend/app/modules/producao): `backend/app/modules/producao`
- [Ingredients and costs](https://github.com/denysrd/pedweb/tree/main/backend/app/modules/ingredientes): `backend/app/modules/ingredientes`

### Business management

- [Sales and orders](https://github.com/denysrd/pedweb/tree/main/backend/app/modules/vendas): `backend/app/modules/vendas`
- [Finance](https://github.com/denysrd/pedweb/tree/main/backend/app/modules/financeiro): `backend/app/modules/financeiro`
- [Suppliers](https://github.com/denysrd/pedweb/tree/main/backend/app/modules/fornecedores): `backend/app/modules/fornecedores`
- [Catalog and branding](https://github.com/denysrd/pedweb/tree/main/backend/app/modules/catalogo): `backend/app/modules/catalogo`
- [Configuration](https://github.com/denysrd/pedweb/tree/main/backend/app/modules/configuracoes): `backend/app/modules/configuracoes`
- [Dashboard](https://github.com/denysrd/pedweb/tree/main/backend/app/modules/dashboard): `backend/app/modules/dashboard`

### AI assistance

- [AI endpoints](https://github.com/denysrd/pedweb/blob/main/backend/app/modules/ai_agent/agent_routes.py): `backend/app/modules/ai_agent/agent_routes.py`
- [ARQ job queue](https://github.com/denysrd/pedweb/blob/main/backend/app/core/arq_pool.py): `backend/app/core/arq_pool.py`
- [AI worker](https://github.com/denysrd/pedweb/blob/main/backend/app/workers/ai_worker.py): `backend/app/workers/ai_worker.py`
- [Recipe suggestions](https://github.com/denysrd/pedweb/blob/main/backend/app/modules/ai_agent/agent_service.py): `backend/app/modules/ai_agent/agent_service.py`

### Other components

- **Bakery staff**

## Connections

- Bakery staff → React application: uses
- React application → FastAPI application: calls API
- React application → Sales screens: routes to (evidence: `frontend/src/App.tsx`)
- Sales screens → Sales API client: requests data (evidence: `frontend/src/screens/vendas/Clientes.tsx`)
- FastAPI application → Authentication and roles: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Purchasing and NF-e: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Inventory: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Recipes: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Production orders: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Sales and orders: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Finance: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Suppliers: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Catalog and branding: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Ingredients and costs: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Production planning: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Dashboard: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Configuration: registers routes (evidence: `backend/app/main.py`)
- AI endpoints → ARQ job queue: enqueues job (evidence: `backend/app/modules/ai_agent/agent_routes.py`)
- ARQ job queue → AI worker: dispatches task
- AI worker → Recipe suggestions: runs suggestions (evidence: `backend/app/workers/ai_worker.py`)
- AI endpoints → Configuration: reads AI key (evidence: `backend/app/modules/ai_agent/agent_routes.py`)
