# vidyutchakrabarti/solargis architecture

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

- Interactive diagram: https://gitdiagram.com/vidyutchakrabarti/solargis
- Repository: https://github.com/vidyutchakrabarti/solargis

## Overview

##### Project Type and Purpose
- From the README and file tree, this is a **full‐stack data‐science web app** (Streamlit) that predicts rooftop solar energy potential using:
- User inputs (rooftop area, irradiance, obstacle heights)
- A deep‐learning model
- External geospatial data (building footprints, irradiance)
- It’s deployed on Google Cloud App Engine (app.yaml) and Dockerized for local/CI use.

##### File Structure
- Top‐level entrypoint: **solargis.py**
- UI: Streamlit multipage under **pages/**
- main.py, app.py → session handling/navigation
- estimate.py, final.py → individual workflow steps
- East.py, West.py, North.py, South.py → orientation‐specific modules
- Business logic/helpers: **helperfuncs.py**, **data.py**
- Styles: CSS files (est_style.css, finalstyle.css, style.css, style2.css) and assets/ (gifs)
- Deployment: Dockerfile, app.yaml, requirements.txt

##### Key Components
a. **Client Browser**
- Users access the Streamlit UI.
b. **Streamlit Web Server**
- Hosted app (solargis.py + pages/*).
- Handles routing, session state, rendering.
c. **Application Logic Layer**
- `helperfuncs.py`: data transformations, shading calculations
- `data.py`: loading local datasets or invoking external APIs
d. **ML Model**
- Pre‐trained deep learning model for output prediction (assumed loaded in helperfuncs or solargis.py).
e. **External Data Services**
- Open Buildings API (building footprints)
- Solar irradiance data source (could be an external REST API or file)
f. **Deployment Infrastructure**
- Docker containerization (Dockerfile)
- Google Cloud App Engine (app.yaml)
- Streamlit Cloud (for staging/demo)

##### Relationships & Data Flows
- Browser → HTTP Request → Streamlit Server
- Streamlit Server → calls Application Logic →
- loads data (local or external)
- invokes ML Model
- Logic Layer → returns predictions → Streamlit UI → Browser
- Deployment Layer wraps the entire server and logic in a container and hosts it on GCP

##### Architectural Patterns & Design Principles
- **Layered Architecture**:
- Presentation (Streamlit UI pages)
- Business Logic (helperfuncs, data handling)
- Model Inference (deep learning)
- Data/External Services
- **Modularization**: Each page in /pages handles one concern—orientation, estimation, final display.
- **Containerized Deployment**: Ensures consistency across environments (Docker + GCP).

##### Must‐Include Elements
- Clear, concise **labels** on all components.
- Callouts for critical files or services.

## Diagram (Mermaid)

```mermaid
flowchart TB
    Browser["Client Browser"]:::frontend

    subgraph "GCP App Engine / Docker Container"
        subgraph "Presentation Layer"
            UI["Streamlit Web Server\n(solargis.py)"]:::frontend
            subgraph "Streamlit UI Pages"
                p_main["main.py"]:::frontend
                p_app["app.py"]:::frontend
                p_est["estimate.py"]:::frontend
                p_final["final.py"]:::frontend
                p_east["East.py"]:::frontend
                p_west["West.py"]:::frontend
                p_north["North.py"]:::frontend
                p_south["South.py"]:::frontend
            end
            Styles["UI Styles & Assets\n(est_style.css, finalstyle.css,\nstyle.css, style2.css, assets/)"]:::ui
        end

        subgraph "Application Logic Layer"
            Logic["Logic Layer\n(helperfuncs.py, data.py)"]:::logic
        end

        Model["Model Inference\n(pre-trained DL model)"]:::logic
        External["External Data\n(Open Buildings API,\nSolar Irradiance API)"]:::external

        subgraph "Deployment Infrastructure"
            Dock["Dockerfile"]:::deployment
            AppY["app.yaml"]:::deployment
            Req["requirements.txt"]:::deployment
        end
    end

    Browser -->|"HTTP Request"| UI
    UI -->|"calls logic"| Logic
    Logic -->|"invokes model"| Model
    Logic -->|"fetches data"| External
    Model -->|"returns prediction"| Logic
    External -->|"returns data"| Logic
    Logic -->|"sends output"| UI
    UI -->|"renders response"| Browser

    click UI "https://github.com/vidyutchakrabarti/solargis/blob/main/solargis.py"
    click p_main "https://github.com/vidyutchakrabarti/solargis/blob/main/pages/main.py"
    click p_app "https://github.com/vidyutchakrabarti/solargis/blob/main/pages/app.py"
    click p_est "https://github.com/vidyutchakrabarti/solargis/blob/main/pages/estimate.py"
    click p_final "https://github.com/vidyutchakrabarti/solargis/blob/main/pages/final.py"
    click p_east "https://github.com/vidyutchakrabarti/solargis/blob/main/pages/East.py"
    click p_west "https://github.com/vidyutchakrabarti/solargis/blob/main/pages/West.py"
    click p_north "https://github.com/vidyutchakrabarti/solargis/blob/main/pages/North.py"
    click p_south "https://github.com/vidyutchakrabarti/solargis/blob/main/pages/South.py"
    click Logic "https://github.com/vidyutchakrabarti/solargis/blob/main/helperfuncs.py"
    click Logic "https://github.com/vidyutchakrabarti/solargis/blob/main/data.py"
    click Styles "https://github.com/vidyutchakrabarti/solargis/blob/main/est_style.css"
    click Styles "https://github.com/vidyutchakrabarti/solargis/blob/main/finalstyle.css"
    click Styles "https://github.com/vidyutchakrabarti/solargis/blob/main/style.css"
    click Styles "https://github.com/vidyutchakrabarti/solargis/blob/main/style2.css"
    click Styles "https://github.com/vidyutchakrabarti/solargis/tree/main/assets/"
    click Dock "https://github.com/vidyutchakrabarti/solargis/tree/main/Dockerfile"
    click AppY "https://github.com/vidyutchakrabarti/solargis/blob/main/app.yaml"
    click Req "https://github.com/vidyutchakrabarti/solargis/blob/main/requirements.txt"

    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef logic fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef deployment fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef ui fill:#E0FFFF,stroke:#333,stroke-width:1px
```
