Skip to content

hassaansaleem28/Learnix-LMS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Complete Case Study - Learnix LMS (Live App)

Overview

Learnix LMS is a full-featured Learning Management System built with Next.js with Typescript in frontend and Node.js and Express with Typescript in the backend. The system provides RESTful APIs for managing online courses, user authentication, course enrollment, payment processing, content delivery, and analytics. It follows a multi-layered architecture ensuring clear separation of concerns between routing, business logic, and data access.

System is designed to support :

o- Multi-role user management (Admin & Regular users)

o- Course creation & content management with video streaming

o- Secure payment processing via Stripe

o- Interactive learning features — questions, replies, and reviews

o- Real-time notifications

o- Administrative analytics & reporting

o- Dynamic layout management for frontend content


Project Goals

Learnix LMS is a community-driven platform built to help beginner developers grow into confident, industry-ready software engineers. It bridges the gap between theory and practice by offering curated lessons, real-world projects, and expert guidance—focusing on learning by doing rather than just consuming tutorials.

o- Beginner-friendly, practical learning: Emphasizes real-world application of concepts to build strong engineering foundations.
o- Community-driven growth: Encourages mentorship, collaboration, and peer feedback in a supportive environment.
o- Progress through consistency: Inspires learners to improve “one commit, one concept, one breakthrough at a time.”


System Architecture Overview

Learnix LMS follows a three-tier architecture consisting of a Node.js/Express backend, MongoDB database, and Next.js frontend.
This design ensures scalability, modularity, and smooth integration between client and server.

Layer Description Key Components / Features
Backend Layer Built with Express.js, exposing RESTful APIs for core LMS operations. - User Management (/api/v1/user) – Authentication, registration, profiles
- Course Management (/api/v1/course) – Courses, questions, reviews
- Order Processing (/api/v1/order) – Purchases, Stripe payments
- Notifications (/api/v1/notifications) – Real-time system updates
- Analytics (/api/v1/analytics) – Usage and performance tracking
- Layout (/api/v1/layout) – Manage banners, FAQs, categories

Extras: Rate limiting (100 req / 15 min / IP), middleware for errors & cookies
Data Layer Uses MongoDB with Mongoose ODM for data modeling and schema validation. - User Model: Credentials, bcrypt hashing, JWT tokens
- Course Model: Course content, videos, reviews, discussions
- Order Model: Purchase and payment tracking
Frontend Layer Built using Next.js 13+ and React, providing a seamless user experience. - Redux Toolkit + RTK Query: State and API management
- Socket.io Client: Real-time communication
- NextAuth: Session and authentication management
- API Slices: Modular endpoints (analytics, layout, orders)
Security Features Ensures data safety and controlled access across the system. - JWT Authentication: Access (5 min) & refresh (3 days) tokens
- CORS: Configured for specific frontend origin
- Password Hashing: Bcrypt encryption for user credentials

System Architecture Diagram

graph TD
  %% Layers
  subgraph Client Layer
    NextJS[Next.js Frontend]
    Redux[RTK Query State Management]
    SocketClient[Socket.io Client]
  end

  subgraph API Layer
    REST[REST API Endpoints]
    SocketServer[Socket.io Server]
    Express[Express.js Backend]
  end

  subgraph Data Layer
    MongoDB[MongoDB]
    Redis[Redis Cache]
    Cloudinary[Cloudinary Storage]
  end

  %% Connections
  NextJS -->|HTTP| REST
  Redux --> NextJS
  SocketClient -->|WebSocket| SocketServer

  REST --> Express
  SocketServer --> Express

  Express --> MongoDB
  Express --> Redis
  Express --> Cloudinary
Loading

System Data flow

sequenceDiagram
    participant User
    participant Frontend
    participant Redux as Redux / RTK Query
    participant Backend as Backend API
    participant Redis as Redis Cache
    participant MongoDB

    User->>Frontend: User Action
    Frontend->>Redux: Dispatch Action
    Redux->>Backend: HTTP Request
    Backend->>Redis: Check Cache
    alt Cache Hit
        Redis-->>Backend: Return Cached Data
    else Cache Miss
        Backend->>MongoDB: Query Database
        MongoDB-->>Backend: Return Data
        Backend->>Redis: Update Cache
    end
    Backend-->>Redux: API Response
    Redux->>Frontend: Update State
    Frontend->>User: Render UI
Loading

Key Features

Learnix is a community-driven Learning Management System (LMS) designed for aspiring developers who want to build real-world skills. It combines technical depth with collaborative learning to help users go beyond tutorials and start shipping production-ready applications.

1- Course Management

