# srivatsavdevarakonda/clg-gpa-calculator architecture

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

- Interactive diagram: https://gitdiagram.com/srivatsavdevarakonda/clg-gpa-calculator
- Repository: https://github.com/srivatsavdevarakonda/clg-gpa-calculator

## Overview

##### Project Type and Purpose
- This is a small full-stack web application (“GPA Calculator”) built with Flask (Python) on the backend and vanilla JavaScript/HTML/CSS on the frontend.
- Purpose: serve a single-page app where users can add/edit courses, calculate SGPA/CGPA, and persist data in browser Local Storage.

##### High-Level File Structure
- app.py: Flask entry point defining HTTP routes and GPA calculation logic.
- templates/index.html: Jinja2 template for the main UI.
- static/style.css & static/script.js: client-side assets (CSS + JS).
- requirements.txt: Python dependencies (Flask, Gunicorn for prod).
- No external database—persistence happens in browser Local Storage.

##### Key Components
a. Client (Browser)
- HTML/CSS/JS running in the user’s browser.
- Reads/Writes Local Storage.
- Renders the UI and handles user interactions (add/edit course, trigger calculation).
b. HTTP API Layer (Flask)
- app.py exposes endpoints (e.g., GET “/”, POST “/calculate”) or handles form submission.
- Performs GPA computation logic.
- Returns JSON or re-renders index.html with updated data.
c. Static Asset Server
- Serves /static/style.css and /static/script.js.
- Gunicorn as WSGI server.
- Deployed on Render.com.

##### Relationships and Data Flow
- User → Browser UI (loads index.html).
- Browser requests static assets → Flask static route.
- User interacts with UI → script.js reads/writes Local Storage.
- On “Calculate GPA” click → AJAX/fetch or form POST to Flask endpoint.
- Flask computes SGPA/CGPA → returns JSON or HTML fragment.

##### Architectural Patterns & Principles
- Separation of concerns:
- Presentation (HTML/CSS)
- Client logic (vanilla JS)
- Server logic (Flask)
- Stateless server: no session or DB; all persistent state lives in the client.
- Simple MVC flavor: index.html + script.js (View/Controller), app.py (Model/Controller).

– UI (index.html + style.css)
– Client Logic (script.js + Local Storage)
– HTTP Routes (/, /calculate)
– GPA Computation Module
– “Load page (GET /)”
– “Fetch static assets”
– “Calculate GPA (POST)”
– “Return JSON/HTML”

## Diagram (Mermaid)

```mermaid
graph TD
    User(("User")):::external
    Browser["Browser"]:::frontend
    subgraph "Browser Components"
        UI["index.html"]:::frontend
        CSS["style.css"]:::frontend
        JS["script.js"]:::frontend
        LS["Local Storage"]:::frontend
    end

    subgraph "Flask App"
        AppPy["app.py"]:::backend
        Routes["HTTP Endpoints /, /calculate"]:::backend
        Logic["GPA Computation Logic"]:::backend
        StaticAssets["Static Assets"]:::backend
        Requirements["requirements.txt"]:::backend
    end

    Gunicorn["Gunicorn"]:::external
    Render["Render.com"]:::external
    README["README.md"]:::external

    User -->|"GET / Load page"| Browser
    Browser -->|"GET /"| AppPy
    Browser -->|"Fetch static assets"| StaticAssets
    StaticAssets -->|"Serves CSS/JS"| Browser
    Browser -->|"POST /calculate"| AppPy
    AppPy -->|"Return JSON/HTML"| Browser
    JS -->|"read/write"| LS
    Gunicorn -->|WSGI layer| AppPy
    Render -->|Deploys| Gunicorn

    click UI "https://github.com/srivatsavdevarakonda/clg-gpa-calculator/blob/main/templates/index.html"
    click JS "https://github.com/srivatsavdevarakonda/clg-gpa-calculator/blob/main/static/script.js"
    click CSS "https://github.com/srivatsavdevarakonda/clg-gpa-calculator/blob/main/static/style.css"
    click AppPy "https://github.com/srivatsavdevarakonda/clg-gpa-calculator/blob/main/app.py"
    click Requirements "https://github.com/srivatsavdevarakonda/clg-gpa-calculator/blob/main/requirements.txt"
    click README "https://github.com/srivatsavdevarakonda/clg-gpa-calculator/blob/main/README.md"

    classDef frontend fill:#ADD8E6,stroke:#0000FF,color:#000
    classDef backend fill:#90EE90,stroke:#008000,color:#000
    classDef external fill:#D3D3D3,stroke:#696969,color:#000
```
