# liqd/adhocracy-plus architecture

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

- Interactive diagram: https://gitdiagram.com/liqd/adhocracy-plus
- Repository: https://github.com/liqd/adhocracy-plus

## Overview

##### Main Components

a) Frontend Layer:
- React Components (in /apps/*/assets/)
- Static Assets (SCSS, images, fonts)
- Templates (Django templates in /apps/*/templates/)

b) Backend Layer:
- Django Applications:
- Core Apps: account, users, organisations
- Feature Apps: ideas, debates, documents, polls, etc.
- Support Apps: notifications, exports, dashboard
- REST API Endpoints
- Authentication/Authorization System

c) Data Layer:
- Database (PostgreSQL/SQLite)
- Redis (for Celery task queue)
- Media Storage

d) Background Processing:
- Celery Workers
- Task Queue System

##### Key Relationships to Highlight

a) User Flow:
- Authentication flow
- Organization management
- Project participation
- Content creation/interaction

b) Data Flow:
- API communications
- Background task processing
- Media handling
- Export functionality

##### Architectural Patterns to Emphasize

a) Django's MVT (Model-View-Template) Architecture:
- Models (/apps/*/models.py)
- Views (/apps/*/views.py)
- Templates (/apps/*/templates/)

b) REST API Architecture:
- Serializers
- ViewSets
- Routers

##### Component Details

a) Frontend Section:
- [React Components] → [Django Templates] → [Static Assets]
- ↓                     ↓
- [Browser Interface] ← [Asset Pipeline]

b) Backend Section:
- [Django Apps] → [URL Routing] → [Views/ViewSets]
- ↓              ↓              ↓
- [Authentication] → [Permissions] → [Models]

c) Data Storage:
- [PostgreSQL/SQLite] ← [Models] → [Cache (Redis)]
- ↓                 ↓            ↓
- [Media Files] ← [File Handlers] → [Task Queue]

##### Important Subsystems

- Email notification system
- Export functionality
- Moderation system
- Multi-language support
- Organization management
- Project management

##### Notes

Annotations for:
- Security implementations
- Scalability points
- Integration points
- Configuration options

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        RC["React Components"]:::frontend
        SA["Static Assets"]:::frontend
        DT["Django Templates"]:::frontend
        BI["Browser Interface"]:::frontend
        AP["Asset Pipeline"]:::frontend
    end

    subgraph Backend
        subgraph CoreApps
            ACC["Account Management"]:::core
            USR["User Management"]:::core
            ORG["Organizations"]:::core
            PRJ["Projects"]:::core
        end

        subgraph FeatureApps
            IDEAS["Ideas Module"]:::feature
            DBT["Debates"]:::feature
            DOCS["Documents"]:::feature
            POLLS["Polls"]:::feature
            MAPS["Maps"]:::feature
            EVENTS["Interactive Events"]:::feature
        end

        subgraph SupportSystems
            NOTIF["Notifications"]:::support
            DASH["Dashboard"]:::support
            UDASH["User Dashboard"]:::support
            EXP["Exports"]:::support
        end

        subgraph CMS
            PAGES["Pages"]:::cms
            NEWS["News"]:::cms
            CONTACT["Contact Forms"]:::cms
        end

        subgraph API
            ENDPOINTS["API Endpoints"]:::api
            SERIAL["Serializers"]:::api
            ROUTE["Routers"]:::api
        end
    end

    subgraph DataStorage
        DB[(Database)]:::storage
        REDIS[(Redis Cache)]:::storage
        MEDIA[(Media Storage)]:::storage
    end

    subgraph BackgroundProcessing
        CELERY[("Celery Workers")]:::process
        QUEUE[("Task Queue")]:::process
    end

    %% Frontend Relationships
    RC --> BI
    SA --> AP
    DT --> BI
    AP --> BI

    %% Backend to Frontend
    CoreApps --> API
    FeatureApps --> API
    SupportSystems --> API
    API --> BI

    %% Data Relationships
    CoreApps --> DB
    FeatureApps --> DB
    SupportSystems --> DB
    CMS --> DB
    REDIS --> CELERY
    CELERY --> QUEUE
    QUEUE --> NOTIF

    %% Media Handling
    FeatureApps --> MEDIA
    CMS --> MEDIA

    %% Click Events
    click RC "https://github.com/liqd/adhocracy-plus/blob/main/apps/*/assets/*.jsx"
    click SA "https://github.com/liqd/adhocracy-plus/tree/main/adhocracy-plus/assets/"
    click DT "https://github.com/liqd/adhocracy-plus/tree/main/adhocracy-plus/templates/"
    click ACC "https://github.com/liqd/adhocracy-plus/tree/main/apps/account/"
    click USR "https://github.com/liqd/adhocracy-plus/tree/main/apps/users/"
    click ORG "https://github.com/liqd/adhocracy-plus/tree/main/apps/organisations/"
    click PRJ "https://github.com/liqd/adhocracy-plus/tree/main/apps/projects/"
    click IDEAS "https://github.com/liqd/adhocracy-plus/tree/main/apps/ideas/"
    click DBT "https://github.com/liqd/adhocracy-plus/tree/main/apps/debate/"
    click DOCS "https://github.com/liqd/adhocracy-plus/tree/main/apps/documents/"
    click POLLS "https://github.com/liqd/adhocracy-plus/tree/main/apps/polls/"
    click MAPS "https://github.com/liqd/adhocracy-plus/tree/main/apps/maps/"
    click EVENTS "https://github.com/liqd/adhocracy-plus/tree/main/apps/interactiveevents/"
    click NOTIF "https://github.com/liqd/adhocracy-plus/tree/main/apps/notifications/"
    click DASH "https://github.com/liqd/adhocracy-plus/tree/main/apps/dashboard/"
    click UDASH "https://github.com/liqd/adhocracy-plus/tree/main/apps/userdashboard/"
    click EXP "https://github.com/liqd/adhocracy-plus/tree/main/apps/exports/"
    click PAGES "https://github.com/liqd/adhocracy-plus/tree/main/apps/cms/pages/"
    click NEWS "https://github.com/liqd/adhocracy-plus/tree/main/apps/cms/news/"
    click CONTACT "https://github.com/liqd/adhocracy-plus/tree/main/apps/cms/contacts/"
    click ENDPOINTS "https://github.com/liqd/adhocracy-plus/blob/main/apps/*/api.py"
    click SERIAL "https://github.com/liqd/adhocracy-plus/blob/main/apps/*/serializers.py"
    click ROUTE "https://github.com/liqd/adhocracy-plus/blob/main/apps/routers.py"
    click MEDIA "https://github.com/liqd/adhocracy-plus/tree/main/media/"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef feature fill:#e74c3c,stroke:#c0392b,color:white
    classDef support fill:#9b59b6,stroke:#8e44ad,color:white
    classDef cms fill:#f1c40f,stroke:#f39c12,color:black
    classDef api fill:#1abc9c,stroke:#16a085,color:white
    classDef storage fill:#34495e,stroke:#2c3e50,color:white
    classDef process fill:#e67e22,stroke:#d35400,color:white
```
