# fsinfuhh/mafiasi architecture

> Architecture diagram of the GitHub repository fsinfuhh/mafiasi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fsinfuhh/mafiasi
- Repository: https://github.com/fsinfuhh/mafiasi

## Overview

##### Main Components
- Web Server & Container Infrastructure:
- A Docker container (or set of containers) which includes Nginx (as configured in docker/nginx.conf) acting as a reverse proxy.
- uWSGI (configured via docker/uwsgi.ini) managed via Supervisor (docker/supervisor.conf) to run the Django application.
- Django Application:
- Middleware components, URL routing (mafiasi/urls.py and app-level urls.py), and migrations (as evident from many 000*_initial.py files) that form the application core.
- Database:
- A PostgreSQL database that is started using scripts (start_dev_db.sh, scripts/start_db.sh) and serves as the persisting data store.
- External Integrations and Services:
- Where applicable, integrations such as LDAP (optional in development), external mail systems, and potentially other services (like nextcloud, mattermost, wiki, etc.) that are encapsulated in their respective Django apps.
- CI/CD & Deployment Configurations:
- GitHub workflows (.github/workflows) for deployment and testing.
- Dockerfile and additional deployment files (kustomization for Kubernetes) that illustrate how the application is containerized and deployed.

##### Relationships and Data Flow
- Optionally, show CI/CD pipelines (from GitHub to Docker/Deployment) as a side component, indicating that automated tests and deployments are part of the architecture.

##### Architectural Patterns and Design Principles
- Use of a layered architecture typical in Django projects:
- Presentation Layer: Templates and static assets (served via Nginx and the Django templating system).
- Business Logic Layer: Modular Django apps, each handling specific functionality (for example, registration, dashboard, etc.).
- Data Layer: Managed via Django ORM connecting to a persistent PostgreSQL database.
- Separation of concerns as Apache/Nginx is used purely for request routing and static asset serving, while uWSGI runs the Django application.
- Mention the use of containerization (Docker) and orchestration (Kubernetes with kustomizations) which encapsulate this separation further.

##### Relevant Technologies and Tooling
- Python/Django (core framework)
- uWSGI (application server)
- Nginx (web server/reverse proxy)
- PostgreSQL (database)
- Docker (containerization)
- GitHub Actions (CI/CD workflows)
- Pipenv for dependency management
- Deployment orchestration via Kubernetes (via kustomize)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Client["Client/Browser"]:::client

    %% Infrastructure Layer
    Nginx["Nginx Reverse Proxy"]:::container
    uWSGI["uWSGI Application Server"]:::container
    Supervisor["Process Manager (Supervisor)"]:::container
    Docker["Docker Containerization"]:::container

    %% Application Layer
    Django["Django Application"]:::django
    subgraph "Mafiasi Django Apps"
        Dashboard["Dashboard"]:::django
        Etherpad["Etherpad"]:::django
        Groups["Groups"]:::django
        Registration["Registration"]:::django
        Teaching["Teaching"]:::django
    end

    %% Data Layer
    DB["PostgreSQL Database"]:::database

    %% CI/CD Layer
    CICD["CI/CD Workflows"]:::cicd

    %% Connections
    Client -->|"HTTP_Request"| Nginx
    Nginx -->|"forwards_to"| uWSGI
    uWSGI -->|"runs"| Django
    Supervisor -- "manages" --> uWSGI
    Django -->|"queries"| DB

    %% Internal Django Modules Connections (optional view)
    Django --> Dashboard
    Django --> Etherpad
    Django --> Groups
    Django --> Registration
    Django --> Teaching

    %% Deployment Pipeline
    CICD -->|"builds_and_deploys"| Docker
    Docker --> Nginx
    Docker --> uWSGI
    Docker --> Supervisor

    %% Click Events
    click Nginx "https://github.com/fsinfuhh/mafiasi/blob/master/docker/nginx.conf"
    click uWSGI "https://github.com/fsinfuhh/mafiasi/blob/master/docker/uwsgi.ini"
    click Supervisor "https://github.com/fsinfuhh/mafiasi/blob/master/docker/supervisor.conf"
    click Docker "https://github.com/fsinfuhh/mafiasi/tree/master/Dockerfile"
    click Django "https://github.com/fsinfuhh/mafiasi/tree/master/mafiasi/"
    click Dashboard "https://github.com/fsinfuhh/mafiasi/tree/master/mafiasi/dashboard/"
    click Etherpad "https://github.com/fsinfuhh/mafiasi/tree/master/mafiasi/etherpad/"
    click Groups "https://github.com/fsinfuhh/mafiasi/tree/master/mafiasi/groups/"
    click Registration "https://github.com/fsinfuhh/mafiasi/tree/master/mafiasi/registration/"
    click Teaching "https://github.com/fsinfuhh/mafiasi/tree/master/mafiasi/teaching/"
    click DB "https://github.com/fsinfuhh/mafiasi/blob/master/scripts/start_db.sh"
    click CICD "https://github.com/fsinfuhh/mafiasi/tree/master/.github/workflows/"

    %% Styles
    classDef client fill:#FCE94F,stroke:#555,stroke-width:2px;
    classDef container fill:#729FCF,stroke:#555,stroke-width:2px;
    classDef django fill:#8AE234,stroke:#555,stroke-width:2px;
    classDef database fill:#E9B96E,stroke:#555,stroke-width:2px;
    classDef cicd fill:#AD7FA8,stroke:#555,stroke-width:2px;
```
