# dhruvreddys/quizmaster architecture

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

- Interactive diagram: https://gitdiagram.com/dhruvreddys/quizmaster
- Repository: https://github.com/dhruvreddys/quizmaster

## Overview

##### Project Type and Purpose
- The README indicates that QuizMaster is part of an IITM BS DEGREE MAD1 PROJECT. Based on the file structure, QuizMaster is a web application that appears to manage quiz-related functionality (creating quizzes, adding questions, handling user attempts, etc.).
- The project uses HTML templates and CSS files for the front-end, Python code for the backend, and SQLite (quizmaster.sqlite3) as its database.

##### Analyzing the File Structure
- Main Entry Point: The app.py file serves as the starting point of the application.
- Controllers Directory: Contains controller.py and studentcontroller.py which likely implement the application logic for handling incoming requests, routing, and possibly business rules.
- Models Directory: Contains database.py. This module probably encapsulates interactions with the SQLite database, representing the data layer.
- Instance Directory: Houses the actual SQLite database file, which indicates persistence for user data, questions, quizzes, etc.
- Templates Directory: Contains HTML files that define the user interface pages. There are multiple pages for registration, dashboards, quiz forms, results, etc.
- Static Directory: Contains CSS files (and a charts subdirectory), which are used for styling the front-end.
- Additional files: requirements.txt specifies dependencies. The DEPLOY directory bundles the components for deployment.

##### Key Architectural Components
a. Web Client (Browser):
- Represents the end-users accessing the application via HTML pages.
b. Frontend Components:
- Templates: Jinja2 templates that generate dynamic HTML.
- Static Files: CSS, and possibly JavaScript (if it were present), used to style and add interactivity to the pages.
c. Application Server:
- The main app.py which initializes the Flask application and sets up routing.
- Controllers: The controller modules (controller.py, studentcontroller.py) to handle HTTP requests, implement business logic, and route responses.
d. Data Models and Persistence Layer:
- Models (database.py) that interact with the SQLite database.
- SQLite Database: The instance/quizmaster.sqlite3 file that stores persistent application data.
e. External Dependencies:
- Python Packages specified in requirements.txt (e.g., Flask and other dependencies) that support the application's functionality.

##### Relationships and Interactions
- Inside the Application Server, indicate that app.py routes these requests to an appropriate Controller.
- Controllers then process the request, interacting with the Models to either fetch or modify data.
- The Models (database.py) communicate with the SQLite Database to perform CRUD operations.
- The Controller then renders an appropriate Template (from the Templates folder), incorporating data retrieved from the Models, and sends the rendered HTML back to the Web Client.
- A feedback loop for user interactions (e.g., form submissions, Quiz attempts) should be visually depicted.

##### Architectural Patterns and Design Principles
- MVC-Like Separation: The structure follows an MVC (Model-View-Controller) paradigm. Models handle data, the Templates (View) handle presentation, and the Controllers manage the business logic and request routing.
- Layered Architecture: There is a clear separation between presentation (templates, static assets), business logic (controllers), and data access (models and database).
- Modularity: Using separate directories for controllers, models, and templates increases maintainability and testability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        WC["Web Client (Browser)"]:::frontend
        T["Templates (HTML)"]:::templates
        S["Static Files (CSS)"]:::templates
    end

    subgraph "Backend Layer"
        AS["app.py (Flask Application)"]:::backend
        subgraph "Controllers"
            C1["controller.py"]:::controllers
            C2["studentcontroller.py"]:::controllers
        end
        M["database.py"]:::models
    end

    ED["requirements.txt"]:::external
    DB["SQLite Database"]:::database

    WC -->|"HTTP_Request"| AS
    AS -->|"Routes_Request"| C1
    AS -->|"Routes_Request"| C2
    C1 -->|"Business_Logic"| M
    C2 -->|"Business_Logic"| M
    M -->|"DB_Operations"| DB
    C1 -->|"Render_HTML"| T
    C2 -->|"Render_HTML"| T
    T -->|"HTML_Response"| WC
    ED -->|"Provides_Dependency"| AS

    click WC "https://github.com/dhruvreddys/quizmaster/tree/main/DEPLOY/templates"
    click T "https://github.com/dhruvreddys/quizmaster/tree/main/DEPLOY/templates"
    click S "https://github.com/dhruvreddys/quizmaster/tree/main/DEPLOY/static"
    click AS "https://github.com/dhruvreddys/quizmaster/blob/main/DEPLOY/app.py"
    click C1 "https://github.com/dhruvreddys/quizmaster/blob/main/DEPLOY/controllers/controller.py"
    click C2 "https://github.com/dhruvreddys/quizmaster/blob/main/DEPLOY/controllers/studentcontroller.py"
    click M "https://github.com/dhruvreddys/quizmaster/blob/main/DEPLOY/models/database.py"
    click DB "https://github.com/dhruvreddys/quizmaster/blob/main/DEPLOY/instance/quizmaster.sqlite3"
    click ED "https://github.com/dhruvreddys/quizmaster/blob/main/DEPLOY/requirements.txt"

    classDef frontend fill:#DDEEFF,stroke:#000,stroke-width:2px;
    classDef templates fill:#EEFFDD,stroke:#000,stroke-width:2px;
    classDef backend fill:#FFDDCC,stroke:#000,stroke-width:2px;
    classDef controllers fill:#FDF6E3,stroke:#000,stroke-width:2px;
    classDef models fill:#E2E2FF,stroke:#000,stroke-width:2px;
    classDef database fill:#FFDDEE,stroke:#000,stroke-width:2px;
    classDef external fill:#FFEEDD,stroke:#000,stroke-width:2px;
```
