# vermasaiyam/quizlab-webwizard architecture

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

- Interactive diagram: https://gitdiagram.com/vermasaiyam/quizlab-webwizard
- Repository: https://github.com/vermasaiyam/quizlab-webwizard

## Overview

##### Main Components
- Frontend Client: Located in the "Frontend" directory. This is a React-based client (bundled with Vite) responsible for UI pages – authentication, upload/homepage, summary, quiz, result, history, and profile.
- Node.js Backend: Found in the "Backend" folder. This backend is built with Express-like architecture. It contains controllers, routes, middlewares, socket features, and utilities for handling user accounts (JWT authentication via models and controllers) and quiz-related requests. It also manages integration with external services (e.g., Cloudinary for file storage).
- Python/Flask API: Triggered via the main.py file at the project root along with groq_ai.py. This component is responsible for handling transcription (with Whisper), summarization, and quiz generation using Groq AI. It forms the core of the AI processing workflows.
- Database: The project uses MongoDB (as indicated by MONGO_URI in the .env file) which houses user data, quiz questions, video data, and other persistent information.
- External Services: Cloudinary is integrated for media storage, and there may be external AI services or APIs (via Groq AI and Whisper libraries), while real-time communication might use socket functionality from the Node.js “socket” module.

##### Relationships and Data Flow
- The Frontend communicates with the Node.js backend through REST API calls for authentication, file uploads, quiz submissions, and user profile management.
- The Node.js backend validates requests using its middlewares, processes business logic via controllers, and interacts with the MongoDB database using model abstractions.
- For media processing, when a user uploads a file or YouTube URL, the Node.js backend can either directly handle file storage (using Cloudinary) or delegate the heavy-lifting to the Python/Flask API. This Python service uses Whisper for transcription and Groq AI for summary and quiz generation. There should be a well-defined API endpoint between Node.js and the Python backend.
- Real-time interactions (if used for updates, notifications, or quiz status) are managed via socket connections in the backend.

##### Key Architectural Patterns & Design Principles
- Separation of concerns: The frontend is entirely separate, the Node.js backend deals with RESTful API design, and the Python Flask API handles AI functions.
- Microservices-style division: Although housed in one repository, the Python and Node.js services act as independent components that communicate over HTTP, allowing easier scaling or modification.
- MVC patterns in Node.js: Controllers, models, and routes clearly separate the application’s logic.
- Modular design: With distinct directories for utilities, middlewares, and models, the architecture supports extendability, simpler unit testing, and clear responsibilities for each module.

- Vital components with clear labels as noted.
- Try to be as detailed as possible by capturing all architectural elements from the unique file structure and the detailed README descriptions.

- The React frontend handling user interaction.
- The Node.js backend facilitating routes, controllers, and middlewares – integrated with MongoDB for storage and Cloudinary for file management.
- The Python/Flask service handling AI-specific tasks (transcription with Whisper, summary and quiz generation with Groq AI).
- The clear data flow between these components and any external dependencies.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        FE["Frontend (React/Vite) Client"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        BE["Node.js Backend (Express-like API)"]:::backend
        Socket["Real-time Socket Communication"]:::socket
        PY["Python/Flask AI Service (Transcription & Summarization)"]:::python
    end

    %% Data & External Services Layer
    subgraph "Data & External Services"
        DB["MongoDB Database"]:::database
        Cloud["Cloudinary (Media Storage)"]:::external
    end

    %% Data Flows
    FE -->|"REST_API_Calls"| BE
    BE -->|"Delegates_AI_Task"| PY
    PY -->|"Returns_AI_Data"| BE
    BE -->|"CRUD_Operations"| DB
    BE -->|"File_Storage_Operations"| Cloud
    BE -->|"Realtime_Updates"| Socket

    %% Click Events
    click FE "https://github.com/vermasaiyam/quizlab-webwizard/tree/main/Frontend/"
    click BE "https://github.com/vermasaiyam/quizlab-webwizard/tree/main/Backend/"
    click PY "https://github.com/vermasaiyam/quizlab-webwizard/blob/main/main.py"
    click DB "https://github.com/vermasaiyam/quizlab-webwizard/blob/main/Backend/utils/db.js"
    click Cloud "https://github.com/vermasaiyam/quizlab-webwizard/blob/main/Backend/utils/cloudinary.js"
    click Socket "https://github.com/vermasaiyam/quizlab-webwizard/blob/main/Backend/socket/socket.js"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#2980B9,stroke-width:2px;
    classDef backend fill:#FCF3CF,stroke:#F1C40F,stroke-width:2px;
    classDef python fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;
    classDef database fill:#ABEBC6,stroke:#27AE60,stroke-width:2px;
    classDef external fill:#FDEBD0,stroke:#E67E22,stroke-width:2px;
    classDef socket fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
```
