# votimetro/webapp architecture

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

- Interactive diagram: https://gitdiagram.com/votimetro/webapp
- Repository: https://github.com/votimetro/webapp

## Overview

##### Project type and purpose
- Votímetro is a static‐first, single‐page web application that quizzes users on political/economic statements and aligns them with Portuguese political parties. There is no persistent runtime backend; rather, a build‐time Python script generates the JSON dataset consumed by the frontend.

##### File structure
- Top‐level:
- output_json.py + questions.csv + party_info.csv + requirements.txt → Data‐processing pipeline
- src/ → Static frontend:
– index.html → Entry point
– js/ (question_controller.js, stimulus.js) → Stimulus‐based UI controllers
– css/ → Styles
– images/ → Logos & assets
- No server code or database folder. Deployment is via static hosting (e.g., GitHub Pages, S3 + CloudFront).

##### README for additional insights
- Describes test logic, data sources (party positions, question bank), and calls out “all code and content” in repo.
- No mention of a runtime API; data is baked in at build time.

##### Main components & their interactions (
a. Data Pipeline (Build Step)
- CSV Source (questions.csv, party_info.csv)
- Python Script (output_json.py, executing under requirements.txt)
→ Generates questions.json & parties.json (or similar)
b. Static Asset Hosting
- Host (GitHub Pages, S3 Bucket) serving: index.html, /js, /css, /images, /data (JSON)
c. Client (Browser)
- Fetches index.html → loads CSS, Stimulus JS, question_controller → Performs quiz logic in‐browser
- Fetches JSON data for questions & party positions
- Renders results & chart (CSS + JS)

##### Architectural patterns & design principles
- Static Single Page Application
- Build‐time data generation (no runtime backend)
- Stimulus (“modest JS”) for controller pattern → loose MVC style on the client
- Separation of concerns: Data (JSON), Presentation (HTML/CSS), Behavior (JS)

##### Technologies & libraries to highlight
- Python 3 script + csv module → data build pipeline
- StimulusJS (lightweight JS framework)
- Vanilla JS controllers (question_controller.js)
- CSS modules under src/css for styling
- Static hosting (GitHub Pages or any CDN)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Pipeline (Build-Time)"
        questions["questions.csv"]:::build
        partyinfo["party_info.csv"]:::build
        script["output_json.py"]:::build
        reqs["requirements.txt"]:::build
        dataJson1{{"questions.json"}}:::data
        dataJson2{{"parties.json"}}:::data

        questions --> script
        partyinfo --> script
        reqs --> script
        script --> dataJson1
        script --> dataJson2
    end

    subgraph "Static Assets (/src)"
        html["index.html"]:::asset
        subgraph JS
            qtCtrl["question_controller.js"]:::asset
            stimulus["stimulus.js"]:::asset
        end
        subgraph CSS_Files["CSS Files"]
            style1["chart.css"]:::asset
            style2["compatibility.css"]:::asset
            style3["fold.css"]:::asset
            style4["main.css"]:::asset
            style5["poll.css"]:::asset
            style6["questions.css"]:::asset
            style7["typography.css"]:::asset
            style8["variables.css"]:::asset
        end
        subgraph Images
            favicon["Favicons"]:::asset
            logos["Logos"]:::asset
        end

        html --> qtCtrl
        html --> stimulus
    end

    staticHost["Static Hosting\n(GitHub Pages/S3)"]:::cloud

    dataJson1 --> staticHost
    dataJson2 --> staticHost
    html --> staticHost
    qtCtrl --> staticHost
    stimulus --> staticHost
    CSS_Files --> staticHost
    Images --> staticHost

    client["User Browser"]:::client
    client -->|"HTTP GET"| staticHost
    client -->|"Fetch JSON"| dataJson1
    client -->|"Fetch JSON"| dataJson2
    client -->|"Load HTML/CSS/JS"| html

    click questions "https://github.com/votimetro/webapp/blob/main//questions.csv"
    click partyinfo "https://github.com/votimetro/webapp/blob/main//party_info.csv"
    click script "https://github.com/votimetro/webapp/blob/main//output_json.py"
    click reqs "https://github.com/votimetro/webapp/blob/main//requirements.txt"
    click html "https://github.com/votimetro/webapp/blob/main//src/index.html"
    click qtCtrl "https://github.com/votimetro/webapp/blob/main//src/js/question_controller.js"
    click stimulus "https://github.com/votimetro/webapp/blob/main//src/js/stimulus.js"
    click CSS_Files "https://github.com/votimetro/webapp/tree/main//src/css/"
    click favicon "https://github.com/votimetro/webapp/tree/main//src/images/favicon/"
    click logos "https://github.com/votimetro/webapp/tree/main//src/images/logos/"

    classDef build fill:#D6E4FF,stroke:#74C0FC
    classDef data fill:#E3FCEC,stroke:#51CF66
    classDef asset fill:#FFE8CC,stroke:#FFA94D
    classDef client fill:#FFF3BF,stroke:#FCC419
    classDef cloud fill:#E7F5FF,stroke:#339AFF
```
