# vimalnegi03/tutor_finder architecture

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

- Interactive diagram: https://gitdiagram.com/vimalnegi03/tutor_finder
- Repository: https://github.com/vimalnegi03/tutor_finder

## Overview

##### Project Type & Purpose
– This is a full-stack MERN application (“Tutor Finder”) that connects students and tutors.
– Frontend: React + Redux + Tailwind for UI and state management.
– Backend: Node.js/Express REST API + Socket.IO for real-time chat.
– Database: MongoDB with Mongoose ODM.
– File storage: Multer + local storage + Cloudinary.

##### Main Components
a. Frontend (Client)
- React application (src/)
- UI components (Auth, Chat, Home, Notes, TutorsList, Groups, TutorDashboard)
- Redux store & slices for auth, chat, groups, messages, reviews, tutors
- Socket.IO client (socket.js) for real-time messaging
- Static assets (public/pdfs, audio)
b. Backend (Server)
- Express server (server.js)
- Routes: authRoutes, userRoutes, chatRoutes, groupRoutes, messageRoutes, reviewRoutes, emailRoutes
- Controllers: userController, groupController, messageController, reviewController
- Middleware: authMiddleware (JWT), upload (Multer)
- Models: User, Group, Message, Chat (room schema)
- Services: emailService (SMTP), Cloudinary integration (cloudinaryConfig.js)
- Socket.IO server (in server.js + firebase-admin for notifications)
- Static/public uploads directory
c. Database
- MongoDB collections corresponding to models
d. External Services
- Cloudinary for media storage
- Email service provider (via emailService.js)
- Optional Push notifications via Firebase Admin

##### Component Interactions & Data Flows
– User/browser → HTTP(S) requests → Express routes → Controllers → Mongoose → MongoDB
– After login/signup, frontend stores JWT → attaches to Authorization header → protected routes check authMiddleware
– Real-time chat: React components emit/receive events through Socket.IO client ↔ Socket.IO server
– File upload in chat: ReactForm → POST multipart via Multer middleware → files stored temporarily or uploaded to Cloudinary → URL returned to client → chat message saved
– Reviews & ratings: frontend dispatches Redux actions → API calls → reviewController persists to DB → updated stats fetched and displayed in dashboards
– Email notifications: certain events trigger emailService (e.g., group requests)

##### Architectural Patterns & Design Principles
– MVC-style layering in backend: Routes → Controllers → Models → Services
– Single-Page Application (SPA) on frontend organized by feature modules (Auth, Chat, Notes, Groups)
– State management via Redux Toolkit slices (separation of concerns, immutability)
– Real-time communications abstracted into a socket module both client/server sides
– File handling separated via dedicated middleware and external service (Cloudinary)

