# william-bruno/oficina_mecanica architecture

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

- Interactive diagram: https://gitdiagram.com/william-bruno/oficina_mecanica
- Repository: https://github.com/william-bruno/oficina_mecanica

## Overview

This is a FastAPI system for managing a mechanical workshop. Its principal workflow is opening a service order for a vehicle, recording diagnosis, assembling and approving service/part items, tracking execution and status, then recording payments. Separate capabilities cover customer, vehicle, mechanic and catalog management, plus reports and statistics. The README documents these product areas; source excerpts and the index show selected wiring, so uncertain runtime connections are omitted rather than inferred.

Main entry points: [`app/main.py`](https://github.com/william-bruno/oficina_mecanica/blob/main/app/main.py) (Application setup), [`app/repository`](https://github.com/william-bruno/oficina_mecanica/tree/main/app/repository) (Data repositories), [`app/services/ordem_servico_service.py`](https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/ordem_servico_service.py) (Order rules), [`app/services/item_servico_service.py`](https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/item_servico_service.py) (Service-item handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_app["Application setup<br/>[main.py]"]
  node_order_route["Service-order routes<br/>[ordem_servico.py]"]
  node_diag_route["Diagnosis routes<br/>[diagnostico.py]"]
  node_item_service_route["Service-item routes<br/>[item_servico.py]"]
  node_item_part_route["Part-item routes<br/>[item_peca.py]"]
  node_payment_route["Payment routes<br/>[pagamento.py]"]
  node_catalog_routes["Registry routes"]
  node_report_routes["Insight routes<br/>[relatorios.py]"]
  node_stats_routes["Statistics routes<br/>[estatisticas.py]"]
end

subgraph group_operations["Workshop operations"]
  node_order_service["Order rules"]
  node_diagnosis_service["Diagnosis handling"]
  node_service_item["Service-item handling"]
  node_part_item["Part-item handling"]
  node_payment_service["Payment handling"]
  node_models["Workshop entities"]
end

subgraph group_registry["People and catalogs"]
  node_registry_services["Registry services"]
end

subgraph group_data["Persistence and insights"]
  node_repositories["Data repositories"]
  node_database[("SQL database<br/>[database.py]")]
  node_reports["Report handling"]
  node_statistics["Statistics handling"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_app -->|"registers"| node_order_route
node_app -->|"registers"| node_diag_route
node_app -->|"registers"| node_item_service_route
node_app -->|"registers"| node_item_part_route
node_app -->|"registers"| node_payment_route
node_app -->|"registers"| node_catalog_routes
node_app -->|"registers"| node_report_routes
node_app -->|"registers"| node_stats_routes
node_order_route -.->|"delegates"| node_order_service
node_diag_route -.->|"delegates"| node_diagnosis_service
node_item_service_route -.->|"delegates"| node_service_item
node_item_part_route -.->|"delegates"| node_part_item
node_payment_route -.->|"delegates"| node_payment_service
node_order_service -.->|"queries and saves"| node_repositories
node_diagnosis_service -.->|"uses repositories"| node_repositories
node_service_item -.->|"uses repositories"| node_repositories
node_part_item -.->|"uses repositories"| node_repositories
node_payment_service -.->|"uses repositories"| node_repositories
node_repositories -.->|"uses sessions"| node_database
node_order_service -->|"validates order state"| node_models
node_service_item -->|"recalculates order"| node_order_service
node_part_item -->|"recalculates order"| node_order_service
node_report_routes -.->|"delegates"| node_reports
node_stats_routes -.->|"delegates"| node_statistics
node_registry_services -.->|"uses repositories"| node_repositories

click node_app "https://github.com/william-bruno/oficina_mecanica/blob/main/app/main.py"
click node_order_route "https://github.com/william-bruno/oficina_mecanica/blob/main/app/routes/ordem_servico.py"
click node_diag_route "https://github.com/william-bruno/oficina_mecanica/blob/main/app/routes/diagnostico.py"
click node_item_service_route "https://github.com/william-bruno/oficina_mecanica/blob/main/app/routes/item_servico.py"
click node_item_part_route "https://github.com/william-bruno/oficina_mecanica/blob/main/app/routes/item_peca.py"
click node_payment_route "https://github.com/william-bruno/oficina_mecanica/blob/main/app/routes/pagamento.py"
click node_catalog_routes "https://github.com/william-bruno/oficina_mecanica/tree/main/app/routes"
click node_report_routes "https://github.com/william-bruno/oficina_mecanica/blob/main/app/routes/relatorios.py"
click node_stats_routes "https://github.com/william-bruno/oficina_mecanica/blob/main/app/routes/estatisticas.py"
click node_order_service "https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/ordem_servico_service.py"
click node_diagnosis_service "https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/diagnostico_service.py"
click node_service_item "https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/item_servico_service.py"
click node_part_item "https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/item_peca_service.py"
click node_payment_service "https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/pagamento_service.py"
click node_registry_services "https://github.com/william-bruno/oficina_mecanica/tree/main/app/services"
click node_models "https://github.com/william-bruno/oficina_mecanica/tree/main/app/models"
click node_repositories "https://github.com/william-bruno/oficina_mecanica/tree/main/app/repository"
click node_database "https://github.com/william-bruno/oficina_mecanica/blob/main/app/core/database.py"
click node_reports "https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/relatorio_service.py"
click node_statistics "https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/estatistica_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_order_route,node_diag_route,node_item_service_route,node_item_part_route,node_payment_route,node_catalog_routes,node_report_routes,node_stats_routes,node_client toneBlue
class node_order_service,node_diagnosis_service,node_service_item,node_part_item,node_payment_service,node_models toneAmber
class node_registry_services toneMint
class node_repositories,node_database,node_reports,node_statistics toneRose
```

## Components

### API entry

- [Application setup](https://github.com/william-bruno/oficina_mecanica/blob/main/app/main.py): `app/main.py`
- [Service-order routes](https://github.com/william-bruno/oficina_mecanica/blob/main/app/routes/ordem_servico.py): `app/routes/ordem_servico.py`
- [Diagnosis routes](https://github.com/william-bruno/oficina_mecanica/blob/main/app/routes/diagnostico.py): `app/routes/diagnostico.py`
- [Service-item routes](https://github.com/william-bruno/oficina_mecanica/blob/main/app/routes/item_servico.py): `app/routes/item_servico.py`
- [Part-item routes](https://github.com/william-bruno/oficina_mecanica/blob/main/app/routes/item_peca.py): `app/routes/item_peca.py`
- [Payment routes](https://github.com/william-bruno/oficina_mecanica/blob/main/app/routes/pagamento.py): `app/routes/pagamento.py`
- [Registry routes](https://github.com/william-bruno/oficina_mecanica/tree/main/app/routes): `app/routes`
- [Insight routes](https://github.com/william-bruno/oficina_mecanica/blob/main/app/routes/relatorios.py): `app/routes/relatorios.py`
- [Statistics routes](https://github.com/william-bruno/oficina_mecanica/blob/main/app/routes/estatisticas.py): `app/routes/estatisticas.py`

### Workshop operations

- [Order rules](https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/ordem_servico_service.py): `app/services/ordem_servico_service.py`
- [Diagnosis handling](https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/diagnostico_service.py): `app/services/diagnostico_service.py`
- [Service-item handling](https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/item_servico_service.py): `app/services/item_servico_service.py`
- [Part-item handling](https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/item_peca_service.py): `app/services/item_peca_service.py`
- [Payment handling](https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/pagamento_service.py): `app/services/pagamento_service.py`
- [Workshop entities](https://github.com/william-bruno/oficina_mecanica/tree/main/app/models): `app/models`

### People and catalogs

- [Registry services](https://github.com/william-bruno/oficina_mecanica/tree/main/app/services): `app/services`

### Persistence and insights

- [Data repositories](https://github.com/william-bruno/oficina_mecanica/tree/main/app/repository): `app/repository`
- [SQL database](https://github.com/william-bruno/oficina_mecanica/blob/main/app/core/database.py): `app/core/database.py`
- [Report handling](https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/relatorio_service.py): `app/services/relatorio_service.py`
- [Statistics handling](https://github.com/william-bruno/oficina_mecanica/blob/main/app/services/estatistica_service.py): `app/services/estatistica_service.py`

### Other components

- **API client**

## Connections

- API client → Application setup: sends requests (evidence: `README.md`)
- Application setup → Service-order routes: registers (evidence: `app/main.py`)
- Application setup → Diagnosis routes: registers (evidence: `app/main.py`)
- Application setup → Service-item routes: registers (evidence: `app/main.py`)
- Application setup → Part-item routes: registers (evidence: `app/main.py`)
- Application setup → Payment routes: registers (evidence: `app/main.py`)
- Application setup → Registry routes: registers (evidence: `app/main.py`)
- Application setup → Insight routes: registers (evidence: `app/main.py`)
- Application setup → Statistics routes: registers (evidence: `app/main.py`)
- Service-order routes → Order rules: delegates (evidence: `app/routes/ordem_servico.py`)
- Diagnosis routes → Diagnosis handling: delegates
- Service-item routes → Service-item handling: delegates (evidence: `app/routes/item_servico.py`)
- Part-item routes → Part-item handling: delegates (evidence: `app/routes/item_peca.py`)
- Payment routes → Payment handling: delegates
- Order rules → Data repositories: queries and saves (evidence: `app/services/ordem_servico_service.py`)
- Diagnosis handling → Data repositories: uses repositories (evidence: `app/services/diagnostico_service.py`)
- Service-item handling → Data repositories: uses repositories (evidence: `app/services/item_servico_service.py`)
- Part-item handling → Data repositories: uses repositories (evidence: `app/services/item_peca_service.py`)
- Payment handling → Data repositories: uses repositories (evidence: `app/services/pagamento_service.py`)
- Data repositories → SQL database: uses sessions
- Order rules → Workshop entities: validates order state (evidence: `app/services/ordem_servico_service.py`)
- Service-item handling → Order rules: recalculates order (evidence: `app/services/item_servico_service.py`)
- Part-item handling → Order rules: recalculates order (evidence: `app/services/item_peca_service.py`)
- Insight routes → Report handling: delegates
- Statistics routes → Statistics handling: delegates
- Registry services → Data repositories: uses repositories (evidence: `app/services/ordem_servico_service.py`)
