# lucasdoreac/luaraujo-calculadoras architecture

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

- Interactive diagram: https://gitdiagram.com/lucasdoreac/luaraujo-calculadoras
- Repository: https://github.com/lucasdoreac/luaraujo-calculadoras

## Overview

##### Project type and purpose
- This is a static, client-side web application consisting of educational financial calculators.
- It uses HTML, CSS, and JavaScript (with Chart.js, Bootstrap 5, and Font Awesome) to render interactive simulations in the browser.

##### File structure
- Top-level HTML pages:
- index.html, contato.html
- calculadoras/calc-1.html, calc-2.html, calc-3.html
- assets/css: style sheets for layout, themes (light/dark), and chart styling/fixes
- assets/js: core UI components, chart helpers, theme-switch logic, and the PGBL-CDB fix
- assets/js/modules: domain logic for each calculator’s inputs, validation, calculation, and result rendering

##### Key insights from the README
- Three calculator flows, each a standalone HTML entry point + shared CSS/JS assets
- Emphasis on theme switching, accessibility, and contrast improvements
- Dependencies: Bootstrap 5.3.0, Chart.js 3.9.1, Font Awesome 6.0.0
- No server-side component—computation and rendering happen entirely in the browser

##### Main components
a. Presentation Layer (Browser)
- HTML Pages (index.html, contacto.html, calculadoras/*.html)
- CSS assets (general styles, theme-switch, chart themes)
- JavaScript assets
- Core UI components (navbar, footer)
- Theme switcher module
- Chart rendering & fixes
- Calculator modules (calculadora.js, calculo-investimentos.js, exibicao-resultados.js, validation.js)
b. Third-Party Libraries (external dependencies)
- Bootstrap CSS/JS (layout & components)
- Chart.js (data visualization)
c. Data Flow & Interactions
- User triggers input on an HTML page → validation.js
- Calculator module computes results → chart-helpers.js
- Chart.js renders graphs in the DOM
- theme-switch toggles CSS variables & classes
d. Hosting & Deployment (optional)
- Static hosting (e.g., GitHub Pages, Netlify) serving all files
- Build/minify step (not currently implemented but recommended)

##### Architectural patterns & design principles
- Modular JS: each calculator’s logic isolated in its own module
- Separation of concerns:
- Presentation (HTML/CSS)
- Business logic (calculator modules)
- Utility functions (chart-helpers.js, validation.js)
- Accessibility & theming handled globally via theme-switch module and contrast-focused CSS

##### Detail
- Individual JS module (validation, calculadora, exibicao-resultados, etc.) rather than lumping all scripts together
- Call out the `pgbl-cdb-fix.js` as a special “bug-fix” component attached to calc-2.html
- Theme-switch module influencing both CSS (theme-switch.css) and JS-driven DOM updates
- Accessibility concerns: keyboard nav, semantic HTML, contrast rules (reference CONTRASTE.md)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer - HTML Entry Points
    subgraph "HTML Entry Points"
        I["index.html"]:::presentation
        C["contato.html"]:::presentation
        C1["calc-1.html"]:::presentation
        C2["calc-2.html"]:::presentation
        C3["calc-3.html"]:::presentation
    end

    %% CSS Bundles
    subgraph "CSS Bundles"
        S["styles.css"]:::presentation
        T["theme-switch.css"]:::presentation
        EC["enhanced-charts.css"]:::presentation
        CTC["chart-theme-contrast.css"]:::presentation
        CTF["chart-text-fix.css"]:::presentation
        CF["contrast-fix.css"]:::presentation
        ECT["enhanced-theme-contrast.css"]:::presentation
        ICF["improved-contrast-fixes.css"]:::presentation
        IS["integrated-styles.css"]:::presentation
        ASF["analysis-sections-fix.css"]:::presentation
    end

    %% Core JS Components
    subgraph "Core JS Components"
        COMP["components.js"]:::presentation
        MAIN["main.js"]:::presentation
        THEME["theme-switch.js"]:::presentation
        CH["chart-helpers.js"]:::presentation
        CTD["chart-theme-detector.js"]:::presentation
        CCON["chart-contrast-fix.js"]:::presentation
        FC["fix-charts.js"]:::presentation
        ELV["ensure-legend-visibility.js"]:::presentation
        SLF["simple-legend-fix.js"]:::presentation
        DGF["direct-graph-fixes.js"]:::presentation
        LCF["load-contrast-fixes.js"]:::presentation
        LMF["load-minimal-fixes.js"]:::presentation
    end

    %% Bug Fix Modules
    subgraph "Bug Fix Modules"
        PGBL["pgbl-cdb-fix.js"]:::presentation
        C2FIX["calc-2-specific-fix.js"]:::presentation
    end

    %% Business Logic - Calculator Modules
    subgraph "Calculator Modules"
        CALC["calculadora.js"]:::business
        INV["calculo-investimentos.js"]:::business
        RES["exibicao-resultados.js"]:::business
        VAL["validation.js"]:::business
    end

    %% External Libraries
    subgraph "External Libraries"
        BS["Bootstrap"]:::thirdparty
        CHART["Chart.js"]:::thirdparty
        FA["Font Awesome"]:::thirdparty
    end

    %% Data Flows & Interactions
    I -->|"loads CSS"| S
    I -->|"loads JS"| COMP
    C -->|"loads CSS"| S
    C -->|"loads JS"| COMP
    C1 -->|"loads CSS"| S
    C1 -->|"loads JS"| COMP
    C2 -->|"loads CSS"| S
    C2 -->|"loads JS"| COMP
    C3 -->|"loads CSS"| S
    C3 -->|"loads JS"| COMP

    COMP -->|"initializes UI"| CALC
    MAIN -->|"orchestrates modules"| CALC
    MAIN -->|"orchestrates modules"| VAL
    VAL -->|"validates input"| CALC
    CALC -->|"computes results"| INV
    INV -->|"passes data"| RES
    RES -->|"invokes charts"| CH
    CH -->|"renders via"| CHART

    I & C & C1 & C2 & C3 -->|"toggles theme"| THEME
    THEME -->|"updates CSS vars"| T

    C2 -->|"applies fix"| PGBL
    C2FIX -->|"applies calc-2 fix"| PGBL
    PGBL -->|"adjusts data"| CH

    %% External dependencies loaded via CDN
    BS -->|"provides layout"| COMP
    CHART -->|"renders graphs"| CH
    FA -->|"provides icons"| COMP

    %% Styles
    classDef presentation fill:#E3F2FD,stroke:#90CAF9,stroke-width:1px
    classDef business fill:#E8F5E9,stroke:#66BB6A,stroke-width:1px
    classDef thirdparty fill:#EEEEEE,stroke:#BDBDBD,stroke-width:1px

    %% Click Events
    click I "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//index.html"
    click C "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//contato.html"
    click C1 "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//calculadoras/calc-1.html"
    click C2 "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//calculadoras/calc-2.html"
    click C3 "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//calculadoras/calc-3.html"
    click S "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/css/styles.css"
    click T "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/css/theme-switch.css"
    click EC "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/css/enhanced-charts.css"
    click CTC "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/css/chart-theme-contrast.css"
    click CTF "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/css/chart-text-fix.css"
    click CF "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/css/contrast-fix.css"
    click ECT "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/css/enhanced-theme-contrast.css"
    click ICF "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/css/improved-contrast-fixes.css"
    click IS "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/css/integrated-styles.css"
    click ASF "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/css/analysis-sections-fix.css"
    click COMP "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/components.js"
    click MAIN "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/main.js"
    click THEME "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/theme-switch.js"
    click CH "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/chart-helpers.js"
    click CTD "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/chart-theme-detector.js"
    click CCON "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/chart-contrast-fix.js"
    click FC "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/fix-charts.js"
    click ELV "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/ensure-legend-visibility.js"
    click SLF "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/simple-legend-fix.js"
    click DGF "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/direct-graph-fixes.js"
    click LCF "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/load-contrast-fixes.js"
    click LMF "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/load-minimal-fixes.js"
    click PGBL "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/pgbl-cdb-fix.js"
    click C2FIX "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/calc-2-specific-fix.js"
    click CALC "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/modules/calculadora.js"
    click INV "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/modules/calculo-investimentos.js"
    click RES "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/modules/exibicao-resultados.js"
    click VAL "https://github.com/lucasdoreac/luaraujo-calculadoras/blob/main//assets/js/modules/validation.js"
```
