Skip to main content

πŸ”§ Backend Wiki - WorkmateOS

WorkmateOS Backend-Dokumentation

Diese Dokumentation beschreibt die Backend-Architektur, Module und APIs von WorkmateOS.


πŸ“š Dokumentations-Übersicht​

DokumentStatusBeschreibung
Authentication & SSOβœ… VollstΓ€ndigZitadel SSO, OAuth2, Role Mapping, Permissions
Admin Panelβœ… VollstΓ€ndigSystem-Administration, User/Department/Role Management
Module Übersichtβœ… VollstΓ€ndigAlle Backend-Module (CRM, Projects, Invoices, etc.)
API Reference⏳ TODOAlle REST Endpoints mit Beispielen
Datenbank Schema⏳ TODODatenbank-Modelle, Migrations, Best Practices

πŸ—οΈ Backend-Architektur​

Tech Stack​

  • Framework: FastAPI (Python 3.13)
  • ORM: SQLAlchemy 2.0
  • Database: PostgreSQL 16
  • Migrations: Alembic
  • Authentication: Zitadel (OAuth2/OIDC)
  • API Docs: Swagger/OpenAPI

Verzeichnis-Struktur​

backend/
β”œβ”€β”€ app/
β”‚ β”œβ”€β”€ core/ # Core-FunktionalitΓ€t
β”‚ β”‚ β”œβ”€β”€ auth/ # Authentication (Zitadel, Roles)
β”‚ β”‚ β”œβ”€β”€ audit/ # Audit Logging
β”‚ β”‚ └── settings/ # Config, Database
β”‚ β”‚
β”‚ β”œβ”€β”€ modules/ # Business-Module
β”‚ β”‚ β”œβ”€β”€ employees/ # Mitarbeiter-Verwaltung
β”‚ β”‚ β”œβ”€β”€ documents/ # Dokumenten-Management
β”‚ β”‚ β”œβ”€β”€ reminders/ # Erinnerungen
β”‚ β”‚ β”œβ”€β”€ dashboards/ # Dashboard-Daten
β”‚ β”‚ β”œβ”€β”€ system/ # System-Services
β”‚ β”‚ └── backoffice/ # Backoffice-Module
β”‚ β”‚ β”œβ”€β”€ crm/ # Customer Relationship
β”‚ β”‚ β”œβ”€β”€ projects/ # Projekt-Management
β”‚ β”‚ β”œβ”€β”€ invoices/ # Rechnungswesen
β”‚ β”‚ β”œβ”€β”€ finance/ # Ausgaben
β”‚ β”‚ β”œβ”€β”€ time_tracking/ # Zeiterfassung
β”‚ β”‚ └── chat/ # Messaging
β”‚ β”‚
β”‚ β”œβ”€β”€ models.py # Model-Exporte (fΓΌr Alembic)
β”‚ └── main.py # FastAPI-App
β”‚
β”œβ”€β”€ alembic/ # Database Migrations
β”œβ”€β”€ tests/ # Unit & Integration Tests
└── requirements.txt # Python Dependencies

πŸ” Authentication​

WorkmateOS nutzt Zitadel als Identity Provider mit OAuth2/OIDC.

VollstΓ€ndige Dokumentation: β†’ AUTHENTICATION.md

Quick Start:

  • SSO-Login ΓΌber Zitadel
  • Role-based Access Control (RBAC)
  • Wildcard Permissions (*, backoffice.*)
  • Automatisches Employee Onboarding

πŸ“¦ Module​

Core-Module​

ModulBeschreibungDokumentation
EmployeesMitarbeiter, Abteilungen, RollenADMIN_PANEL.md / MODULE_UEBERSICHT.md
DocumentsDokumenten-Upload & ManagementMODULE_UEBERSICHT.md
RemindersErinnerungen & BenachrichtigungenMODULE_UEBERSICHT.md
DashboardsDashboard-KonfigurationMODULE_UEBERSICHT.md
SystemInfrastruktur-ServicesMODULE_UEBERSICHT.md

Backoffice-Module​

