# weikangg/bc3412_consulting architecture

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

- Interactive diagram: https://gitdiagram.com/weikangg/bc3412_consulting
- Repository: https://github.com/weikangg/bc3412_consulting

## Overview

##### Overall Project Breakdown
- Backend Analysis Engine:
- This includes modules in the “ans_burning_qn1_and_2” and “ans_burning_qn3” directories, which handle different types of analytical algorithms (e.g., duration, scenario, and risk analysis).
- The “groundwork” directory contains essential supporting modules such as data import, cleaning, company processing, ranking, and metrics analysis. These modules form the core engine that orchestrates the data workflow.
- The “consts” and “utils” directories provide constant definitions and utility functions (like saving results) that are shared across the backend processes.
- “main.py” is likely the orchestration entry point that ties together the various analytical components.

- Data Management:
- The “data” directory holds raw input CSV files for different companies (such as “chubu” and “nextera_energy”) across multiple categories (Environment, Financial, Governance, Social, Targets, etc.).
- The output is organized under the “results” directory (and partly mirrored in the “bc3412-dashboard/public/results”), where aggregated scores, detailed analyses, and JSON outputs are stored.

- Frontend Dashboard:
- The “bc3412-dashboard” directory houses the web dashboard. It includes configuration files (like “package.json”, “vite.config.ts”, and ESLint configuration), HTML files, and a “src” directory indicative of a modern TypeScript/React (or similar framework) single-page application.
- This layer is responsible for visual presentation of the analyzed data and results (rendering tables, scores, charts, etc.). It consumes the JSON output files generated by the backend.

##### Relationships and Data Flow
- Data Initiation:
- Raw CSV datasets (located in “data”) are ingested by the “groundwork” modules (data_import.py and data_cleaning.py).
- Processing and Analysis:
- Processed data is then passed to the “ans_burning_qn*” modules alongside additional processing in “groundwork” for calculating metrics (e.g., duration, scenario rules, risk scores).
- Intermediate data might be transformed or aggregated (e.g., using “ranker.py”, “score_timeseries.py”, and “recommendations_formatter.py”) to compute insights.
- Saving and Storing Results:
- Once processed, the results are saved (using functions in “utils/results_saver.py”) as JSON files in the “results” directory.
- Visualization:
- The “bc3412-dashboard” frontend reads these JSON files (from its “public/results” folder, which seems to mirror or be populated by “results”) to render visualizations and tables, such as the “RiskTable” and “ScoreTable” components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Sources"
        DS1["Chubu CSV"]:::data
        DS2["Nextera Energy CSV"]:::data
    end

    subgraph "Data Ingestion & Cleaning (groundwork)"
        DI["Data Import"]:::ingestion
        DC["Data Cleaning"]:::ingestion
    end

    subgraph "Core Data Processing & Metrics Analysis (groundwork)"
        CP["Company Processor"]:::processing
        IMA["Important Metrics Analyzer"]:::processing
        RK["Ranker"]:::processing
        ST["Score Timeseries"]:::processing
        RF["Recommendations Formatter"]:::processing
    end

    subgraph "Orchestration"
        MO["main.py"]:::orchestration
        CNS["Constants"]:::orchestration
    end

    subgraph "Backend Analysis Engine"
        subgraph "Duration & Scenario Analysis"
            DA["Duration Analyzer"]:::analysis
            SA["Scenario Analyzer"]:::analysis
        end
        subgraph "Risk Analysis"
            RA["Risk Analyzer"]:::analysis
        end
    end

    subgraph "Utility Functions"
        RS["Results Saver"]:::utility
        UT["Utils"]:::utility
    end

    RSO["Results Storage"]:::storage
    FD["Dashboard"]:::frontend

    %% Data flow connections
    DS1 --> DI
    DS2 --> DI
    DI --> DC
    DC --> CP
    CP --> IMA
    IMA --> RK
    RK --> ST
    ST --> RF
    RF --> MO
    CNS --> MO
    MO --> DA
    MO --> SA
    MO --> RA
    DA --> RS
    SA --> RS
    RA --> RS
    RS --> RSO
    RSO --> FD

    %% Click Events
    click DS1 "https://github.com/weikangg/bc3412_consulting/tree/main/data/chubu"
    click DS2 "https://github.com/weikangg/bc3412_consulting/tree/main/data/nextera_energy"
    click DI "https://github.com/weikangg/bc3412_consulting/blob/main/groundwork/data_import.py"
    click DC "https://github.com/weikangg/bc3412_consulting/blob/main/groundwork/data_cleaning.py"
    click CP "https://github.com/weikangg/bc3412_consulting/blob/main/groundwork/company_processor.py"
    click IMA "https://github.com/weikangg/bc3412_consulting/blob/main/groundwork/important_metrics_analyzer.py"
    click RK "https://github.com/weikangg/bc3412_consulting/blob/main/groundwork/ranker.py"
    click ST "https://github.com/weikangg/bc3412_consulting/blob/main/groundwork/score_timeseries.py"
    click RF "https://github.com/weikangg/bc3412_consulting/blob/main/groundwork/recommendations_formatter.py"
    click CNS "https://github.com/weikangg/bc3412_consulting/blob/main/consts/consts.py"
    click MO "https://github.com/weikangg/bc3412_consulting/blob/main/main.py"
    click DA "https://github.com/weikangg/bc3412_consulting/blob/main/ans_burning_qn1_and_2/duration_analyzer.py"
    click SA "https://github.com/weikangg/bc3412_consulting/blob/main/ans_burning_qn1_and_2/scenario_analyzer.py"
    click RA "https://github.com/weikangg/bc3412_consulting/blob/main/ans_burning_qn3/risk_analyzer.py"
    click RS "https://github.com/weikangg/bc3412_consulting/blob/main/utils/results_saver.py"
    click UT "https://github.com/weikangg/bc3412_consulting/blob/main/utils/utils.py"
    click RSO "https://github.com/weikangg/bc3412_consulting/tree/main/results"
    click FD "https://github.com/weikangg/bc3412_consulting/tree/main/bc3412-dashboard"

    %% Styles
    classDef data fill:#c5e1a5,stroke:#333,stroke-width:2px;
    classDef ingestion fill:#b3e5fc,stroke:#333,stroke-width:2px;
    classDef processing fill:#ffe082,stroke:#333,stroke-width:2px;
    classDef orchestration fill:#d1c4e9,stroke:#333,stroke-width:2px;
    classDef analysis fill:#ffab91,stroke:#333,stroke-width:2px;
    classDef utility fill:#f8bbd0,stroke:#333,stroke-width:2px;
    classDef storage fill:#dcedc8,stroke:#333,stroke-width:2px;
    classDef frontend fill:#b39ddb,stroke:#333,stroke-width:2px;
```
