# abhinav-vishwakarma/studyaid-ai architecture

> Architecture diagram of the GitHub repository abhinav-vishwakarma/studyaid-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhinav-vishwakarma/studyaid-ai
- Repository: https://github.com/abhinav-vishwakarma/studyaid-ai

## Overview

##### Main System Components

a) Client Layer:
- React.js Frontend (Single Page Application)
- User Interface Components (Home, Notes, PYQs, Predicted, etc.)

b) API Layer:
- Express.js Backend Server
- RESTful API Endpoints
- File Upload/Download Controllers

c) Service Layer:
- AI Services (Google Generative AI/Gemini)
- File Storage Service
- Database Service

d) Storage Layer:
- MySQL Database
- File Storage System (for PDFs and documents)

##### Component Relationships

a) Data Flow:
- User requests → Frontend → Backend API → Services → Storage
- File uploads path
- AI processing flow
- Search and retrieval paths

b) Integration Points:
- Frontend-Backend communication via REST APIs
- Backend-AI service integration
- Database connections
- File storage interactions

##### Detailed Component Breakdown

Frontend Components:
- Public Assets
- React Components
- Core Components
- Pages
- Context Providers
- Styles

Backend Components:
- Controllers
- File Controllers
- Routes
- File Routes
- Services
- AI Service
- File Service
- Database Service
- Storage
- Uploads

##### Key Interactions to Highlight

a) File Management Flow:
- Upload → Processing → Storage → Indexing
- Retrieval → Serving

b) AI Processing Flow:
- Document Analysis
- Topic Extraction
- Question Prediction
- Summary Generation

c) Search Operations:
- User Query → Search Index → Results
- AI-Enhanced Search Process

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Frontend["React Frontend"]
        UI["UI Components"]
        Pages["Pages"]
        Context["Context Provider"]
        Styles["Styles"]
        
        Frontend --> UI
        Frontend --> Pages
        Frontend --> Context
        Frontend --> Styles
    end

    subgraph API
        Server["Express Server"]
        Routes["File Routes"]
        Controllers["File Controllers"]
        
        Server --> Routes
        Routes --> Controllers
    end

    subgraph Services
        AI["Google Generative AI/Gemini"]
        FileService["File Service"]
        DBService["Database Service"]
    end

    subgraph Storage
        MySQL[(MySQL Database)]
        FileSystem["File Storage System"]
    end

    Client --> API
    API --> Services
    Services --> Storage

    %% Component Pages
    subgraph Pages
        Home["Home Page"]
        Notes["Notes Page"]
        PYQs["PYQs Page"]
        Predicted["Predicted Page"]
        Subject["Subject Page"]
        Semester["Semester Page"]
    end

    %% Component UI
    subgraph UI
        Loader["Loader Component"]
        SelectOptions["Select Options"]
        Atom["Atomic Components"]
    end

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#f1c40f,stroke:#f39c12,color:black
    classDef storage fill:#9b59b6,stroke:#8e44ad,color:white

    class Frontend,UI,Pages,Context,Styles frontend
    class Server,Routes,Controllers backend
    class AI,FileService,DBService service
    class MySQL,FileSystem storage

    %% Click Events
    click Frontend "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/blob/main/frontend/src/App.js"
    click UI "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/tree/main/frontend/src/components"
    click Pages "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/tree/main/frontend/src/pages"
    click Context "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/blob/main/frontend/src/context/AppContext.js"
    click Styles "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/tree/main/frontend/src/styles"
    click Server "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/blob/main/backend/index.js"
    click Routes "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/blob/main/backend/routes/fileRoutes.js"
    click Controllers "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/blob/main/backend/controllers/fileController.js"
    click FileSystem "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/tree/main/backend/uploads"
    click Home "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/blob/main/frontend/src/pages/Home.js"
    click Notes "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/blob/main/frontend/src/pages/Note.js"
    click PYQs "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/blob/main/frontend/src/pages/PYQs.js"
    click Predicted "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/blob/main/frontend/src/pages/Predicted.js"
    click Subject "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/blob/main/frontend/src/pages/Subject.js"
    click Semester "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/blob/main/frontend/src/pages/Semester.js"
    click Loader "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/blob/main/frontend/src/components/SudyPulseLoader.js"
    click SelectOptions "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/blob/main/frontend/src/components/select_options.js"
    click Atom "https://github.com/Abhinav-Vishwakarma/StudyAid-AI/blob/main/frontend/src/components/Atom.js"
```
