# harshbang/pygpa-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/harshbang/pygpa-analyzer
- Repository: https://github.com/harshbang/pygpa-analyzer

## Overview

##### Project Type and Purpose
- This is a single-service, Python-based web application deployed via Streamlit Cloud.
- Purpose: Provide students with GPA calculators and planning tools through an interactive web UI.

##### File Structure
- Top level:
- .devcontainer/ – VS Code dev-container config (local development environment).
- app.py – Streamlit app entry point (UI + controller).
- source_code.py – Core GPA calculation logic (business model).
- requirements.txt – Dependency list (Pandas, Numpy, Streamlit).
- README.md, SECURITY.md – Documentation.
- No distinct frontend/backend folders: Streamlit serves both UI and server logic in one process.

##### Key Insights from README
- UI framework: Streamlit (handles user input forms, displays charts/tables).
- Business logic: Pandas + Numpy computations for SGPA, CGPA, goal matrices, planners.
- Deployment: Streamlit Cloud (managed hosting).
- No external database or persistent storage – all computations happen in-memory per session.

##### Main Components & Their Relationships
a. User (Web Browser)
b. Streamlit Web App (app.py)
– Receives HTTP requests via Streamlit server
– Renders forms, tables, matrices, charts
c. Calculation Engine (source_code.py)
– Encapsulates GPA formulas, matrix generator, planner logic
– Utilizes Pandas DataFrames and Numpy arrays
d. Dependency Layer
– Pandas, Numpy, Streamlit libraries
e. Deployment Host
– Streamlit Cloud (handles HTTPS endpoint, autoscaling, SSL)
f. Dev Environment (optional)
– Docker-based devcontainer for local testing

Relationships:
- The User interacts with the Streamlit Web App.
- Streamlit Web App invokes functions in the Calculation Engine.
- The Calculation Engine uses Pandas/Numpy to process data.
- Results flow back through the Streamlit Web App to the User.
- All components live in a single Python process on Streamlit Cloud.

##### Architectural Patterns & Design Principles
- MVC-style separation (UI in app.py, business logic in source_code.py).
- Stateless sessions: each user session starts fresh, no shared storage.
- Modular code: calculation logic decoupled from UI rendering.
- Cloud-native deployment: no server maintenance, leverages Streamlit Cloud.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Cloud["Streamlit Cloud Host"]:::external
    User["User Browser"]:::client
    StreamlitApp["Streamlit Web App\n(app.py)"]:::ui
    CalcEngine["Calculation Engine\n(source_code.py)"]:::logic
    Dependencies["Pandas, Numpy, Streamlit\n(requirements.txt)"]:::deps
    DevContainer["VS Code Dev Container\n(.devcontainer/devcontainer.json)"]:::dev
    README["README.md"]:::docs
    SEC["SECURITY.md"]:::docs

    Cloud --> StreamlitApp
    User -->|"HTTP Request"| StreamlitApp
    StreamlitApp -->|"invokes functions"| CalcEngine
    CalcEngine -->|"uses libraries"| Dependencies
    CalcEngine -->|"returns computed data"| StreamlitApp
    StreamlitApp -->|"renders UI"| User
    DevContainer -->|"local development"| StreamlitApp
    README -->|"documentation for"| StreamlitApp
    SEC -->|"security guidelines"| StreamlitApp

    click StreamlitApp "https://github.com/harshbang/pygpa-analyzer/blob/main/app.py"
    click CalcEngine "https://github.com/harshbang/pygpa-analyzer/blob/main/source_code.py"
    click Dependencies "https://github.com/harshbang/pygpa-analyzer/blob/main/requirements.txt"
    click DevContainer "https://github.com/harshbang/pygpa-analyzer/blob/main/.devcontainer/devcontainer.json"
    click README "https://github.com/harshbang/pygpa-analyzer/blob/main/README.md"
    click SEC "https://github.com/harshbang/pygpa-analyzer/blob/main/SECURITY.md"

    classDef client fill:#D6EAF8,stroke:#1B4F72,color:#1B2631,stroke-width:2px
    classDef ui fill:#AED6F1,stroke:#1B4F72,color:#1B2631,stroke-width:2px
    classDef logic fill:#A9DFBF,stroke:#196F3D,color:#1B2631,stroke-width:2px
    classDef deps fill:#FCF3CF,stroke:#B7950B,color:#1B2631,stroke-width:2px
    classDef external fill:#F5CBA7,stroke:#BA4A00,color:#1B2631,stroke-width:2px
    classDef dev fill:#D5DBDB,stroke:#566573,color:#1B2631,stroke-width:2px
    classDef docs fill:#E8DAEF,stroke:#6C3483,color:#1B2631,stroke-width:2px
```
