# rajdeep-samanta59/aura_sphere architecture

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

- Interactive diagram: https://gitdiagram.com/rajdeep-samanta59/aura_sphere
- Repository: https://github.com/rajdeep-samanta59/aura_sphere

## Overview

##### Project Type and Purpose
- From the file tree and README, this is a full-stack web application called “Aura-Sphere” with:
- A Client folder: React (Vite, Tailwind CSS) single-page front end
- A Server folder: Node.js/Express REST API with MVC pattern, authentication, file uploads, and Mongo-style models
- The domain appears to be an educational/gamified platform: users, courses, assignments, challenges, leaderboards, study groups, rewards, events, and virtual rooms.

##### File Structure
A. Client (React/Vite front end)
- index.html + main.jsx: entry point
- src/component: React components (Landing, Dashboard, GoalsPage, Leaderboard, AuthForm, Navbar, etc.)
- assets + CSS: styling and images
- Tailwind/Vite configs: build and styling pipeline

B. Server (Node.js/Express back end)
- src/index.js: Express app bootstrap
- src/db/connect.js: database connection (likely MongoDB)
- src/models: data schemas for User, Course, Assignment, Challenge, Class, Dept, Doubt, Event, Reward, StudyGroup, Timetable, VirtualRoom
- src/controller: business logic (userController)
- src/routes: route definitions grouped by feature (auth.js, userroute.js, courserouter.js, challengeRoutes.js, leaderboardroute.js, goals.js, etc.)
- src/middleware: auth (Passport JWT?), error handling, file upload (Multer), async handlers
- src/utils: common helpers (ApiError, ApiResponse)
- public/temp: temporary storage for uploaded avatars
- passport.js: authentication strategy

##### Key Architectural Patterns & Technologies
- Front end: component-based UI, client-side routing (React Router implied), API calls to back end
- Back end: MVC (Model-View-Controller) pattern, layered architecture (routes → controllers → models), middleware pipeline
- Stateless RESTful APIs with JWT via Passport for authentication
- File uploads handled by Multer, stored locally then possibly uploaded to cloud (uploadcloud util)
- MongoDB (or similar document DB) for persistence

##### Main Components & Interactions
a. Client Application
- React components & UI
- State management (local React state or context)
- HTTP/HTTPS requests to API (Axios/Fetch)
b. API Gateway / Server
- Express server entrypoint
- Middleware chain (auth, error handler, multer)
- Route handlers → Controllers
- Business logic & validation
- Models → Database layer
c. Database
- MongoDB instance or cluster
d. File Storage
- Local temp folder (Server/public/temp)
- External cloud storage (Cloudinary/S3) via uploadcloud util
e. Authentication Service
- Passport JWT strategy → token issuance & verification
f. External Services (optional)
- Email/SMS (if notifications), third-party APIs

##### Relationships & Data Flow
1. User interacts with React UI
2. UI dispatches API calls (login, fetch courses, upload avatar)
3. Express middleware verifies JWT → routes request
4. Controller executes business logic → reads/writes MongoDB
5. File uploads flow: Front end → Multer middleware → temp storage → uploadcloud util → cloud storage
6. Responses (ApiResponse) returned to client

##### Important Design Principles
- Separation of concerns: UI vs API vs Data
- Layered MVC on back end: decoupled models, controllers, routes
- Stateless authentication via JWT
- Component-based UI for scalability
- Utility layers (asyncHandler, ApiError) for error consistency

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Application" 
        direction TB
        FE_app["React App (Vite, Tailwind)"]:::frontend
        FE_entry["index.html"]:::frontend
        FE_main["main.jsx"]:::frontend
        FE_components["Components Directory"]:::frontend
        FE_styles["Tailwind & PostCSS Config"]:::frontend
        FE_vite["Vite Config"]:::frontend
    end

    %% Backend/API Layer
    subgraph "Backend/API Service"
        direction TB
        ExpressApp["Express Server"]:::backend
        Passport["Passport JWT Strategy"]:::backend
        DBConnect["DB Connection Module"]:::backend

        subgraph "Middleware"
            direction TB
            AuthMW["Auth Middleware"]:::backend
            ErrorMW["Error Handling Middleware"]:::backend
            MulterMW["File Upload Middleware"]:::backend
        end

        subgraph "Routes"
            direction TB
            AuthRoute["Auth Routes"]:::backend
            UserRoute["User Routes"]:::backend
            CourseRoute["Course Routes"]:::backend
            GoalsRoute["Goals/Assignment Routes"]:::backend
            ChallengeRoute["Challenge Routes"]:::backend
            LeaderboardRoute["Leaderboard Routes"]:::backend
            GamifyRoute["Gamification/Rewards Routes"]:::backend
            StudyEventRoute["Study Groups & Events Routes"]:::backend
        end

        subgraph "Controllers"
            direction TB
            UserCtrl["User Controller"]:::backend
        end

        subgraph "Utilities"
            direction TB
            ApiError["ApiError & AsyncHandler"]:::backend
            ApiResponse["ApiResponse"]:::backend
            UploadCloud["Cloud Upload Helper"]:::backend
        end

        subgraph "Models"
            direction TB
            ModelsDir["Models Directory"]:::backend
        end
    end

    %% Persistence & External
    subgraph "Persistence & Storage"
        direction TB
        MongoDB["MongoDB"]:::persistence
        TempStorage["Temp File Storage"]:::persistence
        CloudStorage["External Cloud Storage"]:::external
    end

    %% Relationships
    FE_app -->|"sends HTTP requests"| ExpressApp
    ExpressApp -->|uses| DBConnect
    ExpressApp -->|uses| Passport
    ExpressApp -->|middleware| AuthMW
    ExpressApp -->|middleware| ErrorMW
    ExpressApp -->|middleware| MulterMW
    AuthMW -->|protects| AuthRoute
    ExpressApp -->|routes| AuthRoute
    ExpressApp -->|routes| UserRoute
    ExpressApp -->|routes| CourseRoute
    ExpressApp -->|routes| GoalsRoute
    ExpressApp -->|routes| ChallengeRoute
    ExpressApp -->|routes| LeaderboardRoute
    ExpressApp -->|routes| GamifyRoute
    ExpressApp -->|routes| StudyEventRoute
    AuthRoute -->|calls| UserCtrl
    UserRoute -->|calls| UserCtrl
    CourseRoute -->|calls| UserCtrl
    GoalsRoute -->|calls| UserCtrl
    ChallengeRoute -->|calls| UserCtrl
    LeaderboardRoute -->|calls| UserCtrl
    GamifyRoute -->|calls| UserCtrl
    StudyEventRoute -->|calls| UserCtrl
    UserCtrl -->|uses| ModelsDir
    ModelsDir -->|interacts with| MongoDB
    MulterMW -->|stores temp in| TempStorage
    UploadCloud -->|uploads to| CloudStorage
    MulterMW -->|calls| UploadCloud

    %% Click Events
    click FE_app "https://github.com/rajdeep-samanta59/aura_sphere/tree/main/Client/"
    click FE_entry "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Client/index.html"
    click FE_main "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Client/src/main.jsx"
    click FE_components "https://github.com/rajdeep-samanta59/aura_sphere/tree/main/Client/src/component/"
    click FE_styles "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Client/tailwind.config.js"
    click FE_styles "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Client/postcss.config.js"
    click FE_vite "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Client/vite.config.js"
    click ExpressApp "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/index.js"
    click DBConnect "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/db/connect.js"
    click Passport "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/passport.js"
    click AuthMW "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/middleware/auth.js"
    click ErrorMW "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/middleware/errorHandler.js"
    click MulterMW "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/middleware/multer.js"
    click UserCtrl "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/controller/userController.js"
    click AuthRoute "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/routes/auth.js"
    click UserRoute "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/routes/userroute.js"
    click CourseRoute "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/routes/courserouter.js"
    click GoalsRoute "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/routes/goals.js"
    click ChallengeRoute "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/routes/challengeRoutes.js"
    click LeaderboardRoute "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/routes/leaderboardroute.js"
    click GamifyRoute "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/routes/gamificiation.js"
    click StudyEventRoute "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/routes/addpt.js"
    click ApiError "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/utils/ApiError.js"
    click ApiError "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/utils/asyncHandler.js"
    click ApiResponse "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/utils/ApiResponse.js"
    click UploadCloud "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/utils/uploadcloud.js"
    click ModelsDir "https://github.com/rajdeep-samanta59/aura_sphere/tree/main/Server/src/models/"
    click MongoDB "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/models/user.model.js"
    click MongoDB "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/models/course.model.js"
    click MongoDB "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/models/assignment.model.js"
    click MongoDB "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/models/challenge.js"
    click MongoDB "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/models/classes.model.js"
    click MongoDB "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/models/dept.model.js"
    click MongoDB "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/models/doubt.model.js"
    click MongoDB "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/models/event.model.js"
    click MongoDB "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/models/reward.js"
    click MongoDB "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/models/studygroup.model.js"
    click MongoDB "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/models/timetable.model.js"
    click MongoDB "https://github.com/rajdeep-samanta59/aura_sphere/blob/main/Server/src/models/virtualroom.model.js"
    click TempStorage "https://github.com/rajdeep-samanta59/aura_sphere/tree/main/Server/public/temp/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#75AADB,color:#034778
    classDef backend fill:#D6F5D6,stroke:#34A853,color:#196F3D
    classDef persistence fill:#FFF4C1,stroke:#FFA000,color:#A66C00
    classDef external fill:#FFE0B2,stroke:#FB8C00,color:#E65100
```
