# lsf-wesel-rheinhausen/lsf-fliegerlager-webapp architecture

> Architecture diagram of the GitHub repository lsf-wesel-rheinhausen/lsf-fliegerlager-webapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp
- Repository: https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp

## Overview

#### Purpose and runtime
Fliegerlager-Abrechnung is a Docker-oriented Django 5.2 / Python 3.13 application for managing club flying camps: participants, pricing, bookings, expenses, payments, shifts, meal orders, and auditable settlements. It serves both staff administration and participant kiosk/PWA interfaces. Primary Django entry points are `src/manage.py`, `src/config/wsgi.py`, and `src/config/asgi.py`; production uses Gunicorn configuration in `src/config/gunicorn_config.py`.

#### Application composition and routing
The domain is concentrated in one Django app, `billing`. Project settings, middleware, global routes, SSO, persistence migration, and web-push key handling are the framework boundary in:
- `src/config/settings.py`
- `src/config/urls.py`
- `src/config/middleware.py`

Feature routes and request handlers are primarily:
- `src/billing/urls.py`
- `src/billing/views.py`
- `src/billing/admin.py`

Server-rendered Django templates and small static JavaScript/CSS assets implement the UI rather than a separate frontend application.

#### Core domain and settlement pipeline
The relational domain models camps, participants/families, price rules, charges, payments, expenses, meal signups/orders, shifts, and versioned settlement runs. Its central persistence contract is:
- `src/billing/models.py`
- `src/billing/migrations/0021_settlementrun_versioned_snapshots.py`
- `src/billing/migrations/0065_payment_soft_delete_audit.py`

Staff create/import operational records; pricing and settlement services calculate participant and camp-level results; settlement runs retain immutable snapshots and feed CSV, Excel, and PDF exports. Business orchestration and file interchange are centered in:
- `src/billing/services.py`
- `src/billing/importers.py`
- `src/billing/exporters.py`

#### Participant kiosk, meals, and shift workflows
A separate participant-facing kiosk operates under kiosk-specific access and security rules: common camp PIN, personal PIN/session access, active-camp isolation, and action auditing. Relevant boundaries are:
- `src/billing/kiosk_access.py`
- `src/billing/kiosk_security.py`
- `src/billing/kiosk_access_views.py`

Kiosk flows expose meal bookings, attendance/profile activity, family/partner permissions, and self-service shift selection/exchange. Their presentation layer begins at:
- `src/templates/billing/kiosk_base.html`
- `src/templates/billing/kiosk_home.html`
- `src/templates/billing/kiosk_shifts.html`

#### Identity, authorization, and communications
Django groups implement Admin and Bearbeiter authorization, supplemented by superuser access. Authentication supports password login, optional passkeys, trusted-header Authelia SSO, and controlled account recovery:
- `src/billing/auth.py`
- `src/billing/permissions.py`
- `src/config/sso.py`

Notification delivery crosses external boundaries: encrypted/configured SMTP email and web-push subscriptions. Worker commands process queued delivery/recovery work:
- `src/billing/email_delivery.py`
- `src/billing/notifications.py`
- `src/billing/management/commands/run_push_worker.py`

#### Infrastructure, persistence, and deployment updates
Development may use SQLite, while Docker deployments and concurrent kiosk use require PostgreSQL. Compose runs the application plus an isolated updater; production images are published to GHCR. Deployment artifacts are:
- `docker-compose.yml`
- `Dockerfile`
- `Dockerfile.updater`

The app requests updates through an internal agent. That agent uses Portainer’s API—not a Docker socket—to redeploy, backs up PostgreSQL, records image digests for rollback, and health-checks the resulting service:
- `deployment_agent.py`
- `src/billing/deployment_updates.py`
- `scripts/postgres-backup.sh`

#### PWA and operational boundaries
The PWA supplies install/offline UX and push integration but explicitly avoids caching sensitive application data. Its server/static boundary is:
- `src/billing/pwa_views.py`
- `src/templates/billing/service_worker.js`
- `src/static/billing/pwa.js`

Security-sensitive deployment behavior includes HTTPS cookies/redirects, host/CSRF controls, guarded Gunicorn request parsing, trusted-proxy SSO, kiosk throttling, and environment-provided secrets.

