# semionhiwi/uni-project-pizza- architecture

> Architecture diagram of the GitHub repository semionhiwi/uni-project-pizza-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/semionhiwi/uni-project-pizza-
- Repository: https://github.com/semionhiwi/uni-project-pizza-

## Overview

#### Purpose and topology
This is a pizza-ordering platform: a Python REST backend plus a separate Preact/TypeScript client. The backend manages users, menu/inventory entities, pizza definitions, orders, addresses, pricing, statuses, and stock consumption. The frontend consumes the backend through generated OpenAPI-style TypeScript services.

#### Backend entry and HTTP composition
FastAPI starts at `app/main.py`, which mounts the versioned API assembled in `app/api/v1/router.py`. Domain endpoints follow a consistent router → schema → CRUD layout, for example:
- `app/api/v1/endpoints/order/router.py`
- `app/api/v1/endpoints/order/schemas.py`
- `app/api/v1/endpoints/order/crud.py`

This is the principal API boundary: request validation and response contracts are in schemas; persistence/business operations are in CRUD modules.

#### Domain catalog and pizza construction
Menu/inventory resources are independently exposed for beverages, dough, sauces, toppings, and pizza types. Pizza types model reusable pizza definitions and their ingredient composition, including sauce quantities:
- `app/api/v1/endpoints/pizza_type/crud.py`
- `app/api/v1/endpoints/topping/crud.py`
- `app/database/migrations/versions/3701fe355667_add_pizza_type_sauce_quantity_table.py`

The canonical relational model is centralized in `app/database/models.py`; Alembic migrations evolve it from `app/database/migrations/versions/`.

#### Order lifecycle and inventory boundary
Orders are the transactional core. Order APIs compose pizzas, beverages, users, and addresses, calculate/order prices, and manage order state through:
- `app/api/v1/endpoints/order/router.py`
- `app/api/v1/endpoints/order/crud.py`
- `app/api/v1/endpoints/order/address/crud.py`

Stock-specific logic is deliberately separated from general order CRUD in `app/api/v1/endpoints/order/stock_logic/stock_ingredients_crud.py` and `app/api/v1/endpoints/order/stock_logic/stock_beverage_crud.py`. This boundary is where order fulfillment affects ingredient and beverage availability.

#### Persistence and external integration
Backend persistence uses the connection layer at `app/database/connection.py`, SQLAlchemy-style models in `app/database/models.py`, and Alembic configuration in `alembic.ini`. Address handling has a dedicated exception, `app/exceptions/nominatim_error.py`, indicating an integration/error boundary for Nominatim geocoding or address lookup.

#### Frontend application and state flow
The Preact client enters through `pizza_1337_preact/src/index.tsx` and application composition begins at `pizza_1337_preact/src/AppComponent.tsx`. UI actions flow through Flux actions and reducers into shared state:
- `pizza_1337_preact/src/flux/actions/OrderActions.ts`
- `pizza_1337_preact/src/flux/reducer/reducer.ts`
- `pizza_1337_preact/src/flux/store/store.ts`

Components such as `pizza_1337_preact/src/components/CreateOrderDialog.tsx` and `pizza_1337_preact/src/components/OrderDetailsComponent.tsx` render and mutate that state.

#### Client/API adapter boundary
Frontend code depends on a port abstraction rather than directly coupling components to HTTP:
- `pizza_1337_preact/src/ports_adapters/ports/PortPizzaBackend.ts`
- `pizza_1337_preact/src/ports_adapters/adapters/RestAdapterPizzaBackend.ts`
- `pizza_1337_preact/src/ports_adapters/services/PizzaBackendService.ts`

The REST adapter uses generated API client services under `pizza_1337_preact/src/api/services/`, keeping OpenAPI transport/types separate from UI and state logic.

#### Delivery runtime
Docker Compose is the local orchestration entry point (`docker-compose.yml`). Backend image/boot behavior resides in `infra/build_artifacts/`, while Kubernetes deployment manifests target staging and production:
- `infra/build_artifacts/docker-entrypoint.sh`
- `infra/deployment/deployment-staging.yaml`
- `infra/deployment/deployment-production.yaml`

GitLab CI (`.gitlab-ci.yml`) and SonarQube configuration (`sonar-project.properties`) support automated validation and deployment.

