# thetatau/cmt architecture

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

- Interactive diagram: https://gitdiagram.com/thetatau/cmt
- Repository: https://github.com/thetatau/cmt

## Overview

##### Main components
- Client / Browser – represents the end users accessing the web application.
- Web Application (Backend) – a Django application broken into modular apps:
- thetatauCMT (handles the core chapter management functionalities, including chapters, ballots, events, finances, forms, submissions, surveys, tasks, notes, etc.)
- anonymizer and core – provide supporting functionality.
- OpenEdX (integration module) and others.
- Database – typically PostgreSQL managed in a container as suggested by configuration in the .envs and compose/production/postgres.
- Async Task Processor – include a celery worker component (the project shows a taskapp module and tasks folder).
- Static and Template Assets – while served by Django in many cases, clearly delineate the frontend components handled via the templates, static files (CSS, JS, images) and SASS compilation.
- Deployment/Infrastructure – represent Docker containers (with docker-compose for local and production), as well as environment-specific configurations (compose/local vs. compose/production).

##### Relationships and interactions
- Connection between Django and the celery worker, which processes asynchronous tasks (such as background emails, notifications, and maintenance commands).
- Static file serving (for CSS, JS, images) over the network or via a CDN if that feature is used in production.
- Integration of third-party services or any external dependency like email services, if relevant from configuration and testing instructions.

##### Architectural patterns
- Modular design of the Django project – distinct apps (organized under thetatauCMT, core, anonymizer, etc.) each handling specific business logic.
- Point out the separation of development environments using Docker Compose with different configurations for local vs. production.
- Reverse proxy (Traefik) as an external edge service that manages routing and TLS termination.
- Use of environment-specific settings (with the config/settings directory containing base, local, production, etc.) which enforce a layered configuration model.

##### Specify relevant technologies and frameworks
- Django (with Cookiecutter Django as the starter) as the web framework.
- PostgreSQL for the database.
- Docker/Docker Compose for containerization and deployment.
- Traefik as the reverse proxy.
- Celery (with thetatauCMT/taskapp/celery) for asynchronous task processing.
- Sass and live reload tooling for the frontend styling (as noted in the README’s live-reloading section).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Components
    A["Client/Browser"]:::client
    B["Traefik Reverse Proxy (Docker Container)"]:::traefik
    C["Django Web Application (Docker Container)"]:::django
    D["PostgreSQL Database (Docker Container)"]:::database
    E["Celery Worker (Async Task Processor)"]:::celery
    F["Deployment/Infrastructure & Env Configs"]:::deploy

    %% Flow connections
    A -->|"sends request"| B
    B -->|"forwards request"| C
    C -->|"read/write data"| D
    C -->|"executes background tasks"| E
    C -->|"managed by"| F

    %% Django internal components subgraph
    subgraph "Django Components"
        direction TB
        C1["Dev Docker Config"]:::django
        C2["Prod Docker Config"]:::django
        C3["Django Settings"]:::django
        subgraph "Modular Apps"
            direction TB
            C4["thetatauCMT"]:::modular
            C5["anonymizer"]:::modular
            C6["core"]:::modular
            C7["OpenEdX"]:::modular
        end
        C8["Static & Template Assets"]:::django
    end

    %% Connections inside Django container
    C --- C1
    C --- C2
    C --- C3
    C --- C8
    C3 --- C4
    C3 --- C5
    C3 --- C6
    C3 --- C7

    %% Click Events for Traefik Reverse Proxy
    click B "https://github.com/thetatau/cmt/blob/main/compose/production/traefik/traefik.yml"
    click B "https://github.com/thetatau/cmt/tree/main/compose/production/traefik/Dockerfile"

    %% Click Events for Django Web Application - Dev Config
    click C1 "https://github.com/thetatau/cmt/tree/main/compose/local/django/Dockerfile"
    click C1 "https://github.com/thetatau/cmt/tree/main/compose/local/django/start"

    %% Click Events for Django Web Application - Prod Config
    click C2 "https://github.com/thetatau/cmt/tree/main/compose/production/django/Dockerfile"
    click C2 "https://github.com/thetatau/cmt/tree/main/compose/production/django/entrypoint"
    click C2 "https://github.com/thetatau/cmt/tree/main/compose/production/django/start"

    %% Click Events for Django Settings
    click C3 "https://github.com/thetatau/cmt/blob/main/config/settings/base.py"
    click C3 "https://github.com/thetatau/cmt/blob/main/config/settings/local.py"
    click C3 "https://github.com/thetatau/cmt/blob/main/config/settings/production.py"
    click C3 "https://github.com/thetatau/cmt/blob/main/config/settings/staging.py"

    %% Click Events for Modular Apps
    click C4 "https://github.com/thetatau/cmt/tree/main/thetatauCMT/"
    click C5 "https://github.com/thetatau/cmt/tree/main/anonymizer/"
    click C6 "https://github.com/thetatau/cmt/tree/main/core/"
    click C7 "https://github.com/thetatau/cmt/tree/main/OpenEdX/"

    %% Click Events for Static & Template Assets
    click C8 "https://github.com/thetatau/cmt/tree/main/thetatauCMT/templates/"
    click C8 "https://github.com/thetatau/cmt/tree/main/thetatauCMT/static/"

    %% Click Events for PostgreSQL Database
    click D "https://github.com/thetatau/cmt/tree/main/compose/production/postgres/"

    %% Click Events for Celery Worker
    click E "https://github.com/thetatau/cmt/blob/main/thetatauCMT/taskapp/celery.py"
    click E "https://github.com/thetatau/cmt/tree/main/thetatauCMT/tasks/"

    %% Click Events for Deployment/Infrastructure
    click F "https://github.com/thetatau/cmt/blob/main/docker-compose.yml"
    click F "https://github.com/thetatau/cmt/blob/main/docker-compose.local.yml"
    click F "https://github.com/thetatau/cmt/tree/main/.envs/"

    %% Styles
    classDef client fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    classDef traefik fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef django fill:#a9dfbf,stroke:#196f3d,stroke-width:2px;
    classDef database fill:#f5b7b1,stroke:#943126,stroke-width:2px;
    classDef celery fill:#f9c2c0,stroke:#c0392b,stroke-width:2px;
    classDef deploy fill:#d2b4de,stroke:#6c3483,stroke-width:2px;
    classDef modular fill:#f7dc6f,stroke:#b7950b,stroke-width:2px;
```
