# m-deb-16/classlink architecture

> Architecture diagram of the GitHub repository m-deb-16/classlink, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/m-deb-16/classlink
- Repository: https://github.com/m-deb-16/classlink

## Overview

##### Project type and purpose
- This is a full-stack MERN application called ClassLink.
- Purpose: educational resource and event organizer with user authentication, resource uploads, event management, and a discussion forum.

##### File structure
- Top-level split:
– client/ → React front end
– server/ → Node.js/Express back end
- client/
– src/components & src/pages → React UI components (cards, navbar, footer, forms, pages)
– src/utils/auth.js → front-end JWT handling
– public/index.html, vite.config.js → build & entry points
- server/
– models/ → Mongoose schemas (User, Resource, Event, Doubt)
– routes/ → Express routers for auth, resources, events, discussions
– middleware/ → auth (JWT verification) and upload (Multer/GridFS)
– server.js → Express app setup, connection to MongoDB, middleware, router mounting
- Config files:
– .env.sample → environment variables (JWT secret, Mongo URI, GridFS bucket)
– package.json in root orchestrates concurrently for running both client & server

##### Key architecture insights from README
- Frontend: React (+ React-Bootstrap & CSS) served by Vite dev server
- Backend: Express API exposes REST endpoints with JWT authentication
- Database: MongoDB for data + GridFS for file storage
- Authentication: JWT passed between client and server via HTTP headers
- File uploads: Multer (Express middleware) streams to GridFS in MongoDB

