How semionhiwi/uni-project-pizza- works
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: models.py Relational model · crud.py Order lifecycle · router.py Domain endpoints · CreateOrderDialog.tsx Order UI
Components 22
FastAPI backend
- FastAPI entry
app/main.py - Versioned API router
app/api/v1/router.py - Domain endpoints · Resources use routers, validation schemas, and CRUD modules.
app/api/v1/endpoints/order/router.py - Order lifecycle · Composes orders, pizzas, beverages, users, addresses, prices, and status.
app/api/v1/endpoints/order/crud.py - Address handling
app/api/v1/endpoints/order/address/crud.py - Stock consumption · Fulfillment decrements ingredient and beverage availability.
app/api/v1/endpoints/order/stock_logic/stock_ingredients_crud.py - Pizza definitions · Reusable pizza types define ingredient and sauce composition.
app/api/v1/endpoints/pizza_type/crud.py - Relational model · Canonical entities and relationships.
app/database/models.py - Database connection
app/database/connection.py - Alembic migrations
app/database/migrations/versions/3701fe355667_add_pizza_type_sauce_quantity_table.py - Nominatim integration
Preact client
- Client entry
pizza_1337_preact/src/index.tsx - Application composition
pizza_1337_preact/src/AppComponent.tsx - Order UI · Order creation and details render shared state.
pizza_1337_preact/src/components/CreateOrderDialog.tsx - Order actions
pizza_1337_preact/src/flux/actions/OrderActions.ts - Shared order state
pizza_1337_preact/src/flux/store/store.ts - Backend port
pizza_1337_preact/src/ports_adapters/ports/PortPizzaBackend.ts - REST adapter
pizza_1337_preact/src/ports_adapters/adapters/RestAdapterPizzaBackend.ts - Generated API services · Transport and generated types remain separate from UI.
pizza_1337_preact/src/api/services/OrderService.ts
Delivery
- Docker Compose
docker-compose.yml - Kubernetes deployments
infra/deployment/deployment-staging.yaml - GitLab CI
.gitlab-ci.yml
Connections 24
- 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