# amitsahoo7/e-learning-platform architecture

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

- Interactive diagram: https://gitdiagram.com/amitsahoo7/e-learning-platform
- Repository: https://github.com/amitsahoo7/e-learning-platform

## Overview

##### Project type and purpose
- This is a full-stack MERN (MongoDB, Express, React, Node.js) E-Learning Management System (e-LMS).
- Frontend: React + Tailwind CSS + Redux Toolkit + React Router + Axios.
- Backend: Node.js + Express + MongoDB/Mongoose + JWT auth + Multer file-uploads + bcrypt.

##### File structure
- Top-level “frontend” directory:
- A Vite-powered React SPA with `src/components`, `src/pages`, `src/context` (CourseContext, UserContext), `App.jsx`, and styling/config files.
- Uses environment variables (`.env`), ESLint, Tailwind and PostCSS, Vite config.
- Top-level “server” directory:
- Express app entry (`index.js`), environment config (`.env`).
- MVC pattern:
– **models/**: Mongoose schemas for Users, Courses, Lectures, Payments, Progress, Feedback
– **controllers/**: business logic per domain (user.js, course.js, admin.js, feedback.js)
– **routes/**: HTTP endpoints grouped by resource (/api/user, /api/course, /api/admin, /api/feedback)
– **middlewares/**: auth (isAuth), error handler (TryCatch), Multer file-upload config, sendMail
- Local file storage under `uploads/` for lecture videos and PDFs.
- Shared root: package.json, .gitignore, webServerApiSettings.json

##### README for additional insights
- Role-based access control: Students, Instructors, Admin
- Core features: Auth & RBAC, Course CRUD, Video lecture upload/organization, Student enrollment & progress tracking, Admin approval workflows
- Future: Payment integration (Stripe/Razorpay), quizzes, discussion forums

1. **Client (Browser/React SPA)**
– Pages: Home, Courses, CourseDescription, CourseStudy, Lecture, Account, Admin Dashboard, etc.
– State management: Contexts (CourseContext/UserContext) or Redux Toolkit
– API layer: Axios calls to backend
2. **API Layer (Node/Express Server)**
– Router: `/api/user`, `/api/course`, `/api/admin`, `/api/feedback`
– Controllers & Middlewares: Authentication (JWT), Authorization (RBAC), Error Handling, File Upload (Multer), Email Service
3. **Data Storage**
– **MongoDB** (collections: users, courses, lectures, payments, progress, feedback)
– **File System** (uploads folder for videos/PDFs; could be replaced by S3/minio)
4. **External Services**
– Email SMTP (sendMail middleware)
– (Future) Payment Gateway (Stripe/Razorpay)
– Client → Axios HTTP(S) → Express API
– Express → Middleware chain (auth → controllers)
– Controllers ↔ Mongoose → MongoDB
– Multer middleware → File System → returns file URL/path → DB
– Express → Email service (SMTP) for verification, notifications
– (Future) Express ↔ Payment Gateway API
c. Architectural patterns & design principles:
– **Client-Server** separation (clear boundary)
– **MVC-style** on backend (Models, Controllers, Routes)
– **RESTful** API endpoints
– **RBAC** using JWT and isAuth middleware
– **Context/Redux** on frontend for state isolation
– **Modular** directory structure for scalability and maintainability
d. Key technologies & frameworks:
– Frontend: React (JSX), Tailwind CSS, Vite, Axios, React Router, Redux Toolkit (or Context API)
– Backend: Node.js, Express, Mongoose, JWT, Multer, bcrypt, dotenv

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (React SPA)"
        direction TB
        FE_Entry["React SPA\nEntry Points"]:::frontend
        FE_Contexts["State Management\nCourseContext, UserContext"]:::frontend
        FE_Pages["Pages\n(src/pages)"]:::frontend
        FE_Components["Reusable Components\n(src/components)"]:::frontend
        FE_AdminUI["Admin UI\n(src/admin)"]:::frontend
        FE_Config["Routing & Config\nVite, Tailwind, Env"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Express API)"
        direction TB
        BE_Entry["Express API\nEntry Point"]:::backend
        BE_DBConn["DB Connection\n(database/db.js)"]:::backend
        subgraph "Models" 
            direction TB
            M_User["User Model"]:::backend
            M_Course["Course Model"]:::backend
            M_Lecture["Lecture Model"]:::backend
            M_Payment["Payment Model"]:::backend
            M_Progress["Progress Model"]:::backend
            M_Feedback["Feedback Model"]:::backend
        end
        subgraph "Controllers"
            direction TB
            C_User["User Controller"]:::backend
            C_Course["Course Controller"]:::backend
            C_Admin["Admin Controller"]:::backend
            C_Feedback["Feedback Controller"]:::backend
        end
        subgraph "Routes"
            direction TB
            R_User["/api/user"]:::backend
            R_Course["/api/course"]:::backend
            R_Admin["/api/admin"]:::backend
            R_Feedback["/api/feedback"]:::backend
        end
        subgraph "Middlewares"
            direction TB
            MW_Auth["isAuth (JWT/RBAC)"]:::backend
            MW_Error["TryCatch Error Handler"]:::backend
            MW_Multer["Multer File Upload"]:::backend
            MW_Email["sendMail Service"]:::backend
        end
        BE_Storage["File Storage\n(uploads/)"]:::storage
        BE_MongoDB["MongoDB"]:::db
        External_SMTP["SMTP Service"]:::external
        External_Payment["Payment Gateway\n(Future)"]:::external
    end

    %% Client-Server Interaction
    FE_Entry -->|HTTP/JSON via Axios| BE_Entry
    FE_Config -->|uses Routes| FE_Entry
    FE_Contexts -->|provides state to| FE_Pages
    FE_Components -->|used by| FE_Pages
    FE_AdminUI -->|protected routes| FE_Entry

    %% Backend Flow
    BE_Entry --> BE_DBConn
    BE_Entry --> R_User
    BE_Entry --> R_Course
    BE_Entry --> R_Admin
    BE_Entry --> R_Feedback

    R_User -->|middleware| MW_Auth
    R_User --> C_User
    R_Course --> MW_Auth
    R_Course --> C_Course
    R_Admin --> MW_Auth
    R_Admin --> C_Admin
    R_Feedback --> MW_Auth
    R_Feedback --> C_Feedback

    C_User --> M_User
    C_Course --> M_Course
    C_Course --> MW_Multer
    C_Course --> M_Lecture
    C_Course --> M_Progress
    C_Feedback --> M_Feedback
    C_User --> M_Progress
    C_User --> M_Payment

    MW_Multer --> BE_Storage
    BE_Storage --> M_Lecture

    BE_DBConn --> BE_MongoDB
    C_User --> BE_MongoDB
    C_Course --> BE_MongoDB
    C_Admin --> BE_MongoDB
    C_Feedback --> BE_MongoDB

    C_User --> MW_Email
    C_Admin --> MW_Email
    MW_Email --> External_SMTP

    BE_Entry -.-> External_Payment
    External_Payment --> BE_Entry

    %% Click Events - Frontend
    click FE_Entry "https://github.com/amitsahoo7/e-learning-platform/blob/main/frontend/src/App.jsx"
    click FE_Entry "https://github.com/amitsahoo7/e-learning-platform/blob/main/frontend/src/main.jsx"
    click FE_Contexts "https://github.com/amitsahoo7/e-learning-platform/blob/main/frontend/src/context/CourseContext.jsx"
    click FE_Contexts "https://github.com/amitsahoo7/e-learning-platform/blob/main/frontend/src/context/UserContext.jsx"
    click FE_Pages "https://github.com/amitsahoo7/e-learning-platform/tree/main/frontend/src/pages"
    click FE_Components "https://github.com/amitsahoo7/e-learning-platform/tree/main/frontend/src/components"
    click FE_AdminUI "https://github.com/amitsahoo7/e-learning-platform/tree/main/frontend/src/admin"
    click FE_Config "https://github.com/amitsahoo7/e-learning-platform/blob/main/frontend/src/App.jsx"
    click FE_Config "https://github.com/amitsahoo7/e-learning-platform/blob/main/frontend/vite.config.js"
    click FE_Config "https://github.com/amitsahoo7/e-learning-platform/blob/main/frontend/tailwind.config.cjs"
    click FE_Config "https://github.com/amitsahoo7/e-learning-platform/blob/main/frontend/.env"

    %% Click Events - Backend
    click BE_Entry "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/index.js"
    click BE_DBConn "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/database/db.js"
    click M_User "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/models/User.js"
    click M_Course "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/models/Courses.js"
    click M_Lecture "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/models/Lecture.js"
    click M_Payment "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/models/Payment.js"
    click M_Progress "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/models/Progress.js"
    click M_Feedback "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/models/Feedback.js"
    click C_User "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/controllers/user.js"
    click C_Course "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/controllers/course.js"
    click C_Admin "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/controllers/admin.js"
    click C_Feedback "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/controllers/feedback.js"
    click R_User "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/routes/user.js"
    click R_Course "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/routes/course.js"
    click R_Admin "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/routes/admin.js"
    click R_Feedback "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/routes/feedback.js"
    click MW_Auth "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/middlewares/isAuth.js"
    click MW_Error "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/middlewares/TryCatch.js"
    click MW_Multer "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/middlewares/multer.js"
    click MW_Email "https://github.com/amitsahoo7/e-learning-platform/blob/main/server/middlewares/sendMail.js"
    click BE_Storage "https://github.com/amitsahoo7/e-learning-platform/tree/main/server/uploads"
    click BE_Entry "https://github.com/amitsahoo7/e-learning-platform/blob/main/package.json"
    click BE_Entry "https://github.com/amitsahoo7/e-learning-platform/blob/main/webServerApiSettings.json"
    click BE_Entry "https://github.com/amitsahoo7/e-learning-platform/blob/main/.gitignore"
    click BE_Entry "https://github.com/amitsahoo7/e-learning-platform/blob/main/README.md"

    %% Styles
    classDef frontend fill:#D0EBFF,stroke:#1C7ED6,color:#1C7ED6
    classDef backend fill:#D3F9D8,stroke:#37B24D,color:#2F9E44
    classDef db fill:#FFE8CC,stroke:#FD7E14,color:#E8590C
    classDef storage fill:#FFF3BF,stroke:#FADB14,color:#F08A5D
    classDef external fill:#E9ECEF,stroke:#868E96,color:#495057
```
