How srivatsavdevarakonda/clg-gpa-calculator works
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”