# dodero10/smartlearn architecture

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

- Interactive diagram: https://gitdiagram.com/dodero10/smartlearn
- Repository: https://github.com/dodero10/smartlearn

## Overview

##### Out the Main Components
- Frontend:
- React application (located in the “frontend” folder) which includes pages (ChatPage.jsx, Profile.jsx), components for chat, quiz, video, and settings.
- That it consumes REST APIs (or WebSocket endpoints) exposed by the backend.
- Backend:
- A central API server (triggered via uvicorn on FastAPI or similar, as implied from the “main.py” and run command).
- Core submodules:
- Chat Query Module (in backend/chat_query): Responsible for processing chat-related input.
- File Processing Module (backend/file_processing): Handles operations on files.
- Lecture Generation Module (backend/gen_lecture): Contains submodules for generating audio, video, slide processing, etc.
- Constant configurations (backend/constants) and utility modules (backend/utils) that support various functionalities.
- Asynchronous task system using Celery (celery_app.py and tasks.py) for background jobs.
- Configuration management (backend/config) such as Celery and Minio client configuration.
- Data and Storage:
- “Chromadb” folder holding SQLite and binary files – possibly for indexing or vector-based retrieval.
- A separateSeed script to initialize/seed the database.
- Integration with Minio (via the “minio_client.py” in both the root and backend/config) showing object storage usage.
- Containerization and Orchestration:
- Docker Compose’s role (docker-compose.yaml files in both the project root and inside backend) that ties together the frontend, backend, and possibly other services (Celery worker containers, Minio or database containers).

##### Relationships and Interactions
- From the Backend, illustrate calls to internal modules:
- How the Chat Query, File Processing, and Lecture Generation components are invoked as part of the API logic.
- Asynchronous processing by having the Backend dispatch jobs to the Celery worker and then reporting results back.
- Connectivity between the Backend and external or integrated services:
- Data flow to storage services (Minio and Chromadb).
- Configuration management components affecting service operation.

##### Architectural Patterns and Technologies
- Separation of concerns:
- The separation between the frontend (UI) and backend (core logic, business rules, and task processing).
- Use of asynchronous task processing (Celery), which decouples time‐consuming operations (like file processing or lecture generation) from the main API response flow.
- Containerized deployment (using Docker and Docker Compose) which suggests that each service (or microservice-like module) might be deployed separately.
- Supporting technologies:
- Python for backend logic (with modules organized under directories like chat_query, file_processing, gen_lecture, etc.).
- React for the frontend.
- Additional infrastructure technologies like Minio for object storage and embedded SQLite/Chromadb for data persistence.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% User Interface Layer
    subgraph "User Interface Layer"
        FE["React Frontend"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        API["API Server (main.py)"]:::backend
        %% Backend Modules
        subgraph "Backend Modules"
            CQ["Chat Query Module"]:::backend
            FP["File Processing Module"]:::backend
            LG["Lecture Generation Module"]:::backend
            UT["Utility Modules"]:::backend
            CC["Constant Configurations"]:::backend
            CONF["Configuration Management"]:::config
        end
        %% Asynchronous Task Layer
        subgraph "Asynchronous Task Layer"
            CEL["Celery Worker"]:::async
        end
    end

    %% Data & Storage Layer
    subgraph "Data & Storage Layer"
        DB["Embedded Database / Chromadb"]:::db
        MIN["Minio Integration"]:::db
    end

    %% Containerization & Orchestration Layer
    subgraph "Containerization & Orchestration"
        DC_R["Docker Compose (Root)"]:::docker
        DC_B["Docker Compose (Backend)"]:::docker
    end

    %% Relationships
    FE -->|"HTTP_Request"| API

    API -->|"process_chat"| CQ
    API -->|"file_ops"| FP
    API -->|"generate_lecture"| LG
    API -->|"load_constants"| CC
    API -->|"util_calls"| UT
    API -->|"config_load"| CONF
    API -->|"dispatch_task"| CEL
    API -->|"store_data"| DB

    CEL -->|"use_utils"| UT
    CONF -->|"minio_config"| MIN
    FP -->|"file_storage"| MIN

    DC_R -->|"orchestrates"| FE
    DC_R -->|"orchestrates"| API
    DC_R -->|"orchestrates"| CEL
    DC_R -->|"orchestrates"| MIN

    DC_B -->|"orchestrates"| API
    DC_B -->|"orchestrates"| CEL
    DC_B -->|"orchestrates"| MIN

    %% Click Events
    click FE "https://github.com/dodero10/smartlearn/tree/main/frontend/"
    click CQ "https://github.com/dodero10/smartlearn/tree/main/backend/chat_query/"
    click FP "https://github.com/dodero10/smartlearn/blob/main/backend/file_processing/file_processing.py"
    click LG "https://github.com/dodero10/smartlearn/tree/main/backend/gen_lecture/"
    click API "https://github.com/dodero10/smartlearn/blob/main/backend/main.py"
    click CEL "https://github.com/dodero10/smartlearn/blob/main/backend/celery_app.py"
    click CEL "https://github.com/dodero10/smartlearn/blob/main/backend/tasks.py"
    click CONF "https://github.com/dodero10/smartlearn/tree/main/backend/config/"
    click UT "https://github.com/dodero10/smartlearn/tree/main/backend/utils/"
    click CC "https://github.com/dodero10/smartlearn/blob/main/backend/constants/constants.py"
    click DB "https://github.com/dodero10/smartlearn/tree/main/backend/chromadb/"
    click MIN "https://github.com/dodero10/smartlearn/blob/main/backend/minio_client.py"
    click DC_R "https://github.com/dodero10/smartlearn/blob/main/docker-compose.yml"
    click DC_B "https://github.com/dodero10/smartlearn/blob/main/backend/docker-compose.yaml"

    %% Styles and Classes
    classDef frontend fill:#b3cde0,stroke:#03396c,stroke-width:2px;
    classDef backend fill:#ccebc5,stroke:#2b542c,stroke-width:2px;
    classDef async fill:#fbb4ae,stroke:#990000,stroke-width:2px;
    classDef config fill:#decbe4,stroke:#5e3c99,stroke-width:2px;
    classDef db fill:#ffe6b3,stroke:#cc7a00,stroke-width:2px;
    classDef docker fill:#d9d9d9,stroke:#808080,stroke-width:2px;
```
