# namanshah01/qbag-backend architecture

> Architecture diagram of the GitHub repository namanshah01/qbag-backend, 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/namanshah01/qbag-backend
- Repository: https://github.com/namanshah01/qbag-backend

## Overview

Based on our analysis of the file structure and README file, this project is the backend for a full-stack Question Bank Generator application built with Django and Django REST Framework. It’s clearly structured around two core Django apps – one for authentication and another for managing questions – with a main project module (qbag_api) handling settings, routing, and integration of these apps.

##### Main Components
- Client (Frontend): Although this project is exclusively backend, the README points to a separate frontend. Represent “QBaG Frontend” as an external client that interacts with your backend via REST API calls.
- Django Server/Backend: A single server that hosts multiple apps.
- Authentication Module: Contains modules like models (authentication/models.py), views (authentication/views.py), serializers, and utilities. This module handles registration, login, email verification, token management (using Simple JWT), and password resets.
- Questions Module: Contains modules for question management such as question creation, retrieval, voting, and paper generation. It has its own models, views, serializers, and even migration scripts.
- Core Project Layer: The qbag_api directory houses the main Django configuration (settings.py), URL routing, middleware (if any), and WSGI/ASGI configurations that tie the apps together.
- Database: Although not directly visible in the file tree, Django projects typically interact with a database (through models in both Authentication and Questions apps). Represent this as the underlying central data store.

- Within the Django Server component, show two sub-components (Authentication and Questions) and illustrate that the main router (qbag_api/urls.py) delegates incoming API requests to either the authentication or questions app based on endpoint patterns.

##### Architectural Patterns/Design Principles
- Separation of Concerns: Each Django app (Authentication and Questions) is self-contained and follows the typical Model-View-Serializer (or MVC-like) pattern.
- Modular Design: Emphasize that the main project ties together multiple apps; each has its own directory with migrations and tests.
- RESTful API Design: Clearly indicate the API endpoints from the README for authentication (login, logout, token refresh, etc.) and for questions (create, retrieve, vote, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    FE["QBaG Frontend"]:::frontend
    Core["qbag_api (Core Project)"]:::core
    Auth["Authentication Service (Simple JWT)"]:::module
    Quest["Questions Service (PyTorch)"]:::module
    DB["Database"]:::database
    DRF["Django REST Framework"]:::library
    JWT["Simple JWT"]:::library
    PT["PyTorch"]:::library

    %% External Client calls Django backend
    FE -->|"API_call"| Core

    %% Django Core routing to modules
    Core -->|"routes_auth"| Auth
    Core -->|"routes_questions"| Quest
    Core -->|"uses_drf"| DRF

    %% Modules performing operations on Database
    Auth -->|"CRUD_ops"| DB
    Quest -->|"CRUD_ops"| DB

    %% Module-specific external libraries
    Auth -->|"uses_jwt"| JWT
    Quest -->|"uses_pytorch"| PT

    %% Click Events for component mapping
    click Core "https://github.com/namanshah01/qbag-backend/tree/main/qbag_api/"
    click Auth "https://github.com/namanshah01/qbag-backend/tree/main/authentication/"
    click Quest "https://github.com/namanshah01/qbag-backend/tree/main/questions/"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef core fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef module fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef database fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef library fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
