# aarushchaudhary/nm-quiz-app architecture

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

- Interactive diagram: https://gitdiagram.com/aarushchaudhary/nm-quiz-app
- Repository: https://github.com/aarushchaudhary/nm-quiz-app

## Overview

##### Project Type and Purpose
- This is a full-stack, web-based quiz application (“NM Quiz App”) built with PHP (7.4+), MySQL, and standard front-end technologies.
- It serves four distinct user roles (Admin, Faculty, Placement Committee, Student) with real-time monitoring, automated grading, and proctoring.

##### File Structure Analysis
- Top level:
- api/ – AJAX-style endpoints organized by role (admin, faculty, placecom, shared, student) plus auth.php
- views/ – PHP templates for each role’s UI
- assets/ – CSS, JS, images, Excel templates
- config/ – Database and application constants
- lib/ – Third-party libraries (Chart.js, PHPSpreadsheet, Composer vendor)
- index.php, login.php, logout.php – entry points and session handlers
- schema.sql – database schema
- Architectural hints:
- Separation of concerns: static assets vs. dynamic views vs. API
- Role-based subfolders indicate logical modules
- REST-style API layer feeding JSON to front-end JS

##### README Insights
- Technology stack and security features (session auth, prepared statements, XSS/CSRF protection) confirm a classic LAMP monolith.
- Features mapped to API calls and view pages reveal the core components and their interactions.

a. Main Components
- Client Browser (HTML/CSS/JS)
- Web Server + PHP Runtime (Apache/Nginx + PHP 7.4+)
- API Layer (api/*.php)
- View Layer (views/*.php + templates)
- Static Assets (assets/css, assets/js, assets/images)
- Business Logic & Config (config/*.php, index.php controllers)
- Database (MySQL/MariaDB)
- External Services/Libraries (Chart.js, PHPSpreadsheet, SMTP for email)

b. Relationships & Data Flow
1. User → Browser UI → Requests view pages or login/logout
2. Browser → AJAX calls → api/*.php → Business logic → Database
3. Database → SQL engine → Returns data to API
4. API → JSON → Browser JS → Updates UI/Chart.js visualizations
5. Admin uploads Excel → PHPSpreadsheet → Business logic → Database
6. System logs and events flow to shared API endpoints → stored/reported

c. Architectural Patterns & Principles
- Monolithic MVC-like separation (views + API + shared business logic)
- RESTful API endpoints for asynchronous operations
- Role-based modularization (admin, faculty, placecom, student)
- Security layers: authentication (api/auth.php), prepared statements, CSRF tokens

d. Key Technologies
- Frontend: HTML5, CSS3, ES6+ JavaScript, Chart.js
- Backend: PHP 7.4+, Composer packages (PHPSpreadsheet), session-based auth
- Data Store: MySQL 5.7+
- Server: Apache/Nginx with mod_rewrite

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Browser" 
        direction TB
        CB_CSS["assets/css"]:::frontend
        CB_JS["assets/js"]:::frontend
        CB_IMG["assets/images"]:::frontend
        CB_CHART["lib/chartjs/chart.umd.js"]:::external
    end

    %% Server Layer
    subgraph "Web Server & PHP Runtime"
        direction TB
        WS_INDEX["index.php"]:::backend
        WS_LOGIN["login.php"]:::backend
        WS_LOGOUT["logout.php"]:::backend
        WS_CONFIG["config/*.php"]:::backend
        WS_VENDOR["lib/vendor"]:::backend
        WS_COMPOSER_JSON["lib/composer.json"]:::backend
        WS_COMPOSER_LOCK["lib/composer.lock"]:::backend
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        API_AUTH["api/auth.php"]:::backend
        API_ADMIN["api/admin/*.php"]:::backend
        API_FACULTY["api/faculty/*.php"]:::backend
        API_PLACECOM["api/placecom/*.php"]:::backend
        API_SHARED["api/shared/*.php"]:::backend
        API_STUDENT["api/student/*.php"]:::backend
    end

    %% Database
    DB["MySQL\n(schema.sql)"]:::database

    %% External Services
    subgraph "External Libraries & Services"
        direction TB
        EXT_PS["PHPSpreadsheet\n(lib/vendor)"]:::external
        EXT_SMTP["SMTP Service"]:::external
    end

    %% Connections
    CB_CSS -->|HTTP Requests| WS_INDEX
    CB_JS -->|HTTP Requests| WS_INDEX
    CB_IMG -->|HTTP Requests| WS_INDEX
    CB_CHART -->|Loads Chart.js| CB_JS

    CB_JS -->|AJAX JSON| API_AUTH
    CB_JS -->|AJAX JSON| API_ADMIN
    CB_JS -->|AJAX JSON| API_FACULTY
    CB_JS -->|AJAX JSON| API_PLACECOM
    CB_JS -->|AJAX JSON| API_SHARED
    CB_JS -->|AJAX JSON| API_STUDENT

    API_AUTH -->|SQL Query| DB
    API_ADMIN -->|SQL Query| DB
    API_FACULTY -->|SQL Query| DB
    API_PLACECOM -->|SQL Query| DB
    API_SHARED -->|SQL Query| DB
    API_STUDENT -->|SQL Query| DB

    API_ADMIN -->|Excel Import/Export| EXT_PS
    API_FACULTY -->|Excel Export| EXT_PS

    API_SHARED -->|Email Notifications| EXT_SMTP
    API_STUDENT -->|Event Logs| API_SHARED

    %% Click Events
    click CB_CSS "https://github.com/aarushchaudhary/nm-quiz-app/tree/main/assets/css"
    click CB_JS "https://github.com/aarushchaudhary/nm-quiz-app/tree/main/assets/js"
    click CB_IMG "https://github.com/aarushchaudhary/nm-quiz-app/tree/main/assets/images"
    click CB_CHART "https://github.com/aarushchaudhary/nm-quiz-app/blob/main/lib/chartjs/chart.umd.js"

    click WS_INDEX "https://github.com/aarushchaudhary/nm-quiz-app/blob/main/index.php"
    click WS_LOGIN "https://github.com/aarushchaudhary/nm-quiz-app/blob/main/login.php"
    click WS_LOGOUT "https://github.com/aarushchaudhary/nm-quiz-app/blob/main/logout.php"
    click WS_CONFIG "https://github.com/aarushchaudhary/nm-quiz-app/blob/main/config/*.php"
    click WS_VENDOR "https://github.com/aarushchaudhary/nm-quiz-app/tree/main/lib/vendor/"
    click WS_COMPOSER_JSON "https://github.com/aarushchaudhary/nm-quiz-app/blob/main/lib/composer.json"
    click WS_COMPOSER_LOCK "https://github.com/aarushchaudhary/nm-quiz-app/blob/main/lib/composer.lock"

    click API_AUTH "https://github.com/aarushchaudhary/nm-quiz-app/blob/main/api/auth.php"
    click API_ADMIN "https://github.com/aarushchaudhary/nm-quiz-app/tree/main/api/admin/"
    click API_FACULTY "https://github.com/aarushchaudhary/nm-quiz-app/tree/main/api/faculty/"
    click API_PLACECOM "https://github.com/aarushchaudhary/nm-quiz-app/tree/main/api/placecom/"
    click API_SHARED "https://github.com/aarushchaudhary/nm-quiz-app/tree/main/api/shared/"
    click API_STUDENT "https://github.com/aarushchaudhary/nm-quiz-app/tree/main/api/student/"

    click DB "https://github.com/aarushchaudhary/nm-quiz-app/blob/main/schema.sql"
    click EXT_PS "https://github.com/aarushchaudhary/nm-quiz-app/tree/main/lib/vendor/"
    
    %% Styles
    classDef frontend fill:#bbdefb,stroke:#0d47a1,color:#0d47a1;
    classDef backend fill:#c8e6c9,stroke:#1b5e20,color:#1b5e20;
    classDef database fill:#ffe0b2,stroke:#e65100,color:#e65100;
    classDef external fill:#e1bee7,stroke:#4a148c,color:#4a148c;
```
