# anay0305/online-mock-tests-webapp architecture

> Architecture diagram of the GitHub repository anay0305/online-mock-tests-webapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anay0305/online-mock-tests-webapp
- Repository: https://github.com/anay0305/online-mock-tests-webapp

## Overview

##### Project Type and Purpose
- This is a full-stack web application built with Django (Python) on the backend and plain HTML/CSS/JS on the frontend.
- Primary purpose: Let users take online mock tests, calculate instant results, and review answers.

##### File Structure
- Top-level “WebApp” folder is the Django project (settings, ASGI/WGSI, urls).
- Two Django apps beneath root:
– “main”: serves HTML views, handles form submissions, renders templates.
– “API”: exposes REST-style endpoints for tests, questions, results.
- “static/” holds all CSS, JS, images, organized per page (login, signup, test, etc.).
- “templates/” contains HTML templates (login.html, test.html, etc.).
- “db.sqlite3” is the development database; migrations live under each app’s “migrations/.”
- “config/gunicorn.conf.py” & “scripts/super.sh” suggest a production deploy via Gunicorn.

##### README for Additional Insights
- Instant scoring and feedback, admin panel for test management.
- Responsive design (mobile/desktop).
- Some features may be incomplete—focus on core flows.

##### Main Components
1. Web Client (Browser)
- Loads “static” assets; interacts via HTTP(S).
2. Load Balancer / Reverse Proxy (optional)
- Nginx or similar in front of Gunicorn (implied by gunicorn.conf.py).
3. Application Server (Gunicorn)
- Receives HTTP requests, forwards to Django.
4. Django WebApp
- URL Router splits requests between the “main” app and the “API” app.
- “main” app renders templates, handles user-driven flows.
- “API” app serves JSON endpoints for quizzes and results.
5. Database (SQLite)
- Django ORM persists users, tests, questions, answers, results.
6. Admin Interface
- Django’s built-in admin site for managing tests and questions.
7. (Optional) External Authentication or Analytics
- Not present currently but leave space for future integration.

##### Relationships and Data Flows
- Browser → (HTTPS) → Load Balancer/Reverse Proxy → Gunicorn → Django URL Router.
- Router → “main/views.py” or → “API/views.py” depending on endpoint.
- Views → ORM → SQLite (read/write).
- Views → Templates (“templates/”) or JSON responses.
- Browser renders returned HTML or JS-driven UI updates.
- Admin users interact via /admin URLs, same flow.

##### Architectural Patterns
- MVC/MVT pattern: Models (API/models.py + main/models.py), Views (views.py), Templates.
- Separation of concerns:
– “main” for server-rendered front end.
– “API” for AJAX/REST calls.
- Static asset pipeline: CSS/JS under “static/” served directly by Django or a CDN.

##### Final Checklist
- Callouts for key frameworks (Django, Gunicorn, SQLite).
- Optional production layers (Nginx, CDN) even if not yet implemented.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Browser["Web Client (Browser)"]:::frontend
    Browser -->|HTTPS GET/POST| Nginx

    %% Production Proxy
    Nginx["Load Balancer / Reverse Proxy\n(Nginx)"]:::server
    Nginx -->|forwards HTTP| Gunicorn

    %% Application Server
    Gunicorn["Application Server\n(Gunicorn)"]:::server
    Gunicorn -->|WSGI/ASGI| Django

    %% Django WebApp
    subgraph "Django WebApp" 
        direction TB
        Router["URL Router\n(WebApp/settings.py & urls.py)"]:::server
        Router --> MainApp
        Router --> APIApp
        Router --> Admin
        Router --> StaticHandler
        MainApp["Main App\n(server-rendered views/templates)"]:::server
        APIApp["API App\n(REST endpoints)"]:::server
        Admin["Admin Interface\n(Django admin)"]:::server
        StaticHandler["Static File Handler\n(CSS/JS/images)"]:::server
        MainApp -->|renders| Templates
        MainApp -->|ORM queries| DB
        APIApp -->|JSON responses| Browser
        APIApp -->|ORM queries| DB
        Admin -->|uses ORM| DB
        StaticHandler -->|serves| Browser

        Templates["Templates\n(HTML files)"]:::server
    end

    %% Data Storage
    DB["SQLite Database\n(db.sqlite3)"]:::storage

    %% Deployment Scripts & Management
    Scripts["Deployment Script\n(scripts/super.sh)"]:::server
    Manage["Project Root\n(manage.py, requirements.txt)"]:::server

    %% Flows
    Browser -->|loads HTML/JS| Django
    Django -->|response HTML/JSON| Browser

    %% Click Events
    click Browser "https://github.com/anay0305/online-mock-tests-webapp/tree/main/static/"
    click Nginx "https://github.com/anay0305/online-mock-tests-webapp/blob/main/config/gunicorn.conf.py"
    click Gunicorn "https://github.com/anay0305/online-mock-tests-webapp/blob/main/WebApp/wsgi.py"
    click Router "https://github.com/anay0305/online-mock-tests-webapp/blob/main/WebApp/settings.py"
    click Router "https://github.com/anay0305/online-mock-tests-webapp/blob/main/WebApp/urls.py"
    click MainApp "https://github.com/anay0305/online-mock-tests-webapp/tree/main/main/"
    click APIApp "https://github.com/anay0305/online-mock-tests-webapp/tree/main/API/"
    click Templates "https://github.com/anay0305/online-mock-tests-webapp/tree/main/templates/"
    click StaticHandler "https://github.com/anay0305/online-mock-tests-webapp/tree/main/static/"
    click DB "https://github.com/anay0305/online-mock-tests-webapp/blob/main/db.sqlite3"
    click Scripts "https://github.com/anay0305/online-mock-tests-webapp/blob/main/scripts/super.sh"
    click Manage "https://github.com/anay0305/online-mock-tests-webapp/blob/main/manage.py"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#0366d6,color:#0366d6;
    classDef server fill:#d4edda,stroke:#28a745,color:#155724;
    classDef storage fill:#fff3cd,stroke:#856404,color:#856404;
```