Main entry points: [`src/billing/models.py`](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/models.py) (Billing domain), [`src/billing/kiosk_access_views.py`](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/kiosk_access_views.py) (Kiosk workflows), [`src/billing/views.py`](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/views.py) (Staff routes & views), [`src/billing/services.py`](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/services.py) (Pricing & settlement)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_django["Django application"]
  node_entrypoints{{"Django entry points<br/>runtime<br/>[manage.py]"}}
  node_config["Project boundary<br/>Django config<br/>[settings.py]"]
  node_staff_routes["Staff routes &amp; views<br/>Django handlers<br/>[views.py]"]
  node_admin["Django admin<br/>admin UI<br/>[admin.py]"]
  node_domain[("Billing domain<br/>Django models<br/>[models.py]")]
  node_settlement_snapshots["Settlement snapshots<br/>schema migration"]
  node_services["Pricing &amp; settlement<br/>domain services<br/>[services.py]"]
  node_interchange["Import &amp; exports<br/>file interchange<br/>[exporters.py]"]
  node_identity["Identity &amp; authorization<br/>auth boundary<br/>[auth.py]"]
end

subgraph group_kiosk["Participant kiosk"]
  node_kiosk_access["Kiosk access control<br/>access security<br/>[kiosk_access.py]"]
  node_kiosk_views["Kiosk workflows<br/>Django handlers"]
  node_kiosk_ui["Kiosk templates<br/>participant UI<br/>[kiosk_home.html]"]
end

subgraph group_delivery["Notifications &amp; PWA"]
  node_notifications["Email &amp; push delivery<br/>notification service<br/>[notifications.py]"]
  node_push_worker{{"Push worker<br/>management command<br/>[run_push_worker.py]"}}
  node_pwa["PWA boundary<br/>PWA endpoints<br/>[pwa_views.py]"]
end

subgraph group_deployment["Deployment updates"]
  node_compose{{"Docker Compose<br/>deployment runtime<br/>[docker-compose.yml]"}}
  node_update_requests["Update requests<br/>deployment service"]
  node_agent{{"Deployment agent<br/>updater runtime"}}
end

node_database[("SQLite / PostgreSQL<br/>relational database")]
node_staff_ui["Staff browser UI<br/>server-rendered UI"]
node_portainer{{"Portainer API<br/>external deployment API"}}

node_entrypoints -->|"loads"| node_config
node_config -->|"routes"| node_staff_routes
node_config -->|"configures"| node_identity
node_staff_ui -->|"requests"| node_staff_routes
node_staff_routes -->|"authorizes"| node_identity
node_staff_routes -->|"orchestrates"| node_services
node_admin -->|"manages"| node_domain
node_services -->|"calculates from"| node_domain
node_services -->|"produces results for"| node_interchange
node_domain -.->|"versioned by"| node_settlement_snapshots
node_domain -->|"persists"| node_database
node_kiosk_ui -->|"uses"| node_kiosk_views
node_kiosk_views -->|"enforces access"| node_kiosk_access
node_kiosk_views -->|"books and selects"| node_services
node_kiosk_views -->|"reads and writes"| node_domain
node_notifications -->|"queued delivery"| node_push_worker
node_pwa -->|"push integration"| node_notifications
node_update_requests -->|"requests update"| node_agent
node_compose -->|"isolates"| node_agent
node_agent -->|"redeploys via"| node_portainer
node_agent -->|"backs up PostgreSQL"| node_database

