# mayrkov/trabalho---03 architecture

> Architecture diagram of the GitHub repository mayrkov/trabalho---03, 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/mayrkov/trabalho---03
- Repository: https://github.com/mayrkov/trabalho---03

## Overview

Pizzaria API is a FastAPI delivery backend for managing customers, menu products, orders, and order items. Clients call the application entry point, which mounts resource routers; each router validates request/response data and performs ORM operations through a database session. The item workflow checks that its order and product exist, computes subtotals, and recalculates the order total. The README documents SQLite and entity cascades; detailed migration behavior is outside this runtime view. Arrows reflect shown router calls and documented API/database relationships.

Main entry points: [`app/core/database.py`](https://github.com/mayrkov/trabalho---03/blob/main/app/core/database.py) (Database sessions), [`app/routers/item_pedido.py`](https://github.com/mayrkov/trabalho---03/blob/main/app/routers/item_pedido.py) (Order item routes), [`app/main.py`](https://github.com/mayrkov/trabalho---03/blob/main/app/main.py) (FastAPI application), [`app/routers/pedido.py`](https://github.com/mayrkov/trabalho---03/blob/main/app/routers/pedido.py) (Order routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry"]
  node_application["FastAPI application<br/>[main.py]"]
end

subgraph group_resources["Resource handlers"]
  node_customers["Customer routes<br/>[cliente.py]"]
  node_products["Product routes<br/>[produto.py]"]
  node_orders["Order routes<br/>[pedido.py]"]
  node_order_items["Order item routes<br/>[item_pedido.py]"]
end

subgraph group_contracts["Data contracts"]
  node_customer_contract["Customer schemas<br/>[cliente.py]"]
  node_product_contract["Product schemas<br/>[produto.py]"]
  node_order_contract["Order schemas<br/>[pedido.py]"]
  node_item_contract["Item schemas<br/>[item_pedido.py]"]
end

subgraph group_persistence["Persistence"]
  node_customer_model["Customer model<br/>[cliente.py]"]
  node_product_model["Product model<br/>[produto.py]"]
  node_order_model["Order model<br/>[pedido.py]"]
  node_item_model["Order item model<br/>[item_pedido.py]"]
  node_db_session["Database sessions<br/>[database.py]"]
end

node_api_client(("API client"))
node_sqlite[("SQLite database")]

node_api_client -->|"sends requests"| node_application
node_application -->|"mounts router"| node_customers
node_application -->|"mounts router"| node_products
node_application -->|"mounts router"| node_orders
node_application -->|"mounts router"| node_order_items
node_customers -->|"validates and serializes"| node_customer_contract
node_products -->|"validates and serializes"| node_product_contract
node_orders -->|"validates and serializes"| node_order_contract
node_order_items -->|"validates and serializes"| node_item_contract
node_customers -->|"queries and changes"| node_customer_model
node_products -->|"queries and changes"| node_product_model
node_orders -->|"queries and changes"| node_order_model
node_orders -->|"checks customer"| node_customer_model
node_order_items -->|"creates and updates"| node_item_model
node_order_items -->|"checks and recalculates"| node_order_model
node_order_items -->|"checks product"| node_product_model
node_customers -->|"gets session"| node_db_session
node_products -->|"gets session"| node_db_session
node_orders -->|"gets session"| node_db_session
node_order_items -->|"gets session"| node_db_session
node_customer_model -->|"uses declarative base"| node_db_session
node_product_model -->|"uses declarative base"| node_db_session
node_order_model -->|"uses declarative base"| node_db_session
node_item_model -->|"uses declarative base"| node_db_session
node_db_session -->|"connects to"| node_sqlite

click node_application "https://github.com/mayrkov/trabalho---03/blob/main/app/main.py"
click node_customers "https://github.com/mayrkov/trabalho---03/blob/main/app/routers/cliente.py"
click node_products "https://github.com/mayrkov/trabalho---03/blob/main/app/routers/produto.py"
click node_orders "https://github.com/mayrkov/trabalho---03/blob/main/app/routers/pedido.py"
click node_order_items "https://github.com/mayrkov/trabalho---03/blob/main/app/routers/item_pedido.py"
click node_customer_contract "https://github.com/mayrkov/trabalho---03/blob/main/app/schemas/cliente.py"
click node_product_contract "https://github.com/mayrkov/trabalho---03/blob/main/app/schemas/produto.py"
click node_order_contract "https://github.com/mayrkov/trabalho---03/blob/main/app/schemas/pedido.py"
click node_item_contract "https://github.com/mayrkov/trabalho---03/blob/main/app/schemas/item_pedido.py"
click node_customer_model "https://github.com/mayrkov/trabalho---03/blob/main/app/models/cliente.py"
click node_product_model "https://github.com/mayrkov/trabalho---03/blob/main/app/models/produto.py"
click node_order_model "https://github.com/mayrkov/trabalho---03/blob/main/app/models/pedido.py"
click node_item_model "https://github.com/mayrkov/trabalho---03/blob/main/app/models/item_pedido.py"
click node_db_session "https://github.com/mayrkov/trabalho---03/blob/main/app/core/database.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_application,node_api_client toneBlue
class node_customers,node_products,node_orders,node_order_items,node_sqlite toneAmber
class node_customer_contract,node_product_contract,node_order_contract,node_item_contract toneMint
class node_customer_model,node_product_model,node_order_model,node_item_model,node_db_session toneRose
```

## Components

### API entry

- [FastAPI application](https://github.com/mayrkov/trabalho---03/blob/main/app/main.py): `app/main.py`

### Resource handlers

- [Customer routes](https://github.com/mayrkov/trabalho---03/blob/main/app/routers/cliente.py): `app/routers/cliente.py`
- [Product routes](https://github.com/mayrkov/trabalho---03/blob/main/app/routers/produto.py): `app/routers/produto.py`
- [Order routes](https://github.com/mayrkov/trabalho---03/blob/main/app/routers/pedido.py): `app/routers/pedido.py`
- [Order item routes](https://github.com/mayrkov/trabalho---03/blob/main/app/routers/item_pedido.py): `app/routers/item_pedido.py`

### Data contracts

- [Customer schemas](https://github.com/mayrkov/trabalho---03/blob/main/app/schemas/cliente.py): `app/schemas/cliente.py`
- [Product schemas](https://github.com/mayrkov/trabalho---03/blob/main/app/schemas/produto.py): `app/schemas/produto.py`
- [Order schemas](https://github.com/mayrkov/trabalho---03/blob/main/app/schemas/pedido.py): `app/schemas/pedido.py`
- [Item schemas](https://github.com/mayrkov/trabalho---03/blob/main/app/schemas/item_pedido.py): `app/schemas/item_pedido.py`

### Persistence

- [Customer model](https://github.com/mayrkov/trabalho---03/blob/main/app/models/cliente.py): `app/models/cliente.py`
- [Product model](https://github.com/mayrkov/trabalho---03/blob/main/app/models/produto.py): `app/models/produto.py`
- [Order model](https://github.com/mayrkov/trabalho---03/blob/main/app/models/pedido.py): `app/models/pedido.py`
- [Order item model](https://github.com/mayrkov/trabalho---03/blob/main/app/models/item_pedido.py): `app/models/item_pedido.py`
- [Database sessions](https://github.com/mayrkov/trabalho---03/blob/main/app/core/database.py): `app/core/database.py`

### Other components

- **API client**
- **SQLite database**

## Connections

- API client → FastAPI application: sends requests (evidence: `README.md`)
- FastAPI application → Customer routes: mounts router (evidence: `app/main.py`)
- FastAPI application → Product routes: mounts router (evidence: `app/main.py`)
- FastAPI application → Order routes: mounts router (evidence: `app/main.py`)
- FastAPI application → Order item routes: mounts router (evidence: `app/main.py`)
- Customer routes → Customer schemas: validates and serializes (evidence: `app/routers/cliente.py`)
- Product routes → Product schemas: validates and serializes (evidence: `app/routers/produto.py`)
- Order routes → Order schemas: validates and serializes (evidence: `app/routers/pedido.py`)
- Order item routes → Item schemas: validates and serializes (evidence: `app/routers/item_pedido.py`)
- Customer routes → Customer model: queries and changes (evidence: `app/routers/cliente.py`)
- Product routes → Product model: queries and changes (evidence: `app/routers/produto.py`)
- Order routes → Order model: queries and changes (evidence: `app/routers/pedido.py`)
- Order routes → Customer model: checks customer (evidence: `app/routers/pedido.py`)
- Order item routes → Order item model: creates and updates (evidence: `app/routers/item_pedido.py`)
- Order item routes → Order model: checks and recalculates (evidence: `app/routers/item_pedido.py`)
- Order item routes → Product model: checks product (evidence: `app/routers/item_pedido.py`)
- Customer routes → Database sessions: gets session (evidence: `app/routers/cliente.py`)
- Product routes → Database sessions: gets session (evidence: `app/routers/produto.py`)
- Order routes → Database sessions: gets session (evidence: `app/routers/pedido.py`)
- Order item routes → Database sessions: gets session (evidence: `app/routers/item_pedido.py`)
- Customer model → Database sessions: uses declarative base (evidence: `app/models/cliente.py`)
- Product model → Database sessions: uses declarative base (evidence: `app/models/produto.py`)
- Order model → Database sessions: uses declarative base (evidence: `app/models/pedido.py`)
- Order item model → Database sessions: uses declarative base (evidence: `app/models/item_pedido.py`)
- Database sessions → SQLite database: connects to (evidence: `README.md`)
