# aditya20-b/shaastra-encrypton-2024 architecture

> Architecture diagram of the GitHub repository aditya20-b/shaastra-encrypton-2024, 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/aditya20-b/shaastra-encrypton-2024
- Repository: https://github.com/aditya20-b/shaastra-encrypton-2024

## Overview

##### Main System Components
- Frontend (Next.js application)
- Backend (Python Flask application)
- ML Model System

##### Detailed Component Breakdown

A. Frontend Layer (Next.js):
- User Interface Components (from _components folder)
- API Routes
- Pages (main and leaderboard)
Use blue coloring for frontend components.

B. Backend Layer (Python):
- API endpoints
- Data processing logic
Use green coloring for backend components.

C. ML/Analysis Layer:
- Decision Tree Classifier
- Mathematical Model
Use orange coloring for ML components.

D. Data Storage:
- CSV data storage
- Model storage (model.pkl)
Use purple coloring for data storage.

##### Component Interactions
- User → Frontend: User interactions
- Frontend → Backend: API calls
- Backend → ML System: Investment analysis requests
- ML System → Dataset: Data retrieval
- ML System → Backend: Analysis results
- Backend → Frontend: Response data

##### Specific Elements

A. Frontend Components:
- Relationship between:
- Search component
- LeaderBoard components
- Criteria display
- Bento display

B. ML Pipeline:
- Dual analysis approach:
- Decision Tree path (binary output)
- Mathematical model path (probability score)

##### Technical Details to Highlight

Annotations showing:
- Next.js frontend with TypeScript
- Flask backend
- Python-based ML system
- CSV-based data storage
- Key calculation factors:
- Capital invested
- Profit/Emission ratio
- Emission Reduction Goal
- Cost factors
- Industry trends
- Climate risk factors

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI[User Interface]
        UI --> Search["Search Interface"]:::frontend
        UI --> LB["Leaderboard Interface"]:::frontend
        UI --> CD["Criteria Display"]:::frontend
        UI --> BD["Bento Display"]:::frontend
        
        Pages[Pages]
        Pages --> MP["Main Page"]:::frontend
        Pages --> LBP["Leaderboard Page"]:::frontend
        
        API["API Routes"]:::frontend
    end

    subgraph Backend
        BE["Flask Server"]:::backend
        BE --> EP["API Endpoints"]
        EP --> DPL["Data Processing Logic"]
    end

    subgraph "ML System"
        DTC["Decision Tree Classifier"]:::ml
        MM["Mathematical Model"]:::ml
        RC["Risk Calculator"]:::ml
        MC["Model Constants"]:::ml
    end

    subgraph "Data Storage"
        DS["Datasets"]:::data
        TM["Trained Model"]:::data
        PD["Preliminary Data"]:::data
    end

    %% Interactions
    UI ==> API
    API ==> BE
    BE ==> DTC
    BE ==> MM
    DTC --> DS
    MM --> DS
    DTC --> BE
    MM --> BE
    BE --> API

    %% Click Events
    click Search "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/frontend/app/_components/Search.tsx"
    click LB "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/frontend/app/_components/LeaderBoardTable.tsx"
    click CD "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/frontend/app/_components/Criteria.tsx"
    click BD "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/frontend/app/_components/Bento.tsx"
    click MP "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/frontend/app/page.tsx"
    click LBP "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/frontend/app/leaderboard/page.tsx"
    click API "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/frontend/app/api/data/fetch/route.ts"
    click BE "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/backend/app.py"
    click DTC "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/models/model.py"
    click MM "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/models/make_model.ipynb"
    click RC "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/models/risk_calculator.py"
    click MC "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/models/constants.py"
    click TM "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/models/model.pkl"
    click DS "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/datasets/companies_final.csv"
    click PD "https://github.com/aditya20-b/shaastra-encrypton-2024/blob/main/frontend/app/api/data/fetch/preliminar.csv"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef ml fill:#e67e22,stroke:#d35400,color:white
    classDef data fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        F["Frontend Component"]:::frontend
        B["Backend Component"]:::backend
        M["ML Component"]:::ml
        D["Data Storage"]:::data
    end
```