click node_entrypoints "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/manage.py"
click node_config "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/config/settings.py"
click node_staff_routes "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/views.py"
click node_admin "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/admin.py"
click node_domain "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/models.py"
click node_settlement_snapshots "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/migrations/0021_settlementrun_versioned_snapshots.py"
click node_services "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/services.py"
click node_interchange "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/exporters.py"
click node_kiosk_access "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/kiosk_access.py"
click node_kiosk_views "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/kiosk_access_views.py"
click node_kiosk_ui "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/templates/billing/kiosk_home.html"
click node_identity "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/auth.py"
click node_notifications "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/notifications.py"
click node_push_worker "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/management/commands/run_push_worker.py"
click node_pwa "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/pwa_views.py"
click node_compose "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/docker-compose.yml"
click node_update_requests "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/deployment_updates.py"
click node_agent "https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/deployment_agent.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_entrypoints,node_config,node_staff_routes,node_admin,node_domain,node_settlement_snapshots,node_services,node_interchange,node_identity toneBlue
class node_kiosk_access,node_kiosk_views,node_kiosk_ui toneAmber
class node_notifications,node_push_worker,node_pwa toneMint
class node_compose,node_update_requests,node_agent toneRose
class node_database,node_staff_ui,node_portainer toneNeutral
```

## Components

### Django application

- [Django entry points](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/manage.py): runtime · HTTP and ASGI/WSGI application entry points. · `src/manage.py`
- [Project boundary](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/config/settings.py): Django config · Settings, middleware, global routes, SSO, and persistence setup. · `src/config/settings.py`
- [Staff routes & views](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/views.py): Django handlers · `src/billing/views.py`
- [Django admin](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/admin.py): admin UI · `src/billing/admin.py`
- [Billing domain](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/models.py): Django models · Camps, people, pricing, charges, payments, meals, shifts, and settlements. · `src/billing/models.py`
- [Settlement snapshots](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/migrations/0021_settlementrun_versioned_snapshots.py): schema migration · Versioned immutable settlement records. · `src/billing/migrations/0021_settlementrun_versioned_snapshots.py`
- [Pricing & settlement](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/services.py): domain services · `src/billing/services.py`
- [Import & exports](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/exporters.py): file interchange · Operational imports plus CSV, Excel, and PDF settlement output. · `src/billing/exporters.py`
- [Identity & authorization](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/auth.py): auth boundary · Password, passkeys, trusted-header SSO, recovery, and group permissions. · `src/billing/auth.py`

### Participant kiosk

- [Kiosk access control](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/kiosk_access.py): access security · PIN/session access, active-camp isolation, throttling, and audit rules. · `src/billing/kiosk_access.py`
- [Kiosk workflows](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/kiosk_access_views.py): Django handlers · Meals, attendance, profiles, family permissions, and shifts. · `src/billing/kiosk_access_views.py`
- [Kiosk templates](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/templates/billing/kiosk_home.html): participant UI · `src/templates/billing/kiosk_home.html`

### Notifications & PWA

- [Email & push delivery](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/notifications.py): notification service · SMTP delivery and web-push subscriptions. · `src/billing/notifications.py`
- [Push worker](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/management/commands/run_push_worker.py): management command · Processes queued push delivery and recovery work. · `src/billing/management/commands/run_push_worker.py`
- [PWA boundary](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/pwa_views.py): PWA endpoints · Offline/install UX without caching sensitive application data. · `src/billing/pwa_views.py`

### Deployment updates

- [Docker Compose](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/docker-compose.yml): deployment runtime · Runs the application and isolated updater. · `docker-compose.yml`
- [Update requests](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/src/billing/deployment_updates.py): deployment service · App-side requests to the internal deployment agent. · `src/billing/deployment_updates.py`
- [Deployment agent](https://github.com/lsf-wesel-rheinhausen/lsf-fliegerlager-webapp/blob/main/deployment_agent.py): updater runtime · Uses Portainer API for redeploy, backup, rollback digest, and health checks. · `deployment_agent.py`

### Other components

- **SQLite / PostgreSQL**: relational database · PostgreSQL is required for concurrent Docker kiosk deployments.
- **Staff browser UI**: server-rendered UI
- **Portainer API**: external deployment API · Redeploys without Docker socket access.

## Connections

- Django entry points → Project boundary: loads
- Project boundary → Staff routes & views: routes
- Project boundary → Identity & authorization: configures
- Staff browser UI → Staff routes & views: requests
- Staff routes & views → Identity & authorization: authorizes
- Staff routes & views → Pricing & settlement: orchestrates
- Django admin → Billing domain: manages
- Pricing & settlement → Billing domain: calculates from
- Pricing & settlement → Import & exports: produces results for
- Billing domain → Settlement snapshots: versioned by
- Billing domain → SQLite / PostgreSQL: persists
- Kiosk templates → Kiosk workflows: uses
- Kiosk workflows → Kiosk access control: enforces access
- Kiosk workflows → Pricing & settlement: books and selects
- Kiosk workflows → Billing domain: reads and writes
- Email & push delivery → Push worker: queued delivery
- PWA boundary → Email & push delivery: push integration
- Update requests → Deployment agent: requests update
- Docker Compose → Deployment agent: isolates
- Deployment agent → Portainer API: redeploys via
- Deployment agent → SQLite / PostgreSQL: backs up PostgreSQL
