# bihealth/digestiflow-docker-compose architecture

> Architecture diagram of the GitHub repository bihealth/digestiflow-docker-compose, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bihealth/digestiflow-docker-compose
- Repository: https://github.com/bihealth/digestiflow-docker-compose

## Overview

##### Main Components
- Docker Host – the server environment that will run this entire containerized stack.
- Docker Compose – the orchestration layer defined in docker-compose.yml and various override files.
- Digestiflow Server Application:
- Web Service (digestiflow-web) – handles HTTP requests, likely via Django’s WSGI interface.
- Celery Workers (digestiflow-celerybeat and digestiflow-celeryd-default) – run background tasks and scheduled jobs.
- Supporting Infrastructure:
- PostgreSQL Database – container running a Postgres instance.
- Redis – container for caching or queue management.
- Reverse Proxy (Traefik) – containerized Traefik to route incoming HTTP/HTTPS requests to the appropriate services. Also note that configuration of Traefik (using its config files and TLS settings) is supported through the config directory.

##### Relationships and Interactions
- Incoming web traffic is handled by Traefik, which listens on ports 80 and 443.
- Traefik routes requests to the appropriate Digestiflow service (web, celery, etc.).
- The web service communicates with PostgreSQL for database operations.
- The web service and workers may interact with Redis for caching or message queuing.
- The init.sh script is responsible for initializing volumes (for persistent storage for Postgres, Redis, and Traefik data).
- The various docker-compose override files (like for lets-encrypt, provided certificates, or SSSD-specific configurations) indicate different production or testing environments that modify how certificates and authentication are handled.

##### Architectural Patterns and Design Principles
- Containerized Microservices – Even though it is orchestrated with Docker Compose (not separate microservices in production), the design encapsulates each major system component in its own container.
- Separation of Concerns – The use of separate containers for web, background tasks, database, caching, and proxying highlights clean separation.
- Configuration via Mounts/Overrides – The existence of multiple configuration files (for Traefik, SSSD, etc.) shows an emphasis on flexible deployment configurations and environment-specific setups.

##### Relevant Technologies
- Docker & Docker Compose – For containerization and orchestration.
- Traefik – Acting as a load balancer and reverse proxy for TLS/SSL handling.
- Django – Inferred from the management command for creating a superuser and the Django Admin instructions.
- Celery – For asynchronous task processing.
- PostgreSQL and Redis – As major storage and caching components.
- Shell scripts (init.sh) for volume setup, and Makefile for release/tag management.

##### Keeping Detailed Yet Manageable
- Although the repository is primarily Docker Compose-based, emphasize the role of configuration files in customizing production behavior (e.g., the different docker-compose.override.yml files).

## Diagram (Mermaid)

```mermaid
graph TD
    %% External Traffic
    Internet["Internet Traffic"]:::external

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        DockerHost["Docker Host / Volumes"]:::infra
        DockerCompose["Docker Compose (docker-compose.yml & overrides)"]:::orchestration
    end

    %% Ingress Layer
    subgraph "Ingress Layer"
        Traefik["Traefik Reverse Proxy"]:::proxy
        ConfigTraefik["Traefik Configuration"]:::config
    end

    %% Application Layer
    subgraph "Application Layer"
        WebService["Digestiflow Web Service (Django)"]:::app
        CeleryBeat["Celery Worker: celerybeat"]:::worker
        CeleryDefault["Celery Worker: celeryd-default"]:::worker
    end

    %% Data Stores
    subgraph "Data Stores"
        PostgreSQL["PostgreSQL Database"]:::database
        Redis["Redis Cache"]:::cache
    end

    %% Configuration & Initialization
    subgraph "Configuration & Initialization"
        InitScript["Initialization Script (init.sh)"]:::init
        ConfigSSSD["SSSD Configuration"]:::config
    end

    %% Connections
    Internet -->|"incoming"| Traefik
    DockerHost --> DockerCompose
    DockerCompose --> Traefik
    DockerCompose --> WebService
    DockerCompose --> CeleryBeat
    DockerCompose --> CeleryDefault
    DockerCompose --> PostgreSQL
    DockerCompose --> Redis

    Traefik -->|"routes"| WebService

    WebService <-->|"db_communication"| PostgreSQL
    WebService -->|"caching_queues"| Redis
    WebService -->|"dispatch_tasks"| CeleryBeat
    WebService -->|"dispatch_tasks"| CeleryDefault

    CeleryBeat -->|"uses_queue"| Redis
    CeleryDefault -->|"uses_queue"| Redis

    ConfigTraefik -.-> Traefik
    ConfigSSSD -.-> DockerCompose
    InitScript -.-> DockerHost

    %% Click Events
    click DockerCompose "https://github.com/bihealth/digestiflow-docker-compose/blob/main/docker-compose.yml"
    click ConfigTraefik "https://github.com/bihealth/digestiflow-docker-compose/tree/main/config/traefik"
    click ConfigSSSD "https://github.com/bihealth/digestiflow-docker-compose/tree/main/config/sssd"
    click InitScript "https://github.com/bihealth/digestiflow-docker-compose/blob/main/init.sh"

    %% Classes
    classDef external fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef infra fill:#cccccc,stroke:#333,stroke-width:2px;
    classDef orchestration fill:#c5f7c3,stroke:#333,stroke-width:2px;
    classDef proxy fill:#ffe0e0,stroke:#333,stroke-width:2px;
    classDef config fill:#e0e0ff,stroke:#333,stroke-width:2px;
    classDef app fill:#d0e8f2,stroke:#333,stroke-width:2px;
    classDef worker fill:#d0f2d0,stroke:#333,stroke-width:2px;
    classDef database fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef cache fill:#fadbd8,stroke:#333,stroke-width:2px;
    classDef init fill:#fcf3cf,stroke:#333,stroke-width:2px;
```
