# codeandomexico/decidim-monterrey architecture

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

- Interactive diagram: https://gitdiagram.com/codeandomexico/decidim-monterrey
- Repository: https://github.com/codeandomexico/decidim-monterrey

## Overview

##### Project type and purpose
- This is a full-stack Ruby on Rails monolith customized from the Decidim open-source participatory democracy platform.
- Its purpose is to serve as the Decidim Monterrey site: a web platform where citizens can propose, debate, vote, submit forms, etc., backed by reusable Decidim engines (budgets, proposals, surveys, verifications, etc.) and a custom “ine” module for neighborhood data.

##### Top-level file structure and architectural clues
- app/: MVC code (controllers, models, views, cells, jobs, mailers, permissions, forms, helpers).
- config/: Rails config, routes, environments, initializers (Decidim, workflows, CarrierWave, OAuth, etc.).
- db/: CSV seed data, migrations (hundreds of Decidim engine migrations).
- lib/extensions/: Rails concerns and service overrides that plug into Decidim’s APIs (workflows, permissions, commands).
- decidim-module-ine/: A mountable Rails engine (controllers, models, views, uploaders, jobs, mailers, presenters, packs, lib/engine).
- omniauth-idmty/: A standalone OAuth strategy gem for authentication.
- docker/, docker-compose-*.yml: Containers for web, worker, database, and environment-specific setups.
- config/webpack & app/packs: Webpacker for JS/CSS asset bundling.

##### Extracted architecture from README
- Rails + Puma serve HTTP(S) requests, assets via Webpacker.
- Postgres (or configured RDBMS) stores all Decidim data + module data + user records.
- ActiveStorage or CarrierWave handles file uploads.
- Background jobs run via ActiveJob/Delayed Job.
- Emails sent with ActionMailer.
- OmniAuth-IDMTY handles external identity provider integration.
- Entire stack runs in Docker containers for consistency across environments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend
    subgraph "Frontend"  
        direction TB
        Browser["Browser / Web Client"]:::externalOrange
        AssetJS["Bundled JS\n(app/packs/src/decidim/decidim_application.js)"]:::internal
        AssetCSS["Bundled CSS\n(app/packs/stylesheets/decidim/)"]:::internal
    end

    %% Backend
    subgraph "Backend"
        direction TB
        RailsApp["Rails Application (Puma)"]:::internal

        subgraph "MVC Layers"
            direction TB
            Controllers["Controllers"]:::internal
            Models["Models"]:::internal
            Views["Views"]:::internal
            Cells["Cells (app/cells/)"]:::internal
            Forms["Forms"]:::internal
            Permissions["Permissions"]:::internal
        end

        subgraph "Background & Mail"
            direction TB
            Jobs["Jobs (app/jobs/)"]:::infraGrey
            DelayedJobBIN["Delayed Job CLI (bin/delayed_job)"]:::infraGrey
            Mailers["Mailers (app/mailers/)"]:::internal
        end

        subgraph "Custom Code"
            direction TB
            Extensions["Extensions & Service Overrides\n(lib/extensions/)"]:::internal
            DecidimIne["decidim-module-ine Engine"]:::internal
            OAuthIDM["omniauth-idmty Strategy"]:::internal
        end

        subgraph "Asset Pipeline"
            direction TB
            WebpackConfig["Webpack Config\n(config/webpack/)"]:::internal
            WebpackerYML["Webpacker YML\n(config/webpacker.yml)"]:::internal
        end
    end

    %% Infrastructure & External
    subgraph "Infrastructure & Services"
        direction TB
        Worker["Background Worker\n(ActiveJob/Delayed Job)"]:::infraGrey
        Database["PostgreSQL Database"]:::db
        Storage["File Storage\n(ActiveStorage/CarrierWave)"]:::infraGrey
        EmailService["SMTP / Email Service"]:::externalOrange
        OAuthProvider["External OAuth Provider\n(IDMTY)"]:::externalOrange
        Docker["Docker Containers\n(docker/)"]:::infraGrey
        DockerCompose["Docker Compose Files"]:::infraGrey
    end

    %% Relationships
    Browser -->|"HTTP(S)"| RailsApp
    Browser -->|"Load assets"| AssetJS
    Browser --> AssetCSS

    RailsApp --> Controllers
    Controllers --> Models
    Controllers --> Views
    Views --> Browser
    Controllers -->|"enqueue job"| Jobs
    Jobs --> Worker
    Worker --> Database
    Worker --> EmailService
    Controllers --> Mailers
    Mailers --> EmailService
    Controllers --> Storage
    RailsApp --> Database
    RailsApp --> Storage
    RailsApp -->|"OAuth handshake"| OAuthProvider
    RailsApp --> EmailService

    RailsApp --> Extensions
    RailsApp --> DecidimIne
    RailsApp --> OAuthIDM

    RailsApp --> WebpackConfig
    RailsApp --> WebpackerYML

    Worker --> DelayedJobBIN
    Docker --> RailsApp
    Docker --> Worker
    Docker --> Database
    Docker --> Storage

    %% Click Events
    click Controllers "https://github.com/codeandomexico/decidim-monterrey/tree/main/app/controllers/"
    click Models "https://github.com/codeandomexico/decidim-monterrey/tree/main/app/models/"
    click Views "https://github.com/codeandomexico/decidim-monterrey/tree/main/app/views/"
    click Cells "https://github.com/codeandomexico/decidim-monterrey/tree/main/app/cells/"
    click Forms "https://github.com/codeandomexico/decidim-monterrey/tree/main/app/forms/"
    click Permissions "https://github.com/codeandomexico/decidim-monterrey/tree/main/app/permissions/"
    click Jobs "https://github.com/codeandomexico/decidim-monterrey/tree/main/app/jobs/"
    click DelayedJobBIN "https://github.com/codeandomexico/decidim-monterrey/tree/main/bin/delayed_job"
    click Mailers "https://github.com/codeandomexico/decidim-monterrey/tree/main/app/mailers/"
    click AssetJS "https://github.com/codeandomexico/decidim-monterrey/blob/main/app/packs/src/decidim/decidim_application.js"
    click AssetCSS "https://github.com/codeandomexico/decidim-monterrey/tree/main/app/packs/stylesheets/decidim/"
    click WebpackConfig "https://github.com/codeandomexico/decidim-monterrey/tree/main/config/webpack/"
    click WebpackerYML "https://github.com/codeandomexico/decidim-monterrey/blob/main/config/webpacker.yml"
    click Extensions "https://github.com/codeandomexico/decidim-monterrey/tree/main/lib/extensions/"
    click DecidimIne "https://github.com/codeandomexico/decidim-monterrey/tree/main/decidim-module-ine/"
    click OAuthIDM "https://github.com/codeandomexico/decidim-monterrey/tree/main/omniauth-idmty/"
    click Database "https://github.com/codeandomexico/decidim-monterrey/tree/main/db/"
    click Docker "https://github.com/codeandomexico/decidim-monterrey/tree/main/docker/"
    click DockerCompose "https://github.com/codeandomexico/decidim-monterrey/blob/main/docker-compose-*.yml"

    %% Styles
    classDef internal fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef db fill:#DFFFE0,stroke:#2E8B57,color:#2E8B57
    classDef externalOrange fill:#FFE5B4,stroke:#FF8C00,color:#FF8C00
    classDef infraGrey fill:#F0F0F0,stroke:#A9A9A9,color:#696969
```