Main entry points: [`app/database/models.py`](https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/database/models.py) (Relational model), [`app/api/v1/endpoints/order/crud.py`](https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/api/v1/endpoints/order/crud.py) (Order lifecycle), [`app/api/v1/endpoints/order/router.py`](https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/api/v1/endpoints/order/router.py) (Domain endpoints), [`pizza_1337_preact/src/components/CreateOrderDialog.tsx`](https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/components/CreateOrderDialog.tsx) (Order UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["FastAPI backend"]
  node_backend_main["FastAPI entry<br/>application entry<br/>[main.py]"]
  node_api_router["Versioned API router<br/>router composition<br/>[router.py]"]
  node_domain_endpoints["Domain endpoints<br/>router/schema/CRUD<br/>[router.py]"]
  node_order_crud["Order lifecycle<br/>transactional CRUD<br/>[crud.py]"]
  node_address_crud["Address handling<br/>address CRUD<br/>[crud.py]"]
  node_stock_logic["Stock consumption<br/>inventory logic"]
  node_pizza_types["Pizza definitions<br/>menu CRUD<br/>[crud.py]"]
  node_models[("Relational model<br/>SQLAlchemy models<br/>[models.py]")]
  node_connection[("Database connection<br/>persistence layer<br/>[connection.py]")]
  node_migrations["Alembic migrations<br/>schema evolution"]
  node_nominatim(("Nominatim integration<br/>external geocoding"))
end

subgraph group_frontend["Preact client"]
  node_client_entry["Client entry<br/>Preact entry<br/>[index.tsx]"]
  node_app_component["Application composition<br/>Preact root<br/>[AppComponent.tsx]"]
  node_ui_components["Order UI<br/>Preact components"]
  node_flux_actions["Order actions<br/>Flux actions<br/>[OrderActions.ts]"]
  node_flux_store["Shared order state<br/>Flux reducer/store<br/>[store.ts]"]
  node_backend_port{{"Backend port<br/>client abstraction"}}
  node_rest_adapter["REST adapter<br/>port adapter"]
  node_generated_client["Generated API services<br/>OpenAPI client<br/>[OrderService.ts]"]
end

subgraph group_delivery["Delivery"]
  node_compose{{"Docker Compose<br/>local orchestration<br/>[docker-compose.yml]"}}
  node_deployment["Kubernetes deployments<br/>staging and production"]
  node_ci["GitLab CI<br/>CI/CD pipeline<br/>[.gitlab-ci.yml]"]
end

node_backend_main -->|"mounts"| node_api_router
node_api_router -->|"routes requests"| node_domain_endpoints
node_domain_endpoints -->|"validates and invokes"| node_order_crud
node_domain_endpoints -->|"exposes"| node_pizza_types
node_order_crud -->|"uses"| node_address_crud
node_order_crud -->|"fulfillment"| node_stock_logic
node_order_crud -->|"persists"| node_models
node_pizza_types -->|"defines composition"| node_models
node_stock_logic -->|"updates inventory"| node_models
node_models -->|"uses"| node_connection
node_migrations -.->|"evolves schema"| node_models
node_address_crud -->|"geocodes addresses"| node_nominatim
node_client_entry -->|"renders"| node_app_component
node_app_component -->|"composes"| node_ui_components
node_ui_components -->|"dispatches"| node_flux_actions
node_flux_actions -->|"updates"| node_flux_store
node_ui_components -->|"reads"| node_flux_store
node_flux_actions -->|"calls"| node_backend_port
node_backend_port -->|"implemented by"| node_rest_adapter
node_rest_adapter -->|"uses"| node_generated_client
node_generated_client -->|"HTTP API"| node_api_router
node_compose -.->|"runs locally"| node_backend_main
node_deployment -.->|"deploys"| node_backend_main
node_ci -.->|"validates and deploys"| node_deployment

click node_backend_main "https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/main.py"
click node_api_router "https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/api/v1/router.py"
click node_domain_endpoints "https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/api/v1/endpoints/order/router.py"
click node_order_crud "https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/api/v1/endpoints/order/crud.py"
click node_address_crud "https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/api/v1/endpoints/order/address/crud.py"
click node_stock_logic "https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/api/v1/endpoints/order/stock_logic/stock_ingredients_crud.py"
click node_pizza_types "https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/api/v1/endpoints/pizza_type/crud.py"
click node_models "https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/database/models.py"
click node_connection "https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/database/connection.py"
click node_migrations "https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/database/migrations/versions/3701fe355667_add_pizza_type_sauce_quantity_table.py"
click node_client_entry "https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/index.tsx"
click node_app_component "https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/AppComponent.tsx"
click node_ui_components "https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/components/CreateOrderDialog.tsx"
click node_flux_actions "https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/flux/actions/OrderActions.ts"
click node_flux_store "https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/flux/store/store.ts"
click node_backend_port "https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/ports_adapters/ports/PortPizzaBackend.ts"
click node_rest_adapter "https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/ports_adapters/adapters/RestAdapterPizzaBackend.ts"
click node_generated_client "https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/api/services/OrderService.ts"
click node_compose "https://github.com/semionhiwi/uni-project-pizza-/blob/main/docker-compose.yml"
click node_deployment "https://github.com/semionhiwi/uni-project-pizza-/blob/main/infra/deployment/deployment-staging.yaml"
click node_ci "https://github.com/semionhiwi/uni-project-pizza-/blob/main/.gitlab-ci.yml"

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_backend_main,node_api_router,node_domain_endpoints,node_order_crud,node_address_crud,node_stock_logic,node_pizza_types,node_models,node_connection,node_migrations,node_nominatim toneBlue
class node_client_entry,node_app_component,node_ui_components,node_flux_actions,node_flux_store,node_backend_port,node_rest_adapter,node_generated_client toneAmber
class node_compose,node_deployment,node_ci toneMint
```

## Components

### FastAPI backend

- [FastAPI entry](https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/main.py): application entry · `app/main.py`
- [Versioned API router](https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/api/v1/router.py): router composition · `app/api/v1/router.py`
- [Domain endpoints](https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/api/v1/endpoints/order/router.py): router/schema/CRUD · Resources use routers, validation schemas, and CRUD modules. · `app/api/v1/endpoints/order/router.py`
- [Order lifecycle](https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/api/v1/endpoints/order/crud.py): transactional CRUD · Composes orders, pizzas, beverages, users, addresses, prices, and status. · `app/api/v1/endpoints/order/crud.py`
- [Address handling](https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/api/v1/endpoints/order/address/crud.py): address CRUD · `app/api/v1/endpoints/order/address/crud.py`
- [Stock consumption](https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/api/v1/endpoints/order/stock_logic/stock_ingredients_crud.py): inventory logic · Fulfillment decrements ingredient and beverage availability. · `app/api/v1/endpoints/order/stock_logic/stock_ingredients_crud.py`
- [Pizza definitions](https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/api/v1/endpoints/pizza_type/crud.py): menu CRUD · Reusable pizza types define ingredient and sauce composition. · `app/api/v1/endpoints/pizza_type/crud.py`
- [Relational model](https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/database/models.py): SQLAlchemy models · Canonical entities and relationships. · `app/database/models.py`
- [Database connection](https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/database/connection.py): persistence layer · `app/database/connection.py`
- [Alembic migrations](https://github.com/semionhiwi/uni-project-pizza-/blob/main/app/database/migrations/versions/3701fe355667_add_pizza_type_sauce_quantity_table.py): schema evolution · `app/database/migrations/versions/3701fe355667_add_pizza_type_sauce_quantity_table.py`
- **Nominatim integration**: external geocoding

### Preact client

- [Client entry](https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/index.tsx): Preact entry · `pizza_1337_preact/src/index.tsx`
- [Application composition](https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/AppComponent.tsx): Preact root · `pizza_1337_preact/src/AppComponent.tsx`
- [Order UI](https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/components/CreateOrderDialog.tsx): Preact components · Order creation and details render shared state. · `pizza_1337_preact/src/components/CreateOrderDialog.tsx`
- [Order actions](https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/flux/actions/OrderActions.ts): Flux actions · `pizza_1337_preact/src/flux/actions/OrderActions.ts`
- [Shared order state](https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/flux/store/store.ts): Flux reducer/store · `pizza_1337_preact/src/flux/store/store.ts`
- [Backend port](https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/ports_adapters/ports/PortPizzaBackend.ts): client abstraction · `pizza_1337_preact/src/ports_adapters/ports/PortPizzaBackend.ts`
- [REST adapter](https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/ports_adapters/adapters/RestAdapterPizzaBackend.ts): port adapter · `pizza_1337_preact/src/ports_adapters/adapters/RestAdapterPizzaBackend.ts`
- [Generated API services](https://github.com/semionhiwi/uni-project-pizza-/blob/main/pizza_1337_preact/src/api/services/OrderService.ts): OpenAPI client · Transport and generated types remain separate from UI. · `pizza_1337_preact/src/api/services/OrderService.ts`

### Delivery

- [Docker Compose](https://github.com/semionhiwi/uni-project-pizza-/blob/main/docker-compose.yml): local orchestration · `docker-compose.yml`
- [Kubernetes deployments](https://github.com/semionhiwi/uni-project-pizza-/blob/main/infra/deployment/deployment-staging.yaml): staging and production · `infra/deployment/deployment-staging.yaml`
- [GitLab CI](https://github.com/semionhiwi/uni-project-pizza-/blob/main/.gitlab-ci.yml): CI/CD pipeline · `.gitlab-ci.yml`

## Connections

- FastAPI entry → Versioned API router: mounts
- Versioned API router → Domain endpoints: routes requests
- Domain endpoints → Order lifecycle: validates and invokes
- Domain endpoints → Pizza definitions: exposes
- Order lifecycle → Address handling: uses
- Order lifecycle → Stock consumption: fulfillment
- Order lifecycle → Relational model: persists
- Pizza definitions → Relational model: defines composition
- Stock consumption → Relational model: updates inventory
- Relational model → Database connection: uses
- Alembic migrations → Relational model: evolves schema
- Address handling → Nominatim integration: geocodes addresses
- Client entry → Application composition: renders
- Application composition → Order UI: composes
- Order UI → Order actions: dispatches
- Order actions → Shared order state: updates
- Order UI → Shared order state: reads
- Order actions → Backend port: calls
- Backend port → REST adapter: implemented by
- REST adapter → Generated API services: uses
- Generated API services → Versioned API router: HTTP API
- Docker Compose → FastAPI entry: runs locally
- Kubernetes deployments → FastAPI entry: deploys
- GitLab CI → Kubernetes deployments: validates and deploys