Learnix supports comprehensive course structures with the following features:

o- Video-based learning
Each course includes thumbnails, demo URLs, and structured video sections.

o- Benefits and prerequisites tracking
Courses define clear learning outcomes and entry requirements.

o- Reviews and ratings system
Students can leave feedback and rate courses from 1 to 5 stars.

o- Q&A functionality
Threaded question replies allow detailed discussions between students and instructors.

2- Technical Features

o- Real-time communication
Socket.io integration enables live interactions across the platform.

o- Theme support
Dark/light mode with smooth transitions for personalized viewing.

o- Main sections
Includes hero landing, course catalog, reviews, and FAQ components.

3- Course Creation & Administration

o- Multi-step course creation workflow
Admins define course name, description, pricing, tags, categories, difficulty level, demo URL, and thumbnail.

o- Benefits & prerequisites
Multiple learning outcomes and entry requirements per course.

o- Video content structure
Lessons include video URLs, titles, descriptions, length tracking, and resource links.

o- Full CRUD operations
Admins can create, read, update, and delete courses via dedicated API endpoints.

o- Course listing dashboard
Data grid interface with ratings, purchase counts, creation dates, and edit/delete actions.

4- Interactive Learning Features

o- Q&A System
o- Students post questions linked to specific video content.
o- Instructors receive notifications for new questions.
o- Threaded replies support detailed discussions.

o- Review & Rating System
o- Students submit reviews and star ratings.
o- Admins can reply with access-controlled responses.
o- Ratings are calculated and displayed with review counts.

5- Student Learning Experience

o- Video Player & Navigation
o- Authenticated students access purchased content.
o- Previous/next controls with disabled states at boundaries.
o- Tabbed interface for Overview, Resources, Q&A, and Reviews.

o- Course Discovery
o- Category filtering with visual interface.
o- Responsive course cards with search functionality.
o- Dedicated course pages with full details and reviews.

6- Payment & Enrollment

o- Stripe integration
Secure payment processing with dynamic pricing.

o- Purchase verification
Enrollment is restricted to users who have purchased the course.

7- Learning Platform Capabilities

o- Beginner-friendly, industry-ready approach
Bridges the gap between theory and practice with curated lessons, hands-on challenges, and expert insights.

o- Real-world workflows
Every module reflects actual engineering practices—not just textbook examples.

o- Community collaboration
A vibrant space where feedback is constructive, mentorship is accessible, and progress is visible.

8- Real - time Notifications to admins

o- Course Purchased Notification
Whenever someone purchased a course then a real time notification with sound plays at admin side with all the details of user who purchased the course.

o- New Review added Notification
Whenever a student added a review to the course then also a real time notification is added to the admin side to notify the admin about the review.

o- Discussion in Q/A Notifications
Discussion about the course in the Q/A section notifies the admin about the issues that student are facing in the course.


API Architecture

Learnix features an organized RESTful API structure, with endpoints grouped by business domain for clarity and scalability:

o- User Authentication & Profiles /api/v1/user/*

o- Course Catalog Operations /api/v1/course/*

o- Order Processing /api/v1/order/*

o- Notification System /api/v1/notifications/*

o- Analytics & Reporting /api/v1/analytics/*

o- Layout Customization /api/v1/layout/*


Tech Stack

graph TD
    %% === Runtime Environment ===
    A["Node.js Runtime"] --> B["Express 4.x"]

    %% === Utilities ===
    B --> U1["dotenv"]
    U1 --> U2["ejs (email templates)"]

    %% === External Services SDK ===
    B --> S1["cloudinary"]
    B --> S2["stripe"]
    B --> S3["axios (VDO Cipher)"]
    B --> S4["nodemailer"]

    %% === Authentication & Security ===
    B --> AS1["jsonwebtoken"]
    B --> AS2["bcryptjs"]

    %% === Database Layer ===
    B --> DB1["mongoose"]
    DB1 --> DB11["MongoDB"]
    B --> DB2["redis client"]
    DB2 --> DB22["Redis"]

    %% === Core Middleware ===
    B --> M1["cookie-parser"]
    B --> M2["cors"]
    B --> M3["express-rate-limit"]
    B --> M4["express.json (50MB limit)"]

Loading

Backend

  • Node.js (v18.x) – JavaScript runtime for server-side applications
  • Express.js (v5.1.0) – Web application framework
  • MongoDB + Mongoose (v8.18.1) – NoSQL database with object modeling
  • JWT (jsonwebtoken v9.0.2) – Token-based authentication
  • bcryptjs (v3.0.2) – Password hashing
  • Nodemailer (v7.0.6) – Email handling
  • Stripe (v19.3.0) – Payment processing

Additional Backend Tools:

  • TypeScript (v5.9.2) – Type-safe JavaScript
  • Redis (ioredis v5.7.0) – Caching and session management
  • EJS (v3.1.10) – Email templating
  • express-rate-limit (v8.2.1) – API rate limiting

Frontend

  • Next.js (v13.5.11) – React framework (not Vite)
  • React (v18) – UI library
  • Redux Toolkit (v2.9.0) – State management

Additional Frontend Tools:

  • TypeScript (v5) – Type safety
  • Tailwind CSS (v3) – Utility-first styling
  • Material-UI (v7.3.4) – Component library
  • NextAuth (v4.24.11) – Authentication

File & Media Handling

  • Cloudinary (v2.7.0) – Cloud-based media storage

Real-time Communication

  • Socket.io – Bi-directional communication for notifications

Development & Deployment


Challenges and Solutions

Challenge Solution
JWT setup was confusing due to access/refresh token lifecycle Implemented proper token rotation and refresh logic for seamless authentication flow
Purchased count not updating during order creation Used Mongoose’s $inc operator to increment the count reliably during order processing
Cache not updating after data changes Added logic to update Redis cache after mutations to maintain consistency
Vdocipher integration errors while fetching and displaying videos Debugged API flow and resolved frontend/backend sync issues for smooth playback
TypeScript model and relationship errors Learned advanced TypeScript patterns and fixed model definitions and schema joins
Frontend API setup issues with Vdocipher Spent time understanding Vdocipher’s frontend flow and resolved integration bugs
Tailwind screen config broke responsive classes Researched and corrected screen setup using community help and GPT
UI/UX issues in admin panel and course overview component Refactored layout and logic to improve design and usability in critical admin views
Business logic errors in course creation and review system Refined controller logic and added validation to ensure correct review and course data handling
Debugging nested Q&A replies and review threading Adjusted schema and frontend rendering to support recursive replies and admin moderation

Database Design

erDiagram
    USER {
        string _id
        string name
        string email
        string password
        string role
        boolean isCreator
        array courses
        timestamp createdAt
        timestamp updatedAt
    }

    NOTIFICATION {
        string _id
        string title
        string status
        timestamp createdAt
        timestamp updatedAt
    }

    LAYOUT {
        string _id
        string logo
        array categories
        object banners
    }

    COURSE {
        string _id
        string name
        string description
        number price
        object thumbnail
        string category
        string demoUrl
        array benefits
        array prerequisites
        array courseData
        array courseClub
        number purchased
        timestamp updatedAt
    }

    ORDER {
        string _id
        string courseId
        string userId
        object payment_info
        timestamp updatedAt
    }

    REVIEW {
        string _id
        number rating
        string userId
        array commentReplies
        timestamp createdAt
        timestamp updatedAt
    }

    COURSECLUB {
        string _id
        string description
        object videoThumbnail
        string videoUrl
        number videoLength
        string category
        array links
        array questions
    }

    QUESTION {
        object _id
        string question
        array commentReplies
        timestamp createdAt
        timestamp updatedAt
    }

    ANSWER {
        string _id
        string answer
        timestamp createdAt
        timestamp updatedAt
    }

    LINK {
        string _id
        string url
    }

    %% Relationships (Crow's Foot style)
    USER ||--o{ ORDER : places
    USER ||--o{ REVIEW : writes
    USER ||--o{ NOTIFICATION : receives
    USER ||--o{ COURSE : enrolls

    COURSE ||--o{ REVIEW : has
    COURSE ||--o{ COURSECLUB : contains
    ORDER }o--|| COURSE : ordered_in
    REVIEW }o--|| COURSE : related_to

    COURSECLUB ||--o{ QUESTION : has
    QUESTION ||--o{ ANSWER : has_replies
    COURSECLUB ||--o{ LINK : includes

Loading

Application Flow Diagram

flowchart TD
    A[User Visits Site] --> B[Landing Page]

    B --> C[Sign Up/Login]
    B --> D[Browse]

    C --> E[Authentication]
    E --> F[Success]
    F --> G[User Dashboard]

    D --> H[Courses Page]
    H --> I[Search/Filter]
    I --> J[Course Listing]
    J --> K[Select Course]
    K --> L[Course Details Page]

    L --> M[Not Purchased]
    L --> N[Already Purchased]

    %% Purchase Flow
    M --> O[Payment Flow]
    O --> P[Stripe Checkout]
    P --> Q[Create Payment Intent]
    Q --> R[Success]
    R --> S[Create Order]

    N --> T[Course Access]
    S --> T

    %% Course Access Path
    T --> U[Video Player]
    U --> V[Navigation]
    V --> W[Course Content List]
    V --> X[User Interactions]

    %% User Interaction Branches
    X --> Y1[Ask Question]
    Y1 --> Y2[Add Question API]

    X --> Z1[Reply to Question]
    Z1 --> Z2[Add Reply API]

    X --> A1[Add Review]
    A1 --> A2[Add Review API]

    %% Admin Flow
    X --> B1[Admin Panel]
    B1 --> B2[Create/Edit]
    B2 --> B3[Course Management]
    B3 --> B4[Upload]
    B4 --> B5[Watch/Update Video]

    %% Backend & System
    X --> C1[Backend Processing]
    C1 --> C2[Update]
    C1 --> C3[Cache]
    C3 --> C4[MongoDB]
    C3 --> C5[Redis Cache]
    C1 --> C6[Notify]
    C6 --> C7[Notification System]

Loading

User Flow

sequenceDiagram
    actor User
    participant Browser
    participant Backend
    participant BackendDB as Backend<br/>Database
    participant MongoDB
    participant Redis
    participant Stripe
    participant VideoPlayer

    %% --- User visits site ---
    User ->> Browser: Visit Website
    Browser ->> Backend: Load Landing Page
    Backend ->> Browser: Display Banners, Courses, FAQs

    %% --- Login / Signup ---
    User ->> Browser: Click Sign Up / Login
    Browser ->> Backend: POST /api/v1/login
    Backend ->> Redis: Create New Session
    Backend ->> Browser: Login Success

    %% --- Course browsing ---
    User ->> Browser: Browse Courses
    Browser ->> Backend: GET /api/v1/courses
    Backend ->> BackendDB: Fetch Course List
    BackendDB -->> Backend: Return Courses
    Backend ->> Browser: Display Course Cards

    %% --- Select a course ---
    User ->> Browser: Select Course
    Browser ->> Backend: GET /api/v1/course/:id
    Backend ->> BackendDB: Fetch Course Details
    BackendDB -->> Backend: Return Course Data
    Backend ->> Browser: Display Course Details

    %% --- Purchase decision ---
    alt Not Purchased
        User ->> Browser: Click Buy Now
        Browser ->> Backend: Open Payment Modal
        Browser ->> Backend: POST /api/v1/payment
        Backend ->> Stripe: Create Payment Intent
        Stripe -->> Backend: Payment Created
        Backend ->> Browser: Client Secret
        Browser ->> Stripe: Process Payment
        Stripe -->> Browser: Payment Success
        Browser ->> Backend: POST /api/v1/order/create
        Backend ->> BackendDB: Create Order Record
        Backend ->> MongoDB: Update User Courses
        MongoDB -->> Backend: Confirm Update
        Backend ->> Browser: Success Message
    else Already Purchased
        Browser ->> Backend: Check Purchase Status
        Backend ->> BackendDB: Verify Purchase
        BackendDB -->> Backend: Valid Purchase
        Backend ->> Browser: Grant Access
    end

    %% --- Course access ---
    User ->> Browser: Access Course
    Browser ->> Backend: GET /api/v1/courseClub
    Backend ->> BackendDB: Fetch CourseClub Data
    BackendDB -->> Backend: Return CourseClub
    Backend ->> Browser: Display Course Club
    Browser ->> VideoPlayer: Stream Video

    %% --- Q&A interactions ---
    User ->> Browser: Ask Question
    Browser ->> Backend: POST /api/v1/course/question
    Backend ->> MongoDB: Add Question to Course
    MongoDB -->> Backend: Confirm Insertion
    Backend ->> Browser: Question Added

    User ->> Browser: Reply to Question
    Browser ->> Backend: POST /api/v1/course/reply
    Backend ->> MongoDB: Add Reply to Question
    MongoDB -->> Backend: Confirm Update
    Backend ->> Browser: Reply Added

    %% --- Reviews ---
    User ->> Browser: Add Review
    Browser ->> Backend: POST /api/v1/course/review
    Backend ->> MongoDB: Update Course Reviews
    MongoDB -->> Backend: Review Stored
    Backend ->> Browser: Review Added

Loading

Admin Flow

sequenceDiagram
    actor Admin
    participant Browser
    participant Backend
    participant BackendDB as Backend<br/>Database
    participant MongoDB
    participant Redis
    participant VideoPlayer

    %% --- Admin login ---
    Admin ->> Browser: Visit Admin Panel
    Browser ->> Backend: Load Admin Dashboard
    Backend ->> Browser: Display Login Page
    Admin ->> Browser: Enter Credentials
    Browser ->> Backend: POST /api/v1/admin/login
    Backend ->> Redis: Create Admin Session
    Backend ->> Browser: Login Success

    %% --- Course Management ---
    Admin ->> Browser: Create New Course
    Browser ->> Backend: POST /api/v1/course/create
    Backend ->> MongoDB: Insert Course Data
    MongoDB -->> Backend: Course Created
    Backend ->> Browser: Display Created Course

    %% --- Upload Thumbnail ---
    Admin ->> Browser: Upload Thumbnail
    Browser ->> Backend: POST /api/v1/course/thumbnail
    Backend ->> MongoDB: Update Thumbnail Field
    MongoDB -->> Backend: Updated
    Backend ->> Browser: Confirmation Message

    %% --- Add Course Content ---
    Admin ->> Browser: Add Course Content
    Browser ->> Backend: POST /api/v1/course/content
    Backend ->> MongoDB: Insert Course Content
    MongoDB -->> Backend: Content Added
    Backend ->> Browser: Content Added Successfully

    %% --- Manage CourseClub ---
    Admin ->> Browser: Add CourseClub
    Browser ->> Backend: POST /api/v1/courseClub/create
    Backend ->> MongoDB: Create CourseClub Entry
    MongoDB -->> Backend: Confirm CourseClub
    Backend ->> Browser: Display CourseClub Created

    %% --- Manage Questions ---
    Admin ->> Browser: View CourseClub Questions
    Browser ->> Backend: GET /api/v1/courseClub/questions
    Backend ->> MongoDB: Fetch All Questions
    MongoDB -->> Backend: Return Questions
    Backend ->> Browser: Display Questions

    Admin ->> Browser: Reply to Question
    Browser ->> Backend: POST /api/v1/courseClub/reply
    Backend ->> MongoDB: Insert Reply to Question
    MongoDB -->> Backend: Reply Stored
    Backend ->> Browser: Reply Added Successfully

    %% --- Manage Reviews ---
    Admin ->> Browser: View Reviews
    Browser ->> Backend: GET /api/v1/reviews
    Backend ->> MongoDB: Fetch Reviews
    MongoDB -->> Backend: Return Reviews
    Backend ->> Browser: Display Reviews

    Admin ->> Browser: Delete Review
    Browser ->> Backend: DELETE /api/v1/review/:id
    Backend ->> MongoDB: Remove Review
    MongoDB -->> Backend: Deletion Confirmed
    Backend ->> Browser: Review Removed

    %% --- System Updates & Cache ---
    Backend ->> Redis: Cache Course Data
    Backend ->> MongoDB: Sync Updates
    Redis -->> Backend: Cache Updated
    MongoDB -->> Backend: Data Synced

    %% --- Notification ---
    Backend ->> Browser: Trigger Admin Notification
    Browser ->> Admin: Display Notification

Loading

Best Practices

TypeScript Integration (Frontend & Backend)

The entire Learnix LMS project is built using TypeScript across both frontend and backend layers.
This ensures strong type safety, better scalability, and early error detection during development.
By enforcing strict type definitions, it reduces runtime bugs and improves maintainability across complex modules such as course management, authentication, and data processing.

Secure Authentication with Access & Refresh Tokens

For robust security, the backend uses a combination of Access Tokens and Refresh Tokens.
This approach enhances session security, prevents unauthorized access, and allows seamless token renewal without requiring users to log in repeatedly.
It follows modern security standards for JWT-based authentication and token lifecycle management.

Efficient State Management with RTK Query

The frontend leverages RTK Query, a part of Redux Toolkit, for efficient and real-time state synchronization.
This enables automatic caching, data fetching, and revalidation of API calls, significantly reducing boilerplate code and improving app performance.
It ensures that Learnix LMS delivers a responsive and up-to-date experience even under heavy data flow.

Enhanced User Experience (UX)

The platform is designed with a focus on clarity, accessibility, and ease of use.
From intuitive navigation to consistent interface elements, Learnix LMS ensures users can engage with courses, dashboards, and content smoothly.
A responsive layout and clear feedback mechanisms contribute to a seamless learning experience across devices.


Conclusion

Learnix LMS stands out as a complete, scalable, and production-ready Learning Management System.
It unites learners, instructors, and administrators in one collaborative ecosystem focused on real-world skill development.
With robust authentication, a TypeScript-based architecture, and seamless state management through RTK Query, it ensures reliability and performance. Designed for both growth and community engagement, Learnix LMS bridges theory and practice to help developers become industry-ready professionals.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors