# arushi-866/brainverse architecture

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

- Interactive diagram: https://gitdiagram.com/arushi-866/brainverse
- Repository: https://github.com/arushi-866/brainverse

## Overview

##### Main Components
- Frontend Client:
– Represent the React.js application starting from the index.html and captured within the “src” directory.
– This includes various UI components (Dashboard, Chatbot, HomePage, Profile, etc.), pages, modals, and utility functions such as ProtectedRoute.
- Backend Server:
– Located in the “backend” folder, built with Node.js/Express.
– Split into controllers (e.g., authController.js, user.js), routes (auth.js, flashcards.js, mindmap.js, etc.), middleware (auth.js, error.js), and models (User.js).
– Also includes configuration for Cloudinary (cloudinary.js) and database connection (db.js).
- Database:
– MongoDB is used for data storage and persistence.
- AI/NLP Service:
– The Gemini 1.5 Pro API is integrated with the backend to handle AI-driven responses (StudyBuddy Chatbot) and question generation.
- File & Document Ingestion:
– The system supports uploading PDFs and documents for content ingestion. This likely interacts with both the backend (handling file uploads/processing) and external storage/integration with services like Cloudinary.

##### Relationships and Interactions
- Frontend <-> Backend:
- Backend <-> Database:
– Show data flows where backend controllers and routes interact with MongoDB for CRUD operations.
- Backend <-> External Services:
– Also, indicate interactions with Cloudinary for media or file handling.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Clearly delineate frontend, backend, and external integrations.
- Modularization: The backend is organized into controllers, middleware, and routes to handle different functionalities.
- API-First Approach: Emphasize RESTful communication between the client and server.
- Security and Error Handling: Note usage of authentication middleware and error handlers.

##### Relevant Technology Labels
- For the backend, note Express.js as the framework with routes, middleware, and controllers.
- MongoDB for the database.
- Cloudinary (for media uploads) and the Gemini 1.5 Pro API (for AI/NLP operations) as external services.
- Optionally, include Tailwind CSS for UI styling as part of the frontend’s tech stack.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        FIndex["React Frontend (index.html)"]:::frontend
        FSrc["React Frontend (src)"]:::frontend
        UIComponents["UI Components"]:::frontend
        UIPages["UI Pages"]:::frontend
    end

    %% Server Layer
    subgraph "Server Layer"
        BE_Server["Express API Server"]:::backend
        BE_Controllers["Controllers"]:::backend
        BE_Routes["Routes"]:::backend
        BE_Middleware["Middleware"]:::backend
        BE_DBConn["DB Connection"]:::backend
        BE_Models["Models"]:::backend
        BE_Cloudinary["Cloudinary Integration"]:::backend
        BE_FileIngestion["File & Document Ingestion"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        MongoDB["MongoDB Database"]:::database
    end

    %% External Services Layer
    subgraph "External Services Layer"
        Gemini["Gemini 1.5 Pro API"]:::external
        CloudinaryService["Cloudinary Service"]:::external
    end

    %% Client interactions
    FIndex -->|"loads"| FSrc
    FSrc -->|"renders"| UIComponents
    FSrc -->|"renders"| UIPages
    FSrc -->|"API_calls"| BE_Server

    %% Backend internal interactions
    BE_Server -->|"dispatches"| BE_Controllers
    BE_Server -->|"dispatches"| BE_Routes
    BE_Server -->|"applies"| BE_Middleware
    BE_Controllers -->|"handles_DB_ops"| BE_DBConn
    BE_Controllers -->|"handles_DB_ops"| BE_Models
    BE_Controllers -->|"calls_AI"| Gemini
    BE_Routes -->|"manages_uploads"| BE_FileIngestion
    BE_Routes -->|"handles_uploads"| BE_Cloudinary
    BE_Routes -->|"CRUD_ops"| MongoDB
    BE_Cloudinary -->|"utilizes"| CloudinaryService

    %% Styling classes
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef database fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef external fill:#FFA07A,stroke:#333,stroke-width:2px;

    %% Click Events - Client Layer
    click FIndex "https://github.com/arushi-866/brainverse/blob/main/Desktop/Brainverse/Brainverse/index.html"
    click FSrc "https://github.com/arushi-866/brainverse/tree/main/Desktop/Brainverse/Brainverse/src"
    click UIComponents "https://github.com/arushi-866/brainverse/tree/main/Desktop/Brainverse/Brainverse/src/components"
    click UIPages "https://github.com/arushi-866/brainverse/tree/main/Desktop/Brainverse/Brainverse/src/pages"

    %% Click Events - Server Layer
    click BE_Server "https://github.com/arushi-866/brainverse/tree/main/Desktop/Brainverse/Brainverse/backend"
    click BE_Controllers "https://github.com/arushi-866/brainverse/tree/main/Desktop/Brainverse/Brainverse/backend/controllers"
    click BE_Routes "https://github.com/arushi-866/brainverse/tree/main/Desktop/Brainverse/Brainverse/backend/routes"
    click BE_Middleware "https://github.com/arushi-866/brainverse/tree/main/Desktop/Brainverse/Brainverse/backend/middleware"
    click BE_DBConn "https://github.com/arushi-866/brainverse/blob/main/Desktop/Brainverse/Brainverse/backend/config/db.js"
    click BE_Models "https://github.com/arushi-866/brainverse/tree/main/Desktop/Brainverse/Brainverse/backend/models"
    click BE_Cloudinary "https://github.com/arushi-866/brainverse/blob/main/Desktop/Brainverse/Brainverse/backend/config/cloudinary.js"
    click BE_FileIngestion "https://github.com/arushi-866/brainverse/blob/main/Desktop/Brainverse/Brainverse/backend/routes/data.js"
```