ModulBeschreibungDokumentation
CRMKunden & KontakteMODULE_UEBERSICHT.md
ProjectsProjekt-ManagementMODULE_UEBERSICHT.md
InvoicesRechnungserstellungFinance DE / Finance EN
FinanceAusgaben-ManagementFinance DE / Finance EN
Time TrackingZeiterfassungMODULE_UEBERSICHT.md
ChatMessaging-SystemMODULE_UEBERSICHT.md

🌐 API-Struktur​

Alle Module folgen einer konsistenten API-Struktur:

/api/{module}/
β”œβ”€β”€ GET / # List (mit Pagination & Filtern)
β”œβ”€β”€ POST / # Create
β”œβ”€β”€ GET /{id} # Read
β”œβ”€β”€ PUT /{id} # Update
β”œβ”€β”€ DELETE /{id} # Delete
└── ... (custom endpoints)

Beispiel - CRM:

GET    /api/customers               # Liste aller Kunden
POST /api/customers # Neuen Kunden anlegen
GET /api/customers/{id} # Kunden abrufen
PUT /api/customers/{id} # Kunden bearbeiten
DELETE /api/customers/{id} # Kunden lΓΆschen
GET /api/customers/{id}/contacts # Kontakte eines Kunden

πŸ—„οΈ Datenbank​

Schema-Design​

Migrations​

Migrations werden mit Alembic verwaltet:

# Create migration
alembic revision --autogenerate -m "Add new table"

# Run migrations
alembic upgrade head

# Rollback
alembic downgrade -1

Dokumentation: ⏳ TODO - DATABASE.md


πŸ” API-Dokumentation​

Swagger UI​

Entwicklung: http://localhost:8000/docs Production: https://api.workmate.kit-it-koblenz.de/docs

Authentifizierung in Swagger​

  1. Klicke auf "Authorize" πŸ”“
  2. Gib Access Token ein: Bearer {your_token}
  3. Klicke "Authorize"
  4. API-Calls werden automatisch authentifiziert

πŸ§ͺ Testing​

Test-Framework: Pytest

# Run all tests
pytest

# Run with coverage
pytest --cov=app tests/

# Run specific test
pytest tests/test_auth.py::test_login

Dokumentation: ⏳ TODO - TESTING.md


πŸš€ Development​

Setup​

# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows

# Install dependencies
pip install -r requirements.txt

# Run migrations
alembic upgrade head

# Start dev server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

Code-Struktur pro Modul​

Jedes Modul folgt diesem Pattern:

module_name/
β”œβ”€β”€ __init__.py # Exports
β”œβ”€β”€ models.py # SQLAlchemy Models
β”œβ”€β”€ schemas.py # Pydantic Schemas (Request/Response)
β”œβ”€β”€ crud.py # Database Operations
β”œβ”€β”€ routes.py # FastAPI Endpoints
└── README.md (optional) # Modul-Dokumentation

πŸ“Š Performance & Monitoring​

Logging​

WorkmateOS nutzt Python's logging mit strukturiertem Logging:

import logging

logger = logging.getLogger(__name__)

logger.info("User logged in", extra={"user_id": user.id, "email": user.email})
logger.error("Database error", exc_info=True)

Metrics (TODO)​

  • Prometheus fΓΌr Metriken
  • Grafana fΓΌr Dashboards
  • Sentry fΓΌr Error Tracking

πŸ”’ Sicherheit​

Best Practices​

  • βœ… HTTPS only in Production
  • βœ… JWT Token Validation bei jedem Request
  • βœ… Role-based Access Control (RBAC)
  • βœ… SQL Injection Prevention durch SQLAlchemy ORM
  • βœ… CORS konfiguriert fΓΌr Frontend-Domain
  • ⏳ Rate Limiting (TODO)
  • ⏳ Input Validation mit Pydantic

Dokumentation: ⏳ TODO - SICHERHEIT.md


πŸ“ BeitrΓ€ge zur Dokumentation​

Diese Dokumentation lebt! Wenn du etwas hinzufΓΌgst:

  1. Halte dich an die bestehende Struktur
  2. FΓΌge Code-Beispiele hinzu
  3. Aktualisiere den Changelog am Ende
  4. Verlinke auf verwandte Dokumente


Letzte Aktualisierung: 30. Dezember 2025 Maintainer: K.I.T Solutions Team