# namansehwal/genai-integrated-lms architecture

> Architecture diagram of the GitHub repository namansehwal/genai-integrated-lms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/namansehwal/genai-integrated-lms
- Repository: https://github.com/namansehwal/genai-integrated-lms

## Overview

##### Main Components

A. Frontend Layer (React-based):
- Sub-components:
- User Interface Components (/components)
- Pages (/pages)
- State Management (Redux - indicated by /store)
- Authentication (Firebase - indicated by firebase.js)

B. Backend Layer (Python):
- Two main sub-systems:
1. AI Services (/apis/gen_ai):
- Chatbot
- Code Explanation
- Notes Generator
- Video Summary
2. Core LMS Services (/apis/non_gen_ai):
- Courses
- Lectures
- Assignments
- Programming Assignments

C. External Services:
- Ollama AI Service (Qwen-2-0.5B model)
- MongoDB Database (indicated by /model/mongo_utility.py)
- Firebase Authentication

##### Component Relationships

- Frontend → Backend API (RESTful communication)
- Backend → MongoDB (data persistence)
- Backend → Ollama AI (AI processing)
- Frontend → Firebase (authentication)

##### Specific Implementation Details

A. Frontend Architecture:
- React components hierarchy
- Redux store for state management
- Authentication flow with Firebase
- API integration points (api.js)

B. Backend Architecture:
- Separate Gen AI and Non-Gen AI APIs
- Database connection layer
- Configuration and utility services
- LLM integration points

##### Data Flow Indicators

- User authentication flow
- API requests/responses
- Database operations
- AI model interactions

##### Additional Elements

- Configuration management
- API documentation (api_documentation.yaml)
- Development tools (Vite, Tailwind)

##### Technical Stack Indicators
- React/Vite (Frontend)
- Python (Backend)
- MongoDB (Database)
- Ollama/Qwen-2-0.5B (AI Model)
- Firebase (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend
        UI["UI Components"]:::frontend
        Pages["Pages"]:::frontend
        Redux["Redux Store"]:::frontend
        FirebaseAuth["Firebase Auth"]:::frontend
        ApiIntegration["API Integration"]:::frontend
        AuthSlice["Auth Slice"]:::frontend
        
        UI --> Pages
        Pages --> Redux
        Redux --> FirebaseAuth
        Redux --> ApiIntegration
        FirebaseAuth --> AuthSlice
    end

    subgraph Backend
        MainApp["Main Application"]:::backend
        ApiConfig["API Configuration"]:::backend
        
        subgraph AIServices
            Chatbot["Chatbot"]:::ai
            CodeExpl["Code Explanation"]:::ai
            NotesGen["Notes Generator"]:::ai
            VideoSum["Video Summary"]:::ai
        end
        
        subgraph CoreLMS
            Courses["Courses"]:::lms
            Lectures["Lectures"]:::lms
            Assignments["Assignments"]:::lms
            ProgAssign["Programming Assignments"]:::lms
        end
        
        LLMIntegration["LLM Integration"]:::ai
        
        AIServices --> LLMIntegration
        CoreLMS --> ApiConfig
        AIServices --> ApiConfig
        ApiConfig --> MainApp
    end

    subgraph ExternalServices
        MongoDB[(MongoDB)]:::database
        Ollama["Ollama AI<br>(Qwen-2-0.5B)"]:::external
        Firebase["Firebase"]:::external
    end

    Frontend --> Backend
    Backend --> MongoDB
    AIServices --> Ollama
    Frontend --> Firebase

    %% Click Events
    click UI "https://github.com/namansehwal/GenAI-Integrated-LMS/tree/main/frontend/src/components"
    click Pages "https://github.com/namansehwal/GenAI-Integrated-LMS/tree/main/frontend/src/pages"
    click Redux "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/frontend/src/store/store.js"
    click FirebaseAuth "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/frontend/src/firebase.js"
    click ApiIntegration "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/frontend/src/api.js"
    click AuthSlice "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/frontend/src/features/authSlice.js"
    click Chatbot "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/backend/apis/gen_ai/chatbot.py"
    click CodeExpl "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/backend/apis/gen_ai/code_explanation.py"
    click NotesGen "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/backend/apis/gen_ai/notes_generator.py"
    click VideoSum "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/backend/apis/gen_ai/video_summary.py"
    click Courses "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/backend/apis/non_gen_ai/courses.py"
    click Lectures "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/backend/apis/non_gen_ai/lectures.py"
    click Assignments "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/backend/apis/non_gen_ai/assignment.py"
    click ProgAssign "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/backend/apis/non_gen_ai/programming_assignments.py"
    click MongoDB "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/backend/model/mongo_utility.py"
    click LLMIntegration "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/backend/utils/LLM.py"
    click ApiConfig "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/backend/instances/api.py"
    click MainApp "https://github.com/namansehwal/GenAI-Integrated-LMS/blob/main/backend/instances/app.py"

    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef backend fill:#4CAF50,stroke:#2E7D32,color:white
    classDef ai fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef lms fill:#00BCD4,stroke:#00838F,color:white
    classDef database fill:#607D8B,stroke:#37474F,color:white
    classDef external fill:#FF9800,stroke:#EF6C00,color:white

    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        Backend_L["Backend"]:::backend
        AI_L["AI Services"]:::ai
        LMS_L["LMS Services"]:::lms
        DB_L["Database"]:::database
        Ext_L["External Services"]:::external
    end
```
