Compare commits
4
Commits
75dc033448
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
758a77c1e5 | ||
|
|
8b53fca7b7 | ||
|
|
60551802ac | ||
|
|
d6ae938dc3 |
No files matched your search
@@ -0,0 +1,52 @@
|
|||||||
|
# Homelab Sites Deployment (`armonia`) — Agent Guidelines
|
||||||
|
|
||||||
|
This file defines the runtime, architectural, and development constraints for AI agents operating within the Homelab Sites deployment repository for **Armonía del Ser** (`armonia.roadtotech.me`).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Architectural Scope & Ground Truth
|
||||||
|
|
||||||
|
- **Role**: This repository contains Docker Compose orchestration, Nginx reverse proxy configuration, Traefik routing labels, and Homelab Sites metadata (`app.yaml`) for deploying Armonía del Ser in a self-hosted Homelab environment.
|
||||||
|
- **Upstream Repositories**:
|
||||||
|
- Backend: [`armonia-api`](https://gitea.roadtotech.me/armonia-del-ser/armonia-api) (FastAPI, Python 3.13, uv)
|
||||||
|
- Admin UI: [`armonia-dashboard`](https://gitea.roadtotech.me/armonia-del-ser/armonia-dashboard) (Vite SPA, Tailwind, Biome)
|
||||||
|
- Public UI: [`armonia-landing`](https://gitea.roadtotech.me/armonia-del-ser/armonia-landing) (Self-service client reservation portal)
|
||||||
|
- Org Profile & Roadmap: [`armonia-del-ser/.profile`](https://gitea.roadtotech.me/armonia-del-ser/.profile)
|
||||||
|
- **Canonical Architecture**: Always consult [`ARCHITECTURE.md`](./ARCHITECTURE.md) and [`docs/adr/`](./docs/adr/) before modifying Traefik labels, environment variables, or compose topology.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Hard Rules
|
||||||
|
|
||||||
|
- **Branch before editing**: Create a dedicated branch before making edits for new features, configuration changes, or bug fixes. Never edit on `main` expecting to branch later.
|
||||||
|
- **Never commit directly to `main`**: All changes must be made on a feature/fix branch (`feat/*`, `fix/*`, `chore/*`) and reviewed via Pull Request.
|
||||||
|
- **Never run destructive git**: Do not execute `git reset --hard`, `git restore <file>`, `git clean -fd`, or force-push without explicit user confirmation.
|
||||||
|
- **Redact secrets**: Never commit or print real tokens, private keys, passwords, or connection strings. Use environment variables defined in `.env.example`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Operations & Validation Commands
|
||||||
|
|
||||||
|
Use `appctl` to validate and operate the Homelab Sites deployment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Validate manifest schema and render Docker Compose
|
||||||
|
appctl config armonia
|
||||||
|
|
||||||
|
# Build container images and start services
|
||||||
|
appctl up armonia
|
||||||
|
|
||||||
|
# Inspect container health and service logs
|
||||||
|
appctl info armonia
|
||||||
|
appctl logs armonia
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Documentation Integrity
|
||||||
|
|
||||||
|
- When changing router rules or environment variables in `docker-compose.yml`, simultaneously update:
|
||||||
|
- [`README.md`](./README.md)
|
||||||
|
- [`ARCHITECTURE.md`](./ARCHITECTURE.md)
|
||||||
|
- [`.env.example`](./.env.example)
|
||||||
|
- Keep [`ARCHITECTURE.md`](./ARCHITECTURE.md) strictly aligned with the present codebase reality. Do not document aspirational features in architecture files.
|
||||||
+176
@@ -0,0 +1,176 @@
|
|||||||
|
# Architecture: Homelab Sites Orchestration (`armonia`)
|
||||||
|
|
||||||
|
This document defines the canonical present-state system architecture and deployment topology for **Armonía del Ser** running within the self-hosted Homelab Sites environment at `armonia.roadtotech.me`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. System Overview
|
||||||
|
|
||||||
|
The Homelab Sites deployment packages the Armonía del Ser platform as a containerized, self-hosted composition providing both the administrative operator control surface and the public scheduling backend. It integrates directly with the Homelab's reverse proxy ([Traefik](https://traefik.io/)), single sign-on / forward-auth identity provider ([Authelia](https://www.authelia.com/)), and directory service ([LLDAP](https://github.com/lldap/lldap)).
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart TD
|
||||||
|
subgraph Internet ["Public & Client Traffic"]
|
||||||
|
Visitor["Public Client / Visitor"]
|
||||||
|
Operator["Practice Operator (Jasmin / Assistant)"]
|
||||||
|
end
|
||||||
|
|
||||||
|
subgraph HomelabEdge ["Homelab Edge & Gateway"]
|
||||||
|
Traefik["Traefik Reverse Proxy"]
|
||||||
|
Authelia["Authelia ForwardAuth"]
|
||||||
|
LLDAP[("LLDAP Directory")]
|
||||||
|
end
|
||||||
|
|
||||||
|
subgraph SitesArmonia ["Sites Deployment: armonia.roadtotech.me"]
|
||||||
|
Dashboard["armonia-dashboard<br/>(Nginx 1.27 + Vite SPA)"]
|
||||||
|
API["armonia-api<br/>(FastAPI Python 3.13)"]
|
||||||
|
SQLite[("Local SQLite Volume<br/>/data/armonia.db")]
|
||||||
|
end
|
||||||
|
|
||||||
|
subgraph ExternalServices ["External Cloud Services"]
|
||||||
|
GCal["Google Calendar API"]
|
||||||
|
TursoCloud[("Turso Cloud libSQL<br/>(Optional Remote DB)")]
|
||||||
|
end
|
||||||
|
|
||||||
|
Visitor -->|"GET /api/{health,availability,services}<br/>POST /api/bookings (with CORS OPTIONS)"| Traefik
|
||||||
|
Operator -->|"Browser HTTPS"| Traefik
|
||||||
|
|
||||||
|
Traefik -->|"Check Session & Role Headers"| Authelia
|
||||||
|
Authelia -->|"Verify LDAP Groups"| LLDAP
|
||||||
|
|
||||||
|
Traefik -->|"Priority 30: Public Bypass (No Auth)"| API
|
||||||
|
Traefik -->|"Priority 20: Protected API (/api with Remote-* headers)"| API
|
||||||
|
Traefik -->|"Priority 10: Protected Dashboard (/)"| Dashboard
|
||||||
|
|
||||||
|
Dashboard -.->|"Internal proxy fallback /api/ -> :8000"| API
|
||||||
|
API -->|"Read/Write (UID 1000)"| SQLite
|
||||||
|
API -.->|"Dual-driver connection (optional)"| TursoCloud
|
||||||
|
API -.->|"Bidirectional calendar sync"| GCal
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Architectural Principles
|
||||||
|
|
||||||
|
1. **Defense in Depth**: Public intake routes are narrowly whitelisted at the Traefik edge. All administrative routes (`/api/bookings/*`, `/api/clients/*`, `/api/auth/*`, `/api/rosters/*`) enforce strict role-based access control inside the FastAPI application via `AUTH_PROVIDER=proxy_headers`.
|
||||||
|
2. **Offline-Tolerant Local State**: The deployment operates autonomously using a bind-mounted local SQLite volume (`./data:/data`) without mandatory external database dependencies.
|
||||||
|
3. **Decoupled Identity**: Application containers store no master user passwords or LDAP credentials; user identity and group memberships are asserted securely via upstream Authelia proxy headers (`Remote-Email`, `Remote-Groups`, `Remote-Name`, `Remote-User`).
|
||||||
|
4. **Predictable Immutability**: Production dashboard assets are compiled into immutable static files served via Nginx with aggressive HTTP caching for static bundles (`/assets/`) and SPA fallback routing.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Components & Responsibilities
|
||||||
|
|
||||||
|
| Container / Service | Image / Build Base | Responsibilities | Exposed Port | Bound Volumes / Networks |
|
||||||
|
| :--- | :--- | :--- | :--- | :--- |
|
||||||
|
| **`armonia-api`** | Git Context (`armonia-api.git#main`) with `uv` + Python 3.13-slim | Operational backend: booking engine, availability calculation, client CRM, JIT admin allowlisting, Google Calendar sync, and schema auto-migration. | 8000 (Internal) | `./data:/data` (UID 1000:100), `proxy-net` |
|
||||||
|
| **`armonia-dashboard`** | Multistage [`Dockerfile.dashboard`](./Dockerfile.dashboard) (Node 22 pnpm builder -> Nginx 1.27 Alpine) | Serves the responsive, mobile-first Vite SPA administrative dashboard. Includes an internal Nginx proxy fallback forwarding `/api/` to `armonia-api:8000` with Authelia headers. | 80 (Internal) | `proxy-net` |
|
||||||
|
| **`Traefik`** *(External)* | Homelab Core Service | SSL termination, routing rules, strip-prefix middleware, and Authelia ForwardAuth enforcement. | 80, 443 (Host) | `proxy-net` |
|
||||||
|
| **`Authelia`** *(External)* | Homelab Core Service | Evaluates session cookies, validates credentials against LLDAP, and injects authenticated identity headers. | Internal | `proxy-net` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Routing & Authentication Boundaries
|
||||||
|
|
||||||
|
Routing decisions are handled in Traefik based on priority and path matching:
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
sequenceDiagram
|
||||||
|
autonumber
|
||||||
|
actor Client as Visitor / Operator
|
||||||
|
participant T as Traefik
|
||||||
|
participant A as Authelia
|
||||||
|
participant API as armonia-api
|
||||||
|
participant UI as armonia-dashboard
|
||||||
|
|
||||||
|
alt Public Route (Priority 30: /api/services, /api/availability, POST /api/bookings, etc.)
|
||||||
|
Client->>T: Request public endpoint
|
||||||
|
T->>T: Strip /api prefix
|
||||||
|
T->>API: Forward unauthenticated request
|
||||||
|
API-->>Client: 200 OK / 201 Created
|
||||||
|
else Protected API Route (Priority 20: /api/clients, /api/auth, GET /api/bookings)
|
||||||
|
Client->>T: Request protected API endpoint
|
||||||
|
T->>A: Verify session cookie
|
||||||
|
alt No Valid Session
|
||||||
|
A-->>Client: 401 Unauthorized / 302 Redirect to Authelia
|
||||||
|
else Valid Session
|
||||||
|
A-->>T: Inject Remote-Email, Remote-Groups, Remote-Name
|
||||||
|
T->>T: Strip /api prefix
|
||||||
|
T->>API: Forward with Remote-* headers
|
||||||
|
API->>API: Map LLDAP group -> RoleEnum (OWNER, ADMIN, ASSISTANT)
|
||||||
|
API-->>Client: 200 OK JSON Response
|
||||||
|
end
|
||||||
|
else Protected UI Route (Priority 10: /*)
|
||||||
|
Client->>T: Request dashboard page
|
||||||
|
T->>A: Verify session cookie
|
||||||
|
alt Valid Session
|
||||||
|
A-->>T: OK
|
||||||
|
T->>UI: Serve static Vite SPA (index.html, assets)
|
||||||
|
UI-->>Client: 200 OK HTML/JS
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
### Traefik Routers Specification
|
||||||
|
|
||||||
|
1. **`armonia-api-public` (Priority 30, Public)**:
|
||||||
|
- **Rule**: `Host(SERVICE_DOMAIN) && (PathPrefix('/api/health') || PathPrefix('/api/availability') || (Method('GET', 'HEAD', 'OPTIONS') && PathPrefix('/api/services')) || (Method('POST', 'OPTIONS') && PathPrefix('/api/bookings')))`
|
||||||
|
- **Middleware**: `armonia-api-strip@docker` (strips `/api`).
|
||||||
|
- **Target**: `armonia-api:8000`.
|
||||||
|
- **Authentication**: None (Bypasses Authelia).
|
||||||
|
|
||||||
|
2. **`armonia-api` (Priority 20, Protected Operator API)**:
|
||||||
|
- **Rule**: `Host(SERVICE_DOMAIN) && PathPrefix('/api')`
|
||||||
|
- **Middleware**: `authelia-auth@docker`, `armonia-api-strip@docker`.
|
||||||
|
- **Target**: `armonia-api:8000`.
|
||||||
|
- **Authentication**: Authelia ForwardAuth enforces authenticated session and forwards headers.
|
||||||
|
|
||||||
|
3. **`armonia-dashboard` (Priority 10, Protected Operator UI)**:
|
||||||
|
- **Rule**: `Host(SERVICE_DOMAIN) && PathPrefix('/')`
|
||||||
|
- **Middleware**: `authelia-auth@docker`.
|
||||||
|
- **Target**: `armonia-dashboard:80`.
|
||||||
|
- **Authentication**: Authelia ForwardAuth.
|
||||||
|
|
||||||
|
4. **`armonia-red` (HTTP to HTTPS Redirect)**:
|
||||||
|
- **Rule**: `Host(SERVICE_DOMAIN)` on entrypoint `web`.
|
||||||
|
- **Middleware**: `https-redirect@docker`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Security & Decoupled Role Mapping
|
||||||
|
|
||||||
|
When `AUTH_PROVIDER=proxy_headers` is set:
|
||||||
|
1. `armonia-api` trusts upstream headers injected by Traefik from Authelia:
|
||||||
|
- `Remote-Email`: Normalized email address of the authenticated operator.
|
||||||
|
- `Remote-Name`: Full display name of the operator.
|
||||||
|
- `Remote-Groups`: Comma-separated list of LLDAP group memberships.
|
||||||
|
2. In `app.core.auth`, incoming groups are mapped in descending order of privilege:
|
||||||
|
- `armonia-owner` $\to$ `RoleEnum.OWNER` (Jasmin)
|
||||||
|
- `armonia-admin` $\to$ `RoleEnum.ADMIN`
|
||||||
|
- `armonia-assistant` $\to$ `RoleEnum.ASSISTANT` (Assistant)
|
||||||
|
3. **Just-In-Time (JIT) Actor Provisioning**:
|
||||||
|
When an authenticated operator initiates a state mutation (such as recording a payment or completing a clinical session), `armonia-api` automatically mirrors the user into the local `admin_allowlist` table to satisfy foreign-key referential integrity for `admin_audit_log`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. Persistence & State Boundaries
|
||||||
|
|
||||||
|
- **Local SQLite Engine (`DATABASE_URL=file:/data/armonia.db`)**:
|
||||||
|
- The SQLite database is stored on the host filesystem under `./data/armonia.db` and bind-mounted to `/data` in the container.
|
||||||
|
- Initialized on boot via FastAPI lifespan ([`app.db.init_db`](https://gitea.roadtotech.me/armonia-del-ser/armonia-api)) using WAL mode and Foreign Key enforcement (`PRAGMA foreign_keys=ON`).
|
||||||
|
- **Turso Cloud LibSQL Driver Support**:
|
||||||
|
- The backend natively supports both local SQLite and remote Turso libSQL endpoints via `get_engine_url()` in `app.db.database`. Switching between local storage and cloud database requires only updating `DATABASE_URL` and `DATABASE_AUTH_TOKEN` in `.env`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 7. Dependencies & Runtime Constraints
|
||||||
|
|
||||||
|
- **Proxy Network**: Containers attach to the external Docker network `proxy-net` managed by the Homelab Core compose stack.
|
||||||
|
- **User IDs**: `armonia-api` executes under UID `1000:100` to maintain clean file ownership on host bind mounts.
|
||||||
|
- **CORS Configuration**: Restricted to `https://${SERVICE_DOMAIN}` and `https://armonia-landing.pages.dev`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 8. Decision Log Index
|
||||||
|
|
||||||
|
- [ADR-0001: Containerized Homelab Sites Orchestration & Dual-Router Architecture](./docs/adr/0001-homelab-sites-orchestration.md)
|
||||||
@@ -2,46 +2,66 @@
|
|||||||
|
|
||||||
Containerized Homelab Sites orchestration for **Armonía del Ser**, uniting the FastAPI backend ([`armonia-api`](https://gitea.roadtotech.me/armonia-del-ser/armonia-api)) and the mobile-first operator dashboard ([`armonia-dashboard`](https://gitea.roadtotech.me/armonia-del-ser/armonia-dashboard)) behind Traefik, Authelia ForwardAuth, and LLDAP role mapping.
|
Containerized Homelab Sites orchestration for **Armonía del Ser**, uniting the FastAPI backend ([`armonia-api`](https://gitea.roadtotech.me/armonia-del-ser/armonia-api)) and the mobile-first operator dashboard ([`armonia-dashboard`](https://gitea.roadtotech.me/armonia-del-ser/armonia-dashboard)) behind Traefik, Authelia ForwardAuth, and LLDAP role mapping.
|
||||||
|
|
||||||
|
In the platform's multi-environment topology, this deployment serves as the **authoritative self-hosted operational staging and live demonstration environment** running on `https://armonia.roadtotech.me`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🏛️ Architecture & Routing Topology
|
## 🌟 Key Capabilities
|
||||||
|
|
||||||
- **Domain**: `https://armonia.roadtotech.me`
|
- **Unified Single Sign-On (SSO)**: Integrates with Homelab Authelia and LLDAP directory services. Practice operators (Jasmin and her assistant) authenticate via their existing homelab accounts with automated role mapping (`OWNER`, `ADMIN`, `ASSISTANT`).
|
||||||
- **External Network**: `proxy-net`
|
- **Selective Public API Intake**: Traefik edge routers cleanly separate public client reservation endpoints (`/api/services`, `/api/availability`, `POST /api/bookings`) from protected operator endpoints (`/api/clients`, `/api/auth`, `/api/bookings/*`).
|
||||||
- **Traefik Routers**:
|
- **Offline-Tolerant Persistence**: Persistent local SQLite storage mounted at `./data/armonia.db` with automated schema bootstrapping and seed catalog initialization.
|
||||||
1. `armonia-api-public` (Priority `30`, Public): Matches `PathPrefix('/api/public') || PathPrefix('/api/health') || PathPrefix('/api/availability') || PathPrefix('/api/services')`, strips `/api/public` or `/api` via `armonia-api-strip@docker`, and routes directly to `armonia-api:8000` without authentication.
|
- **Native Cloud DB Compatibility**: Out-of-the-box support for switching to Turso Cloud libSQL clusters via native URL normalization in `armonia-api`.
|
||||||
2. `armonia-api` (Priority `20`, Protected): Matches `PathPrefix('/api')`, enforces `authelia-auth@docker` (injecting `Remote-Email`, `Remote-User`, `Remote-Name`, and `Remote-Groups`), strips `/api`, and routes to `armonia-api:8000`.
|
- **Standardized Homelab Operations**: Managed via standard `appctl` lifecycle commands.
|
||||||
3. `armonia-dashboard` (Priority `10`, Protected): Matches `PathPrefix('/')`, enforces `authelia-auth@docker`, and serves the static Vite SPA on `armonia-dashboard:80` (with an internal Nginx `/api/` proxy fallback).
|
|
||||||
- **Decoupled Identity & JIT Role Mapping (`AUTH_PROVIDER=proxy_headers`)**:
|
---
|
||||||
- `armonia-owner` $\rightarrow$ `OWNER`
|
|
||||||
- `armonia-admin` $\rightarrow$ `ADMIN`
|
## 🏛️ High-Level Routing Overview
|
||||||
- `armonia-assistant` $\rightarrow$ `ASSISTANT`
|
|
||||||
- On state-mutating requests, `armonia-api` automatically mirrors the authenticated operator into `admin_allowlist` to preserve foreign-key integrity on `admin_audit_log`.
|
| Route Pattern | Method | Target Service | Access Level | Description |
|
||||||
|
| :--- | :--- | :--- | :--- | :--- |
|
||||||
|
| `/api/health`, `/api/availability`, `/api/services` | `GET`, `OPTIONS` | `armonia-api:8000` | **Public** | Public service catalog and real-time appointment availability. |
|
||||||
|
| `/api/bookings` | `POST`, `OPTIONS` | `armonia-api:8000` | **Public** | Client self-service appointment reservation intake with CORS preflight support. |
|
||||||
|
| `/api/*` | `ANY` | `armonia-api:8000` | **Protected** (Authelia) | Administrative operations: 48h follow-up queue, client CRM, booking lifecycle, therapy packages, and session notes. |
|
||||||
|
| `/*` | `GET` | `armonia-dashboard:80` | **Protected** (Authelia) | Mobile-first administrative Vite SPA served via Nginx. |
|
||||||
|
|
||||||
|
> Detailed routing diagrams, middleware execution order, and security boundaries are documented in [**`ARCHITECTURE.md`**](./ARCHITECTURE.md).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🗄️ Database Persistence
|
## 🗄️ Database Persistence
|
||||||
|
|
||||||
- **Active Configuration (Local SQLite Volume)**:
|
- **Active Configuration (Local SQLite Volume)**:
|
||||||
- `DATABASE_URL=file:/data/armonia.db`
|
- Database URL: `DATABASE_URL=file:/data/armonia.db`
|
||||||
- Bind-mounted from `./data:/data` (owned by UID `1000`).
|
- Host Path: `./data/armonia.db` (UID `1000:100`).
|
||||||
- Automatically initializes schema and seeds the service catalog on container startup via FastAPI lifespan (`app.db.init_db`).
|
- Automatically initializes schema and seeds the service catalog on container boot via FastAPI lifespan (`app.db.init_db`).
|
||||||
- **Turso Cloud (`armonia-db`)**:
|
- **Turso Cloud Database (`armonia-db`)**:
|
||||||
- Provisioned at `libsql://armonia-db-kiskaadee.aws-us-east-2.turso.io`.
|
- Provisioned at `libsql://armonia-db-kiskaadee.aws-us-east-2.turso.io`.
|
||||||
- Dual-driver URL normalization (`libsql_client` vs. `sqlalchemy-libsql`) is tracked in [`armonia-del-ser/armonia-api#11`](https://gitea.roadtotech.me/armonia-del-ser/armonia-api/issues/11).
|
- Dual-driver dialect normalization (`file:`, `libsql://`, `sqlite+libsql://`) is natively handled by `armonia-api/app/db/database.py` ([ADR-0001](./docs/adr/0001-homelab-sites-orchestration.md)).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🚀 Operations (`appctl`)
|
## 🚀 Operations (`appctl`)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Validate manifest & rendered Docker Compose config
|
# Validate manifest schema & rendered Docker Compose configuration
|
||||||
appctl config armonia
|
appctl config armonia
|
||||||
|
|
||||||
# Build and start containers
|
# Build images and start containers
|
||||||
appctl up armonia
|
appctl up armonia
|
||||||
|
|
||||||
# Inspect two-axis status & logs
|
# Inspect container status and health
|
||||||
appctl info armonia
|
appctl info armonia
|
||||||
|
|
||||||
|
# Follow live container logs
|
||||||
appctl logs armonia
|
appctl logs armonia
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🧭 Repository Navigation
|
||||||
|
|
||||||
|
- **[System Architecture (`ARCHITECTURE.md`)](./ARCHITECTURE.md)**: Canonical system model, component responsibilities, data flow, and security boundaries.
|
||||||
|
- **[Architectural Decision Records (`docs/adr/`)](./docs/adr/)**: Accepted decisions, trade-offs, and historical rationale ([ADR-0001: Homelab Sites Orchestration](./docs/adr/0001-homelab-sites-orchestration.md)).
|
||||||
|
- **[Agent Guidelines (`AGENTS.md`)](./AGENTS.md)**: Rules for AI agents, branch-first development, and operational validation.
|
||||||
|
- **[Parent Organization Profile (`armonia-del-ser`)](https://gitea.roadtotech.me/armonia-del-ser)**: Upstream repositories, user research interviews, and strategic product roadmap.
|
||||||
+2
-2
@@ -30,10 +30,10 @@ services:
|
|||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
|
|
||||||
# Middleware: Strip /api prefix before forwarding to FastAPI (which serves at /)
|
# Middleware: Strip /api prefix before forwarding to FastAPI (which serves at /)
|
||||||
- "traefik.http.middlewares.armonia-api-strip.stripprefix.prefixes=/api/public,/api"
|
- "traefik.http.middlewares.armonia-api-strip.stripprefix.prefixes=/api"
|
||||||
|
|
||||||
# 1. Public API & Health Router (Priority 30 — bypasses Authelia forward-auth)
|
# 1. Public API & Health Router (Priority 30 — bypasses Authelia forward-auth)
|
||||||
- "traefik.http.routers.armonia-api-public.rule=Host(`${SERVICE_DOMAIN:-armonia.roadtotech.me}`) && (PathPrefix(`/api/public`) || PathPrefix(`/api/health`) || PathPrefix(`/api/availability`) || PathPrefix(`/api/services`))"
|
- "traefik.http.routers.armonia-api-public.rule=Host(`${SERVICE_DOMAIN:-armonia.roadtotech.me}`) && (PathPrefix(`/api/health`) || PathPrefix(`/api/availability`) || (Method(`GET`, `HEAD`, `OPTIONS`) && PathPrefix(`/api/services`)) || (Method(`POST`, `OPTIONS`) && PathPrefix(`/api/bookings`)))"
|
||||||
- "traefik.http.routers.armonia-api-public.entrypoints=websecure"
|
- "traefik.http.routers.armonia-api-public.entrypoints=websecure"
|
||||||
- "traefik.http.routers.armonia-api-public.tls=true"
|
- "traefik.http.routers.armonia-api-public.tls=true"
|
||||||
- "traefik.http.routers.armonia-api-public.priority=30"
|
- "traefik.http.routers.armonia-api-public.priority=30"
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
# ADR-0001: Containerized Homelab Sites Orchestration & Dual-Router Architecture
|
||||||
|
|
||||||
|
- Status: Accepted
|
||||||
|
- Date: 2026-10-19 (Reconciled: 2026-10-24)
|
||||||
|
- Deciders: Core Engineering Team
|
||||||
|
|
||||||
|
## Context and Problem Statement
|
||||||
|
|
||||||
|
Armonía del Ser requires an operational platform uniting the FastAPI backend (`armonia-api`) and the Vite-based operator dashboard (`armonia-dashboard`). The system must be readily accessible to the business owner (Jasmin) and her assistant for hands-on operation and review, while allowing public clients to query availability and register booking requests.
|
||||||
|
|
||||||
|
We needed a deployment strategy that fits within the existing Homelab infrastructure, supports centralized Single Sign-On (SSO) with role-based access control, enables offline-tolerant local data storage, and provides a clear staging / PoC surface prior to cloud production.
|
||||||
|
|
||||||
|
## Decision Outcome
|
||||||
|
|
||||||
|
Chosen option: **Containerized Homelab Sites orchestration using Traefik dual-priority routers, Authelia ForwardAuth with LLDAP group mapping, and a local SQLite volume mount.**
|
||||||
|
|
||||||
|
Specifically:
|
||||||
|
1. **Traefik Dual-Router Architecture**:
|
||||||
|
- Router 1 (`Priority 30`): Whitelists public intake endpoints (`/api/health`, `/api/availability`, safe read methods for `/api/services`, and `POST /api/bookings` with CORS preflight `OPTIONS`) with prefix stripping (`/api`), bypassing Authelia authentication. Sensitive operations (`/api/packages`, `POST /api/services`, administrative booking and CRM actions) fall through to Router 2.
|
||||||
|
- Router 2 (`Priority 20`): Protects administrative `/api` endpoints, enforcing Authelia ForwardAuth and forwarding authenticated identity headers (`Remote-Email`, `Remote-Groups`, `Remote-Name`, `Remote-User`).
|
||||||
|
- Router 3 (`Priority 10`): Serves the dashboard Vite SPA behind Authelia ForwardAuth.
|
||||||
|
2. **Decoupled Identity via `AUTH_PROVIDER=proxy_headers`**:
|
||||||
|
The backend relies on incoming `Remote-*` headers validated by Authelia against LLDAP groups (`armonia-owner`, `armonia-admin`, `armonia-assistant`), eliminating hardcoded passwords or session storage in the containers.
|
||||||
|
3. **Local SQLite Persistence with Native Turso Dual-Driver**:
|
||||||
|
State is persisted locally in `./data/armonia.db` (UID 1000:100). The underlying FastAPI application uses `get_engine_url()` to seamlessly switch between local SQLite files and remote Turso libSQL clusters.
|
||||||
|
|
||||||
|
## Consequences
|
||||||
|
|
||||||
|
- **Positive**:
|
||||||
|
- Operators access the system using existing Homelab Single Sign-On without needing external Google OAuth configuration during staging.
|
||||||
|
- Zero cloud hosting costs during development and operational PoC testing.
|
||||||
|
- Public booking intake functions smoothly alongside protected administrative routes on a single domain (`armonia.roadtotech.me`).
|
||||||
|
- Fast local development cycle using `appctl` (`appctl config`, `appctl up`).
|
||||||
|
- **Negative**:
|
||||||
|
- The homelab instance is subject to local hardware availability and home internet connectivity.
|
||||||
|
- Public intake requires DNS routing and SSL certificates to point to the homelab reverse proxy.
|
||||||
|
|
||||||
|
## Alternatives Considered
|
||||||
|
|
||||||
|
1. **Deploying Directly to Cloud Production (Cloud Run + Cloudflare Pages + Turso Cloud)**:
|
||||||
|
- *Rejected for initial validation*: Jasmin and her assistant needed immediate hands-on access to test the UX and booking flows before provisioning Google Cloud organizations, DNS zone transfers, and Google OAuth approval.
|
||||||
|
2. **Single Unified Container (Serving Static UI and API from FastAPI)**:
|
||||||
|
- *Rejected*: Violates repository separation and complicates independent CI/CD builds for `armonia-api` and `armonia-dashboard`.
|
||||||
|
3. **Basic Authentication in Nginx**:
|
||||||
|
- *Rejected*: Fails to provide role-based distinction between owner (`OWNER`) and assistant (`ASSISTANT`) required for 2-step payment verification and clinical notes access.
|
||||||
|
|
||||||
|
## Related Decisions
|
||||||
|
|
||||||
|
- [`armonia-api` ADR-0001: Turso Edge libSQL with SQLite Fallback](https://gitea.roadtotech.me/armonia-del-ser/armonia-api)
|
||||||
|
- [`armonia-api` ADR-0005: Google OAuth & Turso Admin Allowlist](https://gitea.roadtotech.me/armonia-del-ser/armonia-api)
|
||||||
|
- [`armonia-api` ADR-0006: Mutation Testing & Decoupled Auth Adapter](https://gitea.roadtotech.me/armonia-del-ser/armonia-api)
|
||||||
Reference in new issue
Block a user