# prudhvi-1618/score-sphere architecture

> Architecture diagram of the GitHub repository prudhvi-1618/score-sphere, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prudhvi-1618/score-sphere
- Repository: https://github.com/prudhvi-1618/score-sphere

## Overview

##### Project Type & Purpose
- It is a full-stack web application built with Django.
- Its purpose is to aggregate, display, and allow downloading of student results (across semesters) by converting traditional PDFs and CSV data into a database-driven, user-friendly website.
- The application uses Pandas to import CSV data (sem1courses.csv, sem2courses.csv) into an SQLite database managed via Django models.

##### Major Components
a. Frontend:
- Templates (located in core/templates) including pages like main.html, nav.html, results.html, resultspdf.html, and error pages (notfound.html).
- Static files such as CSS and images (in the static directory).
- Client-side components (HTML/CSS/JavaScript) used for the user interface.
b. Backend:
- Django Application Code:
- The “core” directory contains the business logic: models.py (database models for Student, Semester, Result, etc. as described in the README), views.py, urls.py, admin.py, and forms.
- Custom management commands (within core/management/commands) that handle CSV imports (import_results.py, import_results1.py) to populate the database.
- Django Settings and URL Routing:
- The “edu” directory holds the Django project settings (settings.py), URL configuration (urls.py), and ASGI/WGSI entry points.
- Django’s built-in administrative interface leveraged via admin.py.
c. Database:
- SQLite database (by default with Django) used for storing all the student details, courses, semester data, results, and related entities.
d. External Dependencies:
- Pandas – integrated for CSV file processing.
- Django Framework – providing the overall MVC/MVT structure.
- Other underlying libraries (HTML/CSS/JS libraries if any) for rendering the UI.
e. Data Import/Processing:
- CSV files (sem1courses.csv, sem2courses.csv) provide course data that is imported into the database.
- Management commands act as an ETL (Extract, Transform, Load) process for results data.

##### Relationships and Interactions
- Users access the website via a browser. The client sends HTTP requests which are routed through the Django URL configuration (in both edu/urls.py and core/urls.py).
- The views in core/views.py process these requests, interacting with models (database) to retrieve student results.
- Templates render the data into HTML pages sent back to the client.
- The management commands (import_results.py and import_results1.py) are executed outside the request cycle to import CSV data into the database.
- There is an implicit interaction between the core components (models, views, and templates) following Django’s MVT pattern.
- Additionally, there is functionality for generating downloadable PDFs of results.

##### Architectural Patterns and Design Principles
- MVT (Model-View-Template) – as implemented by Django.
- Separation of Concerns – Frontend (Templates/Static), Business Logic (views, models, management commands), and Configuration (settings, URL routing).
- Use of management commands helps modularize data import processes.

##### Additional Details
- Detail the dependencies such as Django’s role in routing, rendering, and data modeling, along with Pandas’ role in managing CSV data.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FR1("Browser"):::frontend
        FR2("Templates (HTML)"):::frontend
        FR3("Static Files (CSS/JS/Images)"):::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        AP1("Django Project Settings"):::backend
        AP2("Django URL Routing (edu)"):::backend
        AP3("Django URL Routing (core)"):::backend
        AP4("Django Views"):::backend
        AP5("Django Models"):::backend
        AP6("Forms"):::backend
        AP7("Admin Interface"):::backend
        AP8("Management Commands"):::backend
        AP9("ASGI Entry Point"):::backend
        AP10("WSGI Entry Point"):::backend
    end

    %% Database Layer
    subgraph "Database Layer"
        DB("SQLite Database"):::database
        subgraph "ER Diagram"
            ER1("Student"):::database
            ER2("Semester"):::database
            ER3("Result"):::database
            ER4("Course"):::database
            ER1 -->|"relatesTo"| ER2
            ER1 -->|"has"| ER3
            ER2 -->|"includes"| ER3
            ER2 -->|"offers"| ER4
        end
    end

    %% External Interfaces
    subgraph "External Interfaces"
        EX1a("CSV: sem1courses.csv"):::external
        EX1b("CSV: sem2courses.csv"):::external
        EX2("Pandas"):::external
        EX3("PDF Generation"):::external
    end

    %% Connections from Frontend to Application
    FR1 -->|"HTTP_Request"| AP2
    AP1 -->|"configures"| AP2
    AP1 -->|"loads"| AP9
    AP1 -->|"loads"| AP10
    AP2 -->|"routes_to"| AP3
    AP3 -->|"invokes"| AP4
    AP4 -->|"queries"| AP5
    AP4 -->|"validates"| AP6
    AP4 -->|"renders"| FR2
    FR2 -->|"sends_HTML"| FR1
    FR1 -->|"loads_assets"| FR3
    FR1 -->|"accesses"| AP7

    %% Management and Data Import Flow
    AP8 -->|"imports_from"| EX1a
    AP8 -->|"imports_from"| EX1b
    EX1a -->|"processed_by"| EX2
    EX1b -->|"processed_by"| EX2
    EX2 -->|"inserts_into"| DB

    %% Data interactions between Application and Database
    AP5 -->|"stores_in"| DB

    %% PDF Generation Route
    AP4 -->|"generates"| EX3
    EX3 -->|"delivers_PDF_to"| FR1

    %% Styles
    classDef frontend fill:#e0ffff,stroke:#000,stroke-width:1px;
    classDef backend fill:#ffe4b5,stroke:#000,stroke-width:1px;
    classDef database fill:#e6e6fa,stroke:#000,stroke-width:1px;
    classDef external fill:#ffcccb,stroke:#000,stroke-width:1px;

    %% Click Events
    click FR2 "https://github.com/prudhvi-1618/score-sphere/tree/master/core/templates/core/"
    click FR3 "https://github.com/prudhvi-1618/score-sphere/tree/master/static/"
    click AP5 "https://github.com/prudhvi-1618/score-sphere/blob/master/core/models.py"
    click AP4 "https://github.com/prudhvi-1618/score-sphere/blob/master/core/views.py"
    click AP3 "https://github.com/prudhvi-1618/score-sphere/blob/master/core/urls.py"
    click AP7 "https://github.com/prudhvi-1618/score-sphere/blob/master/core/admin.py"
    click AP6 "https://github.com/prudhvi-1618/score-sphere/blob/master/core/forms.py"
    click AP8 "https://github.com/prudhvi-1618/score-sphere/tree/master/core/management/commands/"
    click AP1 "https://github.com/prudhvi-1618/score-sphere/blob/master/edu/settings.py"
    click AP2 "https://github.com/prudhvi-1618/score-sphere/blob/master/edu/urls.py"
    click AP9 "https://github.com/prudhvi-1618/score-sphere/blob/master/edu/asgi.py"
    click AP10 "https://github.com/prudhvi-1618/score-sphere/blob/master/edu/wsgi.py"
    click EX1a "https://github.com/prudhvi-1618/score-sphere/blob/master/sem1courses.csv"
    click EX1b "https://github.com/prudhvi-1618/score-sphere/blob/master/sem2courses.csv"
```
