# anuj-vishwakarma/quizmaster architecture

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

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

## Overview

##### Project Identification
- The project is a full-stack web application built with Flask. It mainly focuses on quiz management – including chapters, subjects, and questions – tailored for two roles: administrators and regular users.
- The README confirms use of Flask for the backend, Jinja2 templates for the frontend, Bootstrap for styling, SQLite for data storage, and Chart.js for performance visualization.

##### Main Components
- Client/User Interface:
– Represented by the templates (subdirectories for admin, auth, and user) and static assets.
– Two user flows: one tailored for admins (e.g., admin-dashboard, management views) and one for regular users (e.g., user dashboard, quiz attempts, profile).
- Backend Application:
– Core application logic resides in files such as app.py, routes.py, config.py, and models.py.
– The controller layer is handled by routes.py and app.py where HTTP requests are mapped to business logic.
- Database:
– SQLite database located in instance/database.db.
– All persistent data including user info, quiz details, chapters, subjects, and question data.
- External Libraries & Frameworks:
– Flask for the web server.
– Jinja2 for view templating.
– Bootstrap and JavaScript for the responsive UI.
– Chart.js for dynamic charts; annotate data flows for performance charts.

##### Architectural Patterns
- The project follows an MVC pattern:
– Model: Managed via models.py for user, admin, quizzes, chapters, etc.
– View: Jinja2 templates serve as the presentation layer (with separation for different user roles).
– Controller/Routes: Managed by routes.py and app.py, handling backend logic and routing.
- Separation of configurations is seen in config.py, and different instance data (i.e., the database) keeps production-level configurations isolated.

##### Identifying Relationships and Interactions
- Requests from a browser trigger Flask routes (controllers) which query the SQLite database through models.
- The controllers process logic and then pass data onto Jinja2 templates for rendering.
- Admin and user dashboards are separate flows but share some common backend components.
- Interaction patterns include submissions from login forms, CRUD operations for quizzes and chapters, and dynamic chart rendering via Chart.js.

##### Final Touches
- Do not hesitate to break down broad components into smaller sub-components (e.g., splitting controllers for login, quiz management, and user management) to capture all essential elements.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client (Web Browser)"
        AdminUI["Admin UI"]:::client
        UserUI["User UI"]:::client
        Templates["Templates (Jinja2)"]:::client
        StaticAssets["Static Assets"]:::client
    end

    %% Server Layer
    subgraph "Web Server (Flask)"
        App["app.py"]:::server
        Routes["routes.py"]:::server
        Config["config.py"]:::server
        Models["models.py"]:::server
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["SQLite Database"]:::db
    end

    %% External Libraries
    subgraph "External Libraries"
        Flask["Flask"]:::external
        Jinja2["Jinja2"]:::external
        Bootstrap["Bootstrap"]:::external
        Chartjs["Chart.js"]:::external
    end

    %% Client to Server Flow
    AdminUI -->|"HTTP_Request"| App
    UserUI  -->|"HTTP_Request"| App

    %% Inside Server interactions
    App -->|"RoutesHandling"| Routes
    App -->|"ConfigAccess"| Config
    App -->|"ModelOps"| Models
    Routes -->|"LogicProcessing"| Models

    %% Server to Database
    Models -->|"DB_Queries"| DB

    %% Server rendering and static
    App -->|"RenderTemplates"| Templates
    App -->|"ServeStatic"| StaticAssets

    %% External Libraries usage
    Flask -->|"Framework"| App
    Jinja2 -->|"TemplateEngine"| Templates
    Bootstrap -->|"Styling"| StaticAssets
    App -->|"ChartData"| Chartjs

    %% Click Events for Component Mapping
    click Templates "https://github.com/anuj-vishwakarma/quizmaster/tree/main/templates"
    click StaticAssets "https://github.com/anuj-vishwakarma/quizmaster/tree/main/static"
    click App "https://github.com/anuj-vishwakarma/quizmaster/blob/main/app.py"
    click Routes "https://github.com/anuj-vishwakarma/quizmaster/blob/main/routes.py"
    click Config "https://github.com/anuj-vishwakarma/quizmaster/blob/main/config.py"
    click Models "https://github.com/anuj-vishwakarma/quizmaster/blob/main/models.py"
    click DB "https://github.com/anuj-vishwakarma/quizmaster/blob/main/instance/database.db"

    %% Styles
    classDef client fill:#cfe2f3,stroke:#0b5394,stroke-width:2px;
    classDef server fill:#d9ead3,stroke:#38761d,stroke-width:2px;
    classDef db fill:#ead1dc,stroke:#b45f06,stroke-width:2px;
    classDef external fill:#fff2cc,stroke:#bf9000,stroke-width:2px;
```