a. Main components
– Browser (User) → React SPA (client)
– API Layer (Express server)
– Authentication Service (JWT validation/issuance)
– Storage Layer
- MongoDB (collections for users, resources, events, doubts)
- GridFS bucket for uploaded files
– External services (optional): e.g., email/SMS for notifications
b. Relationships & interactions
– User interacts with React UI → triggers API calls (login, CRUD on resources/events, post doubts)
– API Layer uses auth middleware to verify JWT on protected routes
– API Layer interacts with MongoDB via Mongoose models
– File upload endpoints use Multer middleware to store files in GridFS
– API responses return JSON payloads to React
c. Architectural patterns/design principles
– Separation of concerns: UI vs. API vs. data persistence
– Component-based UI design in React
– MVC-style on server: routes (controller), models (Mongoose), middleware (service logic)
– RESTful API design
– Stateless authentication via JWT
d. Technologies & frameworks
– React, Vite, React-Bootstrap (UI layer)
– Node.js, Express, Multer, JWT (API layer)
– MongoDB, Mongoose, GridFS (persistence)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Frontend Zone
    subgraph "Frontend (React App)"
        direction TB
        Browser["User Browser"]:::frontend
        ReactApp["React App"]:::frontend

        subgraph "Entry Points"
            direction TB
            Main["main.jsx"]:::frontend
            App["App.jsx"]:::frontend
        end

        subgraph "UI Components"
            direction TB
            EventCard["EventCard.jsx"]:::frontend
            ResourceCard["ResourceCard.jsx"]:::frontend
            RecentResources["RecentResources.jsx"]:::frontend
            Navbar["NavbarComponent.jsx"]:::frontend
            Footer["FooterComponent.jsx"]:::frontend
        end

        subgraph "Pages"
            direction TB
            Dashboard["Dashboard.jsx"]:::frontend
            ResourcesPage["Resources.jsx"]:::frontend
            EventsPage["Events.jsx"]:::frontend
            DiscussionPage["Discussion.jsx"]:::frontend
            LoginPage["Login.jsx"]:::frontend
            RegisterPage["Register.jsx"]:::frontend
            ContactFormPage["ContactForm.jsx"]:::frontend
        end

        AuthUtil["auth.js"]:::frontend
        BuildConfig["vite.config.js"]:::frontend
        HTML["index.html"]:::frontend
        ClientPkg["package.json"]:::frontend

        Browser -->|"loads"| ReactApp
        ReactApp -->|renders| Main
        ReactApp -->|mounts| App
        ReactApp -->|uses| EventCard
        ReactApp -->|uses| ResourceCard
        ReactApp -->|uses| RecentResources
        ReactApp -->|uses| Navbar
        ReactApp -->|uses| Footer
        ReactApp -->|routes| Dashboard
        ReactApp -->|routes| ResourcesPage
        ReactApp -->|routes| EventsPage
        ReactApp -->|routes| DiscussionPage
        ReactApp -->|routes| LoginPage
        ReactApp -->|routes| RegisterPage
        ReactApp -->|routes| ContactFormPage
        ReactApp -->|handles JWT| AuthUtil
        ReactApp -->|config| BuildConfig
        ReactApp -->|entry| HTML
        ReactApp -->|deps| ClientPkg
    end

    %% Backend Zone
    subgraph "Backend (API Layer)"
        direction TB
        ExpressServer["server.js"]:::api

        subgraph "Middleware"
            direction TB
            AuthMW["auth.js"]:::api
            UploadMW["upload.js"]:::api
        end

        subgraph "Routers"
            direction TB
            AuthRouter["authRoutes.js"]:::api
            ResourceRouter["resourceRoutes.js"]:::api
            EventRouter["eventRoutes.js"]:::api
            DiscussionRouter["discussionRoutes.js"]:::api
        end

        subgraph "Models"
            direction TB
            UserModel["User.js"]:::db
            ResourceModel["Resource.js"]:::db
            EventModel["Event.js"]:::db
            DoubtModel["Doubt.js"]:::db
        end

        EnvSample[".env.sample"]:::api
        ServerPkg["package.json"]:::api
    end

    %% Database Zone
    subgraph "Database & Storage"
        direction TB
        MongoDB["MongoDB"]:::db
        Collections["Collections"]:::db
        GridFS["GridFS Bucket"]:::db
    end

    %% Interactions
    ReactApp -->|"HTTP Request"| ExpressServer
    ExpressServer -->|use| AuthMW
    ExpressServer -->|use| UploadMW
    ExpressServer -->|mount| AuthRouter
    ExpressServer -->|mount| ResourceRouter
    ExpressServer -->|mount| EventRouter
    ExpressServer -->|mount| DiscussionRouter
    AuthRouter -->|"controller"| UserModel
    ResourceRouter -->|"controller"| ResourceModel
    EventRouter -->|"controller"| EventModel
    DiscussionRouter -->|"controller"| DoubtModel
    UserModel -->|CRUD| MongoDB
    ResourceModel -->|CRUD| MongoDB
    EventModel -->|CRUD| MongoDB
    DoubtModel -->|CRUD| MongoDB
    UploadMW -->|stream| GridFS
    ExpressServer -->|"reads env"| EnvSample
    ExpressServer -->|"deps"| ServerPkg

    MongoDB -->|stores| Collections
    Collections -->|contains| UserModel
    Collections -->|contains| ResourceModel
    Collections -->|contains| EventModel
    Collections -->|contains| DoubtModel

    %% Click Events - Frontend
    click Main "https://github.com/m-deb-16/classlink/blob/main/client/src/main.jsx"
    click App "https://github.com/m-deb-16/classlink/blob/main/client/src/App.jsx"
    click EventCard "https://github.com/m-deb-16/classlink/blob/main/client/src/components/EventCard.jsx"
    click ResourceCard "https://github.com/m-deb-16/classlink/blob/main/client/src/components/ResourceCard.jsx"
    click RecentResources "https://github.com/m-deb-16/classlink/blob/main/client/src/components/RecentResources.jsx"
    click Navbar "https://github.com/m-deb-16/classlink/blob/main/client/src/components/NavbarComponent.jsx"
    click Footer "https://github.com/m-deb-16/classlink/blob/main/client/src/components/FooterComponent.jsx"
    click Dashboard "https://github.com/m-deb-16/classlink/blob/main/client/src/pages/Dashboard.jsx"
    click ResourcesPage "https://github.com/m-deb-16/classlink/blob/main/client/src/pages/Resources.jsx"
    click EventsPage "https://github.com/m-deb-16/classlink/blob/main/client/src/pages/Events.jsx"
    click DiscussionPage "https://github.com/m-deb-16/classlink/blob/main/client/src/pages/Discussion.jsx"
    click LoginPage "https://github.com/m-deb-16/classlink/blob/main/client/src/pages/Login.jsx"
    click RegisterPage "https://github.com/m-deb-16/classlink/blob/main/client/src/pages/Register.jsx"
    click ContactFormPage "https://github.com/m-deb-16/classlink/blob/main/client/src/pages/ContactForm.jsx"
    click AuthUtil "https://github.com/m-deb-16/classlink/blob/main/client/src/utils/auth.js"
    click HTML "https://github.com/m-deb-16/classlink/blob/main/client/index.html"
    click BuildConfig "https://github.com/m-deb-16/classlink/blob/main/client/vite.config.js"
    click ClientPkg "https://github.com/m-deb-16/classlink/blob/main/client/package.json"

    %% Click Events - Backend
    click ExpressServer "https://github.com/m-deb-16/classlink/blob/main/server/server.js"
    click AuthMW "https://github.com/m-deb-16/classlink/blob/main/server/middleware/auth.js"
    click UploadMW "https://github.com/m-deb-16/classlink/blob/main/server/middleware/upload.js"
    click AuthRouter "https://github.com/m-deb-16/classlink/blob/main/server/routes/authRoutes.js"
    click ResourceRouter "https://github.com/m-deb-16/classlink/blob/main/server/routes/resourceRoutes.js"
    click EventRouter "https://github.com/m-deb-16/classlink/blob/main/server/routes/eventRoutes.js"
    click DiscussionRouter "https://github.com/m-deb-16/classlink/blob/main/server/routes/discussionRoutes.js"
    click UserModel "https://github.com/m-deb-16/classlink/blob/main/server/models/User.js"
    click ResourceModel "https://github.com/m-deb-16/classlink/blob/main/server/models/Resource.js"
    click EventModel "https://github.com/m-deb-16/classlink/blob/main/server/models/Event.js"
    click DoubtModel "https://github.com/m-deb-16/classlink/blob/main/server/models/Doubt.js"
    click EnvSample "https://github.com/m-deb-16/classlink/blob/main/server/.env.sample"
    click ServerPkg "https://github.com/m-deb-16/classlink/blob/main/server/package.json"

    %% Styles
    classDef frontend fill:#D0EBFF,stroke:#1C7ED6,color:#1C7ED6
    classDef api fill:#DFFFD0,stroke:#63E6BE,color:#2F9E44
    classDef db fill:#FFEFD0,stroke:#FAB005,color:#B4690E
```
