# opensourcepolitics/decidim-app architecture

> Architecture diagram of the GitHub repository opensourcepolitics/decidim-app, 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/opensourcepolitics/decidim-app
- Repository: https://github.com/opensourcepolitics/decidim-app

## Overview

This project is a full‐stack, modular Ruby on Rails application built on top of Decidim – a platform for citizen participation. In our case, the “Decidim app by OSP” bundles the core Decidim functionalities (like proposal submissions, citizen initiatives, conferences, etc.) and integrates many additional modules (both official and custom extensions) that extend or override default behaviors. The purpose here is to support a scalable, secure, and extensible digital platform for participatory democracy.

##### And list the main components
- Application Core: The primary Ruby on Rails application including the “app” directory (controllers, models, views, channels, mailers, jobs, etc.).
- Modules/Extensions: Decidim core modules (decidim-core, decidim-conferences, decidim-initiatives, decidim-templates, etc.) as well as community modules (e.g., module for friendly signup, phone authorization, custom proposal states, etc.). Also note the “lib/decidim” and “lib/extends” directories which contain custom overrides and integration logic.
- Database: The relational database backing the application (with many migrations in the “db/migrate” directory).
- Background Job Processor: Components like Sidekiq (configured in initializers and jobs) that handle asynchronous processing.
- Frontend Assets & Webpack: The “packages”, “public”, and asset management configuration – representing the client-side code running in the browser.
- Deployment & Infrastructure: Dockerfiles, docker-compose files, deploy configuration (Terraform files in deploy/providers) and Kubernetes (evident from the “lib/decidim_app/k8s” directory) illustrate containerization and orchestration.
- External Services/Integrations: External authentication via OmniAuth (with providers such as cultuur_connect, france_connect, etc.), caching, and other integrations like spam detection and phone verification.

##### Establish Relationships and Interactions
- User Interaction Layer: Start with the user client (browser or mobile) interacting via a web interface. This flows through load balancers (if depicted) into the application servers.
- Rails Controllers and REST/API Endpoints: Illustrate how UI requests hit controllers, which interact with models (business logic) and perform validations according to the Decidim architecture.
- Deployment & DevOps: Create a “Deployment” layer showing Docker containers, orchestration via Kubernetes, CI/CD pipelines (as evidenced by .github/workflows and Makefile), and infrastructure management (Terraform files under deploy/providers).

##### Architectural Patterns and Design Principles
- Modular Architecture: Very strong emphasis on separation of concerns and modularity. Each Decidim module (or extension thereof) is encapsulated, demonstrating plug-in architecture.
- MVC Pattern: The typical Rails MVC structure is present, so clearly label controllers, models, and views.
- Micro-modules / Overloads: The “lib/extends” and “app/overrides” directories represent how the system is made extensible through overloads and customizations.
- Containerization & Deployment Automation: Docker containers and Kubernetes orchestration should be detailed to show the deployment workflow.
- Integration with external services and APIs: Represent integrations (e.g. OmniAuth, SMS gateways, caching or external translation services).

##### Technologies, Frameworks, and Libraries
- Ruby on Rails (MVC framework)
- Sidekiq (background job processing)
- PostgreSQL (or similar relational DB)
- Webpack (asset bundling and management)
- Docker and docker-compose (containerization)
- Kubernetes toolchain (via commands in lib/decidim_app/k8s)
- CI/CD tools (GitHub Actions workflows, Makefile)
- OmniAuth for authentication

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        UB("User Browser"):::client
        LB("Load Balancer/Reverse Proxy"):::infrastructure
        UB -->|"HTTP"| LB
    end

    %% Application Layer
    subgraph "Application Layer"
        RA("Rails Application Core"):::backend
        CTR("Controllers"):::backend
        MOD("Models"):::backend
        VWS("Views"):::backend
        RA --> CTR
        RA --> MOD
        RA --> VWS
    end

    %% Modules/Extensions
    subgraph "Modules/Extensions"
        DC("Decidim Core Modules"):::module
        OV("Overrides"):::module
        CE("Custom Extensions"):::module
        DC -.->|"extends"| RA
        OV -.->|"overrides"| RA
        CE -.->|"custom logic"| RA
    end

    %% Background Processing
    subgraph "Background Processing"
        BJ("Background Jobs Processor"):::job
    end

    %% Database
    DB("Database"):::database

    %% Frontend Assets
    subgraph "Frontend Assets"
        FE("Frontend Assets & Webpack"):::frontend
    end

    %% Deployment & Infrastructure
    subgraph "Deployment & Infrastructure"
        DCk("Docker & Compose"):::deploy
        K8s("Kubernetes & Providers"):::deploy
        CI("CI/CD Pipelines"):::deploy
        DCk -->|"orchestrates"| K8s
        DCk -->|"triggers"| CI
    end

    %% External Services/Integrations
    ES("External Integrations"):::external

    %% Connections
    LB -->|"HTTP request"| RA
    RA -->|"Database Query"| DB
    RA -->|"Async Dispatch"| BJ
    BJ -->|"Job Processing"| DB
    RA -->|"Module Call"| DC
    RA -->|"Module Call"| OV
    RA -->|"Module Call"| CE
    UB -->|"Loads Assets"| FE
    RA -->|"Calls External API"| ES
    ES -->|"Responds"| RA

    %% Click Events
    click RA "https://github.com/opensourcepolitics/decidim-app/tree/develop/app"
    click DC "https://github.com/opensourcepolitics/decidim-app/tree/develop/lib/decidim"
    click OV "https://github.com/opensourcepolitics/decidim-app/tree/develop/app/overrides"
    click CE "https://github.com/opensourcepolitics/decidim-app/tree/develop/lib/extends"
    click DB "https://github.com/opensourcepolitics/decidim-app/tree/develop/db"
    click BJ "https://github.com/opensourcepolitics/decidim-app/tree/develop/app/jobs"
    click BJ "https://github.com/opensourcepolitics/decidim-app/blob/develop/config/initializers/sidekiq.rb"
    click FE "https://github.com/opensourcepolitics/decidim-app/tree/develop/app/packs"
    click FE "https://github.com/opensourcepolitics/decidim-app/tree/develop/public"
    click FE "https://github.com/opensourcepolitics/decidim-app/tree/develop/packages"
    click DCk "https://github.com/opensourcepolitics/decidim-app/tree/develop/Dockerfile"
    click DCk "https://github.com/opensourcepolitics/decidim-app/blob/develop/docker-compose.yml"
    click K8s "https://github.com/opensourcepolitics/decidim-app/tree/develop/deploy/providers"
    click K8s "https://github.com/opensourcepolitics/decidim-app/tree/develop/lib/decidim_app/k8s"
    click ES "https://github.com/opensourcepolitics/decidim-app/blob/develop/config/initializers/omniauth.rb"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#ccf,stroke:#333,stroke-width:2px;
    classDef backend fill:#cfc,stroke:#333,stroke-width:2px;
    classDef module fill:#fc9,stroke:#333,stroke-width:2px;
    classDef job fill:#cff,stroke:#333,stroke-width:2px;
    classDef database fill:#f96,stroke:#333,stroke-width:2px;
    classDef frontend fill:#9cf,stroke:#333,stroke-width:2px;
    classDef deploy fill:#f66,stroke:#333,stroke-width:2px;
    classDef external fill:#cc6,stroke:#333,stroke-width:2px;
```
