# epe-gov-br/epe4md architecture

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

- Interactive diagram: https://gitdiagram.com/epe-gov-br/epe4md
- Repository: https://github.com/epe-gov-br/epe4md

## Overview

##### Main Components

a. Data Input Layer:
- Input data files (Excel sheets in inst/dados_premissas/)
- Configuration parameters
- Historical data

b. Core Processing Modules:
- Market Potential Calculator
- Payback Analysis Engine
- S-Curve Calibration System
- Projection Generators (Monthly, Power, Generation)
- Investment Calculator

c. Output/Visualization Layer:
- Graph Generation Module
- Results Summary System
- Report Generation

##### Component Relationships

**[Data Input Layer] → [Data Preparation] → [Core Processing] → [Output Generation]**

##### Specific Implementation Details

a. Input Section (Blue Components):
- Multiple Excel input sources
- Data validation/preparation (epe4md_prepara_base)
- To premises copying system (epe4md_copia_premissas)

b. Processing Core (Green Components):
- Central calculation engine (epe4md_calcula)
- Market analysis components (epe4md_mercado_potencial)
- Financial calculations (epe4md_payback, epe4md_investimentos)
- Projection modules (epe4md_proj_*)

c. Output Section (Orange Components):
- Visualization functions (epe4md_graf_*)
- Results aggregation (epe4md_sumariza_resultados)

##### Important Elements to Highlight

- Data transformation steps
- Validation points
- Where configuration parameters affect the process

**[ ] - Data Storage**
**( ) - Processing Functions**
**< > - External Interfaces**
**{} - Output Generation**

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef input fill:#a8d1f0,stroke:#000
    classDef processing fill:#90EE90,stroke:#000
    classDef output fill:#FFB347,stroke:#000
    
    %% Input Layer
    subgraph InputLayer
        InputData["Input Data Files"]
        DataPrep["Data Preparation"]
        PremisesCopy["Premises Copying"]
    end
    
    %% Core Processing Layer
    subgraph CoreProcessing
        MainCalc["Main Calculation Engine"]
        MarketPot["Market Potential Calculator"]
        PaybackEngine["Payback Analysis Engine"]
        SCurveCal["S-Curve Calibration"]
        InvestCalc["Investment Calculator"]
        
        subgraph Projections
            MonthlyProj["Monthly Projections"]
            PowerProj["Power Projections"]
            GenProj["Generation Projections"]
            AdoptProj["Adopters Projections"]
        end
    end
    
    %% Output Layer
    subgraph OutputLayer
        GraphGen["Graph Generation"]
        PubFactors["Publication Factors"]
    end
    
    %% Relationships
    InputData --> DataPrep
    InputData --> PremisesCopy
    DataPrep --> MainCalc
    PremisesCopy --> MainCalc
    
    MainCalc --> MarketPot
    MainCalc --> PaybackEngine
    MainCalc --> SCurveCal
    MainCalc --> InvestCalc
    
    MarketPot --> MonthlyProj
    PaybackEngine --> MonthlyProj
    SCurveCal --> MonthlyProj
    InvestCalc --> MonthlyProj
    
    MonthlyProj --> PowerProj
    MonthlyProj --> GenProj
    MonthlyProj --> AdoptProj
    
    PowerProj --> GraphGen
    GenProj --> GraphGen
    AdoptProj --> GraphGen
    
    GraphGen --> PubFactors
    
    %% Styling
    class InputData,DataPrep,PremisesCopy input
    class MainCalc,MarketPot,PaybackEngine,SCurveCal,InvestCalc,MonthlyProj,PowerProj,GenProj,AdoptProj processing
    class GraphGen,PubFactors output
    
    %% Click Events
    click InputData "https://github.com/EPE-GOV-BR/epe4md/tree/main/inst/dados_premissas/"
    click DataPrep "https://github.com/EPE-GOV-BR/epe4md/blob/main/R/epe4md_prepara_base.R"
    click PremisesCopy "https://github.com/EPE-GOV-BR/epe4md/blob/main/R/epe4md_copia_premissas.R"
    click MarketPot "https://github.com/EPE-GOV-BR/epe4md/blob/main/R/epe4md_mercado_potencial.R"
    click PaybackEngine "https://github.com/EPE-GOV-BR/epe4md/blob/main/R/epe4md_payback.R"
    click SCurveCal "https://github.com/EPE-GOV-BR/epe4md/blob/main/R/epe4md_calibra_curva_s.R"
    click MainCalc "https://github.com/EPE-GOV-BR/epe4md/blob/main/R/epe4md_calcula.R"
    click InvestCalc "https://github.com/EPE-GOV-BR/epe4md/blob/main/R/epe4md_investimentos.R"
    click MonthlyProj "https://github.com/EPE-GOV-BR/epe4md/blob/main/R/epe4md_proj_mensal.R"
    click PowerProj "https://github.com/EPE-GOV-BR/epe4md/blob/main/R/epe4md_proj_potencia.R"
    click GenProj "https://github.com/EPE-GOV-BR/epe4md/blob/main/R/epe4md_proj_geracao.R"
    click AdoptProj "https://github.com/EPE-GOV-BR/epe4md/blob/main/R/epe4md_proj_adotantes.R"
    click GraphGen "https://github.com/EPE-GOV-BR/epe4md/blob/main/R/epe4md_graficos.R"
    click PubFactors "https://github.com/EPE-GOV-BR/epe4md/blob/main/R/epe4md_fatores_publicacao.R"
```