##### Technologies & Frameworks to Highlight
– React.js + Redux Toolkit + Tailwind CSS
– Vite as bundler for client (vite.config.js)
– Node.js + Express.js for REST API
– Socket.IO for real-time bidirectional events
– MongoDB + Mongoose for data persistence
– JWT + bcrypt for authentication/security
– Multer for multipart/form-data handling
– Cloudinary SDK for media uploads
– Firebase Admin for notifications (serviceAccountKey.json)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client (Frontend)"
        direction TB
        subgraph "UI Components" 
            direction TB
            Auth["Auth Components"]:::frontend
            ChatUI["Chat Components"]:::frontend
            Home["Home Components"]:::frontend
            Notes["Notes Components"]:::frontend
            TutorsList["TutorsList Components"]:::frontend
            TutorDashboard["TutorDashboard Components"]:::frontend
        end
        ReduxStore["Redux Store\n(store.js)"]:::frontend
        subgraph "Redux Slices"
            direction TB
            AuthSlice["authSlice.js"]:::frontend
            ChatSlice["chatSlice.js"]:::frontend
            GroupSlice["groupSlice.js"]:::frontend
            MessageSlice["messageSlice.js"]:::frontend
            ReviewSlice["reviewSlice.js"]:::frontend
            TutorSlice["tutorSlice.js"]:::frontend
        end
        SocketClient["Socket.IO Client\n(socket.js)"]:::frontend
        StaticAssets["Static Assets\n(pdfs/, hero.wav)"]:::frontend
        EntryPoint["Entry Point\n(main.jsx, index.html)"]:::frontend
    end

    %% Server Side
    subgraph "Server (Backend)"
        direction TB
        ExpressApp["Express App\n(server.js)"]:::backend
        DBConn["DB Connection\n(db.js)"]:::backend
        subgraph "Middleware"
            direction TB
            AuthMW["Auth Middleware\n(authMiddleware.js)"]:::backend
            UploadMW["Upload Middleware\n(upload.js)"]:::backend
        end
        subgraph "Routes"
            direction TB
            AuthRoutes["authRoutes.js"]:::backend
            UserRoutes["userRoutes.js"]:::backend
            ChatRoutes["chatRoutes.js"]:::backend
            GroupRoutes["groupRoutes.js"]:::backend
            MessageRoutes["messageRoutes.js"]:::backend
            ReviewRoutes["reviewRoutes.js"]:::backend
            EmailRoutes["emailRoutes.js"]:::backend
        end
        subgraph "Controllers"
            direction TB
            UserCtrl["userController.js"]:::backend
            GroupCtrl["groupController.js"]:::backend
            MessageCtrl["messageController.js"]:::backend
            ReviewCtrl["reviewController.js"]:::backend
        end
        subgraph "Models"
            direction TB
            UserModel["userModel.js"]:::database
            GroupModel["Group.js"]:::database
            MessageModel["Message.js"]:::database
            ChatModel["chat.js"]:::database
        end
        subgraph "Services"
            direction TB
            EmailService["emailService.js"]:::backend
            CloudinaryCfg["cloudinaryConfig.js"]:::backend
            FirebaseAdmin["firebase-admin.js"]:::external
        end
        SocketServer["Socket.IO Server"]:::backend
        TempUploads["Temp Uploads\n(public/temp/)"]:::database
        PersistUploads["Persistent Uploads\n(uploads/)"]:::database
    end

    %% Database & External
    MongoDB["MongoDB Atlas"]:::database
    Cloudinary["Cloudinary"]:::external
    SMTP["Email SMTP Provider"]:::external
    Firebase["Firebase Admin"]:::external

    %% Connections - Client to Server
    Auth -->|dispatches actions| ReduxStore
    ChatUI -->|dispatches actions| ReduxStore
    ReduxStore -->|HTTP Requests| ExpressApp
    AuthUIclick-->|HTTP|ExpressApp
    UIclickfake-->|HTTP|ExpressApp
    Auth -->|"HTTP Requests"| ExpressApp
    ChatUI -->|"WebSocket Events"| SocketClient
    SocketClient -.->|"Socket.IO"| SocketServer
    StaticAssets -->|serves assets| ExpressApp

    %% Server internal flows
    ExpressApp -->|uses| DBConn
    ExpressApp -->|applies| AuthMW
    ExpressApp -->|applies| UploadMW
    ExpressApp -->|routes to| AuthRoutes
    ExpressApp -->|routes to| UserRoutes
    ExpressApp -->|routes to| ChatRoutes
    ExpressApp -->|routes to| GroupRoutes
    ExpressApp -->|routes to| MessageRoutes
    ExpressApp -->|routes to| ReviewRoutes
    ExpressApp -->|routes to| EmailRoutes

    AuthRoutes -->|calls| UserCtrl
    UserRoutes -->|calls| UserCtrl
    ChatRoutes -->|calls| MessageCtrl
    GroupRoutes -->|calls| GroupCtrl
    MessageRoutes -->|calls| MessageCtrl
    ReviewRoutes -->|calls| ReviewCtrl
    EmailRoutes -->|calls| EmailService

    MessageCtrl -->|reads/writes| MessageModel
    GroupCtrl -->|reads/writes| GroupModel
    UserCtrl -->|reads/writes| UserModel
    ReviewCtrl -->|reads/writes| MessageModel
    ChatRoutes -->|uses| ChatModel

    UploadMW -->|stores in| TempUploads
    UploadMW -->|uploads to| Cloudinary
    CloudinaryCfg -->|integrates| Cloudinary

    UserCtrl -->|sends| EmailService
    EmailService -->|SMTP| SMTP
    SomeEvent -->|push notifications| FirebaseAdmin

    SocketServer -->|emits/receives| SocketClient

    %% Data Persistence
    MessageModel -->|persistence| MongoDB
    GroupModel -->|persistence| MongoDB
    UserModel -->|persistence| MongoDB
    ChatModel -->|persistence| MongoDB

    %% Click Events
    click Auth "https://github.com/vimalnegi03/tutor_finder/tree/main/client/src/components/Auth/"
    click ChatUI "https://github.com/vimalnegi03/tutor_finder/tree/main/client/src/components/Chat/"
    click Home "https://github.com/vimalnegi03/tutor_finder/tree/main/client/src/components/Home/"
    click Notes "https://github.com/vimalnegi03/tutor_finder/tree/main/client/src/Notes/"
    click TutorsList "https://github.com/vimalnegi03/tutor_finder/tree/main/client/src/components/TutorsList/"
    click TutorDashboard "https://github.com/vimalnegi03/tutor_finder/tree/main/client/src/components/TutorDashboard/"
    click ReduxStore "https://github.com/vimalnegi03/tutor_finder/blob/main/client/src/store/store.js"
    click AuthSlice "https://github.com/vimalnegi03/tutor_finder/blob/main/client/src/store/Slices/authSlice.js"
    click ChatSlice "https://github.com/vimalnegi03/tutor_finder/blob/main/client/src/store/Slices/chatSlice.js"
    click GroupSlice "https://github.com/vimalnegi03/tutor_finder/blob/main/client/src/store/Slices/groupSlice.js"
    click MessageSlice "https://github.com/vimalnegi03/tutor_finder/blob/main/client/src/store/Slices/messageSlice.js"
    click ReviewSlice "https://github.com/vimalnegi03/tutor_finder/blob/main/client/src/store/Slices/reviewSlice.js"
    click TutorSlice "https://github.com/vimalnegi03/tutor_finder/blob/main/client/src/store/Slices/tutorSlice.js"
    click SocketClient "https://github.com/vimalnegi03/tutor_finder/blob/main/client/src/socket.js"
    click StaticAssets "https://github.com/vimalnegi03/tutor_finder/tree/main/client/public/pdfs/"
    click EntryPoint "https://github.com/vimalnegi03/tutor_finder/blob/main/client/src/main.jsx"
    click ExpressApp "https://github.com/vimalnegi03/tutor_finder/blob/main/server/server.js"
    click DBConn "https://github.com/vimalnegi03/tutor_finder/blob/main/server/connectToDb/db.js"
    click CloudinaryCfg "https://github.com/vimalnegi03/tutor_finder/blob/main/server/cloudinaryConfig.js"
    click FirebaseAdmin "https://github.com/vimalnegi03/tutor_finder/blob/main/server/firebase-admin.js"
    click AuthMW "https://github.com/vimalnegi03/tutor_finder/blob/main/server/middleware/authMiddleware.js"
    click UploadMW "https://github.com/vimalnegi03/tutor_finder/blob/main/server/middleware/upload.js"
    click AuthRoutes "https://github.com/vimalnegi03/tutor_finder/blob/main/server/routes/authRoutes.js"
    click UserRoutes "https://github.com/vimalnegi03/tutor_finder/blob/main/server/routes/userRoutes.js"
    click ChatRoutes "https://github.com/vimalnegi03/tutor_finder/blob/main/server/routes/chatRoutes.js"
    click GroupRoutes "https://github.com/vimalnegi03/tutor_finder/blob/main/server/routes/groupRoutes.js"
    click MessageRoutes "https://github.com/vimalnegi03/tutor_finder/blob/main/server/routes/messageRoutes.js"
    click ReviewRoutes "https://github.com/vimalnegi03/tutor_finder/blob/main/server/routes/reviewRoutes.js"
    click EmailRoutes "https://github.com/vimalnegi03/tutor_finder/blob/main/server/routes/emailRoutes.js"
    click UserCtrl "https://github.com/vimalnegi03/tutor_finder/blob/main/server/controllers/userController.js"
    click GroupCtrl "https://github.com/vimalnegi03/tutor_finder/blob/main/server/controllers/groupController.js"
    click MessageCtrl "https://github.com/vimalnegi03/tutor_finder/blob/main/server/controllers/messageController.js"
    click ReviewCtrl "https://github.com/vimalnegi03/tutor_finder/blob/main/server/controllers/reviewController.js"
    click UserModel "https://github.com/vimalnegi03/tutor_finder/blob/main/server/models/userModel.js"
    click GroupModel "https://github.com/vimalnegi03/tutor_finder/blob/main/server/models/Group.js"
    click MessageModel "https://github.com/vimalnegi03/tutor_finder/blob/main/server/models/Message.js"
    click ChatModel "https://github.com/vimalnegi03/tutor_finder/blob/main/server/models/chat.js"
    click EmailService "https://github.com/vimalnegi03/tutor_finder/blob/main/server/services/emailService.js"
    click TempUploads "https://github.com/vimalnegi03/tutor_finder/tree/main/server/public/temp/"
    click PersistUploads "https://github.com/vimalnegi03/tutor_finder/tree/main/server/uploads/"

    classDef frontend fill:#E0F7FA,stroke:#0288D1,color:#000
    classDef backend fill:#E8F5E9,stroke:#2E7D32,color:#000
    classDef database fill:#FFF3E0,stroke:#EF6C00,color:#000
    classDef external fill:#EDE7F6,stroke:#6A1B9A,color:#000
```
