Zum Hauptinhalt springen

Architektur

StoreStash besteht aus 4 Docker-Services hinter einem Nginx Reverse Proxy.

Übersicht​

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ Docker Network ───────────────────┐
β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Nginx │───►│ Frontend β”‚ β”‚ Backend β”‚ β”‚
β”‚ β”‚ :80 β”‚ β”‚ SvelteKitβ”‚ β”‚ FastAPI β”‚ β”‚
β”‚ β”‚ │───►│ :3000 β”‚ β”‚ :8000 β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ /api/* β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”‚
β”‚ β”‚ β”‚ DB β”‚ β”‚
β”‚ β”‚ β”‚ Postgresβ”‚ β”‚
β”‚ β”‚ β”‚ :5432 β”‚ β”‚
β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ Port 3000 (nicht exponiert) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”˜β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Request-Flow​

  1. Browser β†’ Nginx (:3000)
  2. Nginx routet:
    • /api/* β†’ Backend (FastAPI :8000)
    • /* β†’ Frontend (SvelteKit :3000)
  3. Backend β†’ PostgreSQL (intern :5432)

Services​

Nginx​

  • Reverse Proxy, TLS Termination (in Produktion)
  • Rate-Limiting: 30 req/s pro IP, Burst 20
  • Security Headers: CSP, X-Frame-Options, Permissions-Policy
  • Body-Size-Limit: 2 MB
  • Swagger UI blockiert in Produktion

Frontend (SvelteKit)​

  • Server-Side Rendering via adapter-node
  • Tailwind CSS mit CSS Custom Properties fΓΌr Themes
  • PWA: Manifest, Service Worker, Shortcuts
  • i18n: DE + EN, erweiterbar

Backend (FastAPI)​

  • Async (asyncio + asyncpg)
  • SQLAlchemy 2.0 ORM
  • Pydantic v2 Schemas mit strikter Validierung
  • Open Food Facts Proxy

PostgreSQL​

  • Version 16 (Alpine)
  • Nur im Docker-Netzwerk erreichbar
  • Healthcheck via pg_isready
  • Volume-Mount fΓΌr Persistenz

Verzeichnisstruktur​

backend/app/
β”œβ”€β”€ api/v1/ # Endpoint-Router (products, stock, barcode, ...)
β”œβ”€β”€ core/ # Config, Database, Seed
β”œβ”€β”€ models/ # SQLAlchemy ORM Models
β”œβ”€β”€ schemas/ # Pydantic Request/Response Schemas
└── services/ # Business Logic (inventory_service)

frontend/src/
β”œβ”€β”€ lib/
β”‚ β”œβ”€β”€ api/ # Typed API Client
β”‚ β”œβ”€β”€ components/ # Svelte Components (ui/, inventory/, layout/)
β”‚ β”œβ”€β”€ i18n/ # Translations (de.ts, en.ts)
β”‚ β”œβ”€β”€ stores/ # Svelte Stores (state, themes, device)
β”‚ └── types/ # TypeScript Interfaces
β”œβ”€β”€ routes/ # 10 SvelteKit Pages
└── app.css # Tailwind + CSS Variables