# albatrossc/sppu-codes architecture

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

- Interactive diagram: https://gitdiagram.com/albatrossc/sppu-codes
- Repository: https://github.com/albatrossc/sppu-codes

## Overview

##### Project type and purpose
- This is a full-stack web application (“SPPU Codes”) built in Python (Flask or similar) and deployed on Vercel.
- Purpose: Serve SPPU lab assignments, code snippets, and exam PDF’s to students; allow code submission via a web form.

##### File structure
- app.py at root: the main HTTP server / Flask application.
- hosting/ folder: Python modules (downloads.py, minfy.py, version.py) defining route handlers or utility scripts.
- templates/: Jinja2 HTML templates for index, subject selector, viewer, submit, download, error, contact.
- static/: all front-end assets:
- css/ and js/ for styling and interactivity
- pdfjs/ and viewer.html for in-browser PDF rendering
- pyqs/ directory holding nested course-and-semester PDF files
- questions/: JSON files per subject, used by the backend to list available questions.
- answers/: source‐code files organized by subject folders (cgl, dsal, dsl, iotl, oop).
- requirements.txt: Python dependencies.
- vercel.json: deployment configuration for Vercel.

##### README for additional insights
- Confirms the site’s public URL, usage, and contribution flow (Submit Code page).
- Highlights that all data is served from code/JSON/PDF file system—no external database.

a. Main components
1. Client Browser (user’s Chrome/Firefox/mobile)
2. CDN / Static Asset Server (serving static/css, static/js, pdfjs assets, static/pyqs PDFs)
3. Web Server (app.py + hosting/*.py)
4. File Storage (answers/, questions/, static/pyqs/)
5. Deployment Platform (Vercel or any PaaS)
6. External Libraries (PDF.js, any Python libraries from requirements)
b. Relationships & interactions
- Browser → HTTP(S) request → Vercel edge → app.py
- app.py routes consult questions/*.json and answers/ directories, or write to answers/ on “submit”
- app.py renders Jinja2 templates + injects dynamic data
- Browser fetches CSS/JS/PDF assets directly from CDN/static server
- PDF.js in browser pulls PDF bytes from static/pyqs or answers (viewer route)
c. Architectural patterns & design principles
- MVC-style separation:
- Model = flat file storage (JSON, code files, PDFs)
- View = Jinja2 templates + static assets
- Controller = Flask route handlers in app.py/hosting
- Static + dynamic content separation: static assets served directly; dynamic pages rendered server-side.
- Stateless, serverless or micro-VM on Vercel: no in-app database, persistence via file system.
d. Key technologies
- Python (Flask or similar), Jinja2 templating
- JavaScript + jQuery (static/js/*.js) for client-side logic
- PDF.js for in-browser PDF rendering
- Vercel for deployment, vercel.json routing
- CSS modules for component styling

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Layer
    subgraph "Client Browser"
        Browser["Client Browser"]:::client
        PDFjsLib["PDF.js Library"]:::client
    end

    %% CDN / Static Assets
    subgraph "CDN / Static Assets"
        CSS["CSS Files"]:::storage
        JS["JavaScript Files"]:::storage
        PDFAssets["Past Question PDFs"]:::storage
        PDFjsStatic["PDF.js Assets"]:::storage
    end

    %% Vercel Edge
    subgraph "Deployment Platform"
        VercelEdge["Vercel Edge"]:::external
    end

    %% Server Layer
    subgraph "Server (Vercel Functions)"
        App["app.py"]:::server
        DL["downloads.py"]:::server
        MF["minfy.py"]:::server
        VR["version.py"]:::server
        subgraph "Templates"
            IDX["index.html"]:::server
            SEL["select.html"]:::server
            SUBJ["subject.html"]:::server
            VIEW["viewer.html"]:::server
            DWLD["download.html"]:::server
            SUBM["submit.html"]:::server
            CNTCT["contact.html"]:::server
            ERR["error.html"]:::server
            TPL["template.html"]:::server
        end
    end

    %% File Storage
    subgraph "File Storage"
        subgraph Questions
            CGLQ["cgl.json"]:::storage
            DSALQ["dsal.json"]:::storage
            DSLQ["dsl.json"]:::storage
            IOTLQ["iotl.json"]:::storage
            OOPQ["oop.json"]:::storage
        end
        subgraph Answers
            A_CGL["answers/cgl/"]:::storage
            A_DSAL["answers/dsal/"]:::storage
            A_DSL["answers/dsl/"]:::storage
            A_IOTL["answers/iotl/"]:::storage
            A_OOP["answers/oop/"]:::storage
        end
        subgraph Downloads
            Z_CGL["DSL.zip"]:::storage
            Z_DSAL["cgl.zip"]:::storage
            Z_DSL["dsal.zip"]:::storage
            Z_IOTL["iotl.zip"]:::storage
            Z_OOP["oop.zip"]:::storage
        end
        PYQS["static/pyqs/"]:::storage
    end

    %% Deployment Config & Docs
    subgraph "Configuration & Documentation"
        VCFG["vercel.json"]:::external
        REQ["requirements.txt"]:::external
        DOCS["docs/README.md"]:::external
        ROBOTS["robots.txt"]:::external
        SITEMAP["sitemap.xml"]:::external
    end

    %% Connections
    Browser -->|HTTP GET/POST| VercelEdge
    VercelEdge --> App
    App --> CGLQ
    App --> DSALQ
    App --> DSLQ
    App --> IOTLQ
    App --> OOPQ
    App --> A_CGL
    App --> A_DSAL
    App --> A_DSL
    App --> A_IOTL
    App --> A_OOP
    App --> Z_CGL
    App --> Z_DSAL
    App --> Z_DSL
    App --> Z_IOTL
    App --> Z_OOP
    App --> IDX
    App --> SEL
    App --> SUBJ
    App --> VIEW
    App --> DWLD
    App --> SUBM
    App --> CNTCT
    App --> ERR
    App --> TPL
    Browser --> CSS
    Browser --> JS
    Browser --> PDFAssets
    Browser --> PDFjsStatic
    Browser --> PDFjsLib

    %% Click Events
    click App "https://github.com/albatrossc/sppu-codes/blob/main/app.py"
    click DL "https://github.com/albatrossc/sppu-codes/blob/main/hosting/downloads.py"
    click MF "https://github.com/albatrossc/sppu-codes/blob/main/hosting/minfy.py"
    click VR "https://github.com/albatrossc/sppu-codes/blob/main/hosting/version.py"
    click IDX "https://github.com/albatrossc/sppu-codes/blob/main/templates/index.html"
    click SEL "https://github.com/albatrossc/sppu-codes/blob/main/templates/select.html"
    click SUBJ "https://github.com/albatrossc/sppu-codes/blob/main/templates/subject.html"
    click VIEW "https://github.com/albatrossc/sppu-codes/blob/main/templates/viewer.html"
    click DWLD "https://github.com/albatrossc/sppu-codes/blob/main/templates/download.html"
    click SUBM "https://github.com/albatrossc/sppu-codes/blob/main/templates/submit.html"
    click CNTCT "https://github.com/albatrossc/sppu-codes/blob/main/templates/contact.html"
    click ERR "https://github.com/albatrossc/sppu-codes/blob/main/templates/error.html"
    click TPL "https://github.com/albatrossc/sppu-codes/blob/main/templates/template.html"
    click CSS "https://github.com/albatrossc/sppu-codes/tree/main/static/css/"
    click JS "https://github.com/albatrossc/sppu-codes/tree/main/static/js/"
    click PDFjsStatic "https://github.com/albatrossc/sppu-codes/tree/main/static/pdfjs/"
    click CGLQ "https://github.com/albatrossc/sppu-codes/blob/main/questions/cgl.json"
    click DSALQ "https://github.com/albatrossc/sppu-codes/blob/main/questions/dsal.json"
    click DSLQ "https://github.com/albatrossc/sppu-codes/blob/main/questions/dsl.json"
    click IOTLQ "https://github.com/albatrossc/sppu-codes/blob/main/questions/iotl.json"
    click OOPQ "https://github.com/albatrossc/sppu-codes/blob/main/questions/oop.json"
    click A_CGL "https://github.com/albatrossc/sppu-codes/tree/main/answers/cgl/"
    click A_DSAL "https://github.com/albatrossc/sppu-codes/tree/main/answers/dsal/"
    click A_DSL "https://github.com/albatrossc/sppu-codes/tree/main/answers/dsl/"
    click A_IOTL "https://github.com/albatrossc/sppu-codes/tree/main/answers/iotl/"
    click A_OOP "https://github.com/albatrossc/sppu-codes/tree/main/answers/oop/"
    click PYQS "https://github.com/albatrossc/sppu-codes/tree/main/static/pyqs/"
    click Z_CGL "https://github.com/albatrossc/sppu-codes/blob/main/downloads/DSL.zip"
    click Z_DSAL "https://github.com/albatrossc/sppu-codes/blob/main/downloads/cgl.zip"
    click Z_DSL "https://github.com/albatrossc/sppu-codes/blob/main/downloads/dsal.zip"
    click Z_IOTL "https://github.com/albatrossc/sppu-codes/blob/main/downloads/iotl.zip"
    click Z_OOP "https://github.com/albatrossc/sppu-codes/blob/main/downloads/oop.zip"
    click VCFG "https://github.com/albatrossc/sppu-codes/blob/main/vercel.json"
    click REQ "https://github.com/albatrossc/sppu-codes/blob/main/requirements.txt"
    click DOCS "https://github.com/albatrossc/sppu-codes/blob/main/docs/README.md"
    click ROBOTS "https://github.com/albatrossc/sppu-codes/blob/main/robots.txt"
    click SITEMAP "https://github.com/albatrossc/sppu-codes/blob/main/sitemap.xml"

    %% Styles
    classDef client fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef server fill:#d4edda,stroke:#333,stroke-width:1px
    classDef storage fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#333,stroke-width:1px
```
