Skip to content

venkatesh-i2i/lms-codebase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Learning Management System - Microservices Architecture

πŸ—οΈ Architecture Overview

This project implements a comprehensive Learning Management System (LMS) using a microservices architecture with Spring Boot 3, WebFlux, PostgreSQL, Redis, RabbitMQ, and Kubernetes deployment.

🎯 Services Architecture

Core Business Services

  1. User Service (Port: 8081) - User management, authentication, profiles
  2. Course Service (Port: 8082) - Course content, modules, lessons
  3. Enrollment Service (Port: 8083) - Student enrollments, progress tracking
  4. Assessment Service (Port: 8084) - Quizzes, assignments, grading
  5. Notification Service (Port: 8085) - Email, push notifications

Infrastructure Services

  1. API Gateway (Port: 8080) - Spring Cloud Gateway for routing
  2. Config Server (Port: 8888) - Centralized configuration
  3. Discovery Server (Port: 8761) - Eureka service registry

πŸ› οΈ Technology Stack

  • Framework: Spring Boot 3.2.0
  • Reactive: Spring WebFlux
  • Database: PostgreSQL with R2DBC
  • Caching: Redis
  • Message Broker: RabbitMQ
  • Service Discovery: Eureka
  • API Gateway: Spring Cloud Gateway
  • Security: JWT + OAuth2
  • Containerization: Docker
  • Orchestration: Kubernetes
  • Monitoring: Prometheus + Grafana

πŸ—„οΈ Database Design

Each service has its own PostgreSQL database following the database-per-service pattern:

User Service Database

- users (id, username, email, password_hash, first_name, last_name, role, status)
- user_profiles (id, user_id, bio, avatar_url, phone, preferences)

Course Service Database

- courses (id, title, description, instructor_id, category_id, level, price)
- course_modules (id, course_id, title, description, order_index)
- lessons (id, module_id, title, content, video_url, duration_minutes)
- course_categories (id, name, description, parent_id)

Enrollment Service Database

- enrollments (id, student_id, course_id, enrollment_date, progress_percentage)
- lesson_progress (id, enrollment_id, lesson_id, completed_at, time_spent)
- learning_paths (id, name, description, created_by)

Assessment Service Database

- assessments (id, course_id, title, type, max_score, time_limit)
- assessment_questions (id, assessment_id, question_text, question_type, points)
- assessment_submissions (id, assessment_id, student_id, score, status)

Notification Service Database

- notifications (id, recipient_id, type, message, status, sent_at)
- notification_templates (id, name, type, subject, body, variables)
- notification_preferences (id, user_id, email_enabled, push_enabled)

πŸ”Œ API Endpoints

User Service (/api/v1/users)

  • POST / - Create user
  • GET /{id} - Get user by ID
  • PUT /{id} - Update user
  • DELETE /{id} - Delete user
  • GET /search - Search users
  • PATCH /{id}/status - Update user status

Course Service (/api/v1/courses)

  • GET / - List courses
  • POST / - Create course
  • GET /{id} - Get course details
  • GET /{id}/modules - Get course modules
  • POST /{id}/modules - Add course module

Enrollment Service (/api/v1/enrollments)

  • POST / - Enroll student
  • GET /student/{id} - Get student enrollments
  • PUT /{id}/progress - Update progress
  • GET /analytics/{courseId} - Get enrollment analytics

Assessment Service (/api/v1/assessments)

  • GET /course/{courseId} - Get course assessments
  • POST / - Create assessment
  • POST /{id}/submit - Submit assessment
  • GET /submissions/student/{id} - Get student submissions

Notification Service (/api/v1/notifications)

  • POST /send - Send notification
  • GET /user/{userId} - Get user notifications
  • PUT /{id}/read - Mark as read
  • POST /bulk-send - Send bulk notifications

🎭 Event-Driven Architecture

Published Events

  • User Events: user.created, user.updated, user.deleted, user.status.changed
  • Course Events: course.created, course.published, course.updated
  • Enrollment Events: enrollment.created, enrollment.completed, progress.updated
  • Assessment Events: assessment.submitted, assessment.graded

Event Flow Examples

User Registration β†’ user.created β†’ notification-service (welcome email)
Course Published β†’ course.published β†’ notification-service (notify enrolled students)
Assessment Submitted β†’ assessment.submitted β†’ notification-service (notify instructor)

πŸ” Security Architecture

JWT Authentication Flow

  1. User authenticates via API Gateway
  2. JWT token issued with user claims and roles
  3. Each service validates JWT independently
  4. Role-based access control (RBAC) enforced

Roles & Permissions

  • STUDENT: View courses, enroll, submit assessments, track progress
  • INSTRUCTOR: Create courses, grade assessments, view student progress
  • ADMIN: Full system access, user management, analytics

πŸš€ Getting Started

Prerequisites

  • Java 17+
  • Docker & Docker Compose
  • Maven 3.8+
  • Kubernetes (optional, for production deployment)

Development Setup

# Clone the repository
git clone <repository-url>
cd lms-services

# Start infrastructure services
docker-compose up -d postgres-users postgres-courses postgres-enrollments postgres-assessments postgres-notifications redis rabbitmq

# Start discovery server
cd discovery-service && mvn spring-boot:run

# Start config server
cd config-service && mvn spring-boot:run

# Start individual services
cd user-service && mvn spring-boot:run
cd course-service && mvn spring-boot:run
cd enrollment-service && mvn spring-boot:run
cd assessment-service && mvn spring-boot:run
cd notification-service && mvn spring-boot:run

# Start API Gateway
cd gateway-service && mvn spring-boot:run

Docker Deployment

# Build and start all services
docker-compose up --build

# View logs
docker-compose logs -f user-service

# Scale services
docker-compose up --scale user-service=3

Kubernetes Deployment

# Apply database configurations
kubectl apply -f kubernetes/postgres/

# Apply infrastructure services
kubectl apply -f kubernetes/infrastructure/

# Apply business services
kubectl apply -f kubernetes/services/

# Check deployment status
kubectl get pods -l app=user-service

πŸ“Š Monitoring & Observability

Health Checks

All services expose health endpoints at /actuator/health

Metrics

  • Prometheus: Metrics collection (port 9090)
  • Grafana: Visualization dashboards (port 3000)
  • Custom Metrics: Business metrics for each service

Distributed Tracing

  • Spring Cloud Sleuth: Request tracing
  • Jaeger: Trace visualization
  • Correlation IDs: End-to-end request tracking

Logging

  • Structured JSON logging
  • Centralized log aggregation
  • Request/response logging with correlation IDs

πŸ§ͺ Testing Strategy

Unit Tests

# Run unit tests for all services
mvn test

# Generate coverage report
mvn jacoco:report

Integration Tests

# Run integration tests with testcontainers
mvn verify -P integration-tests

Contract Tests

  • Consumer-driven contract testing with Pact
  • API contract validation
  • Cross-service communication testing

πŸ“ˆ Performance & Scalability

Caching Strategy

  • User Sessions: Redis-based session storage
  • Course Catalog: Cached with TTL
  • Assessment Results: Cached for quick retrieval
  • Cache Invalidation: Event-driven cache updates

Database Optimization

  • Connection pooling with HikariCP
  • Read replicas for read-heavy operations
  • Database indexes for performance
  • Partitioning for large tables

Horizontal Scaling

  • Stateless service design
  • Load balancing with Spring Cloud Gateway
  • Auto-scaling with Kubernetes HPA
  • Circuit breaker pattern for resilience

πŸ”„ CI/CD Pipeline

GitLab CI/CD Example

stages:
  - test
  - build
  - deploy

test:
  script:
    - mvn test
    - mvn verify -P integration-tests

build:
  script:
    - docker build -t lms/user-service .
    - docker push lms/user-service

deploy:
  script:
    - kubectl apply -f kubernetes/

πŸš€ Production Considerations

Environment Configuration

  • Separate configurations for dev/staging/prod
  • Secret management with Kubernetes secrets
  • Environment-specific database configurations

Security Hardening

  • TLS/SSL encryption
  • Network policies
  • Vulnerability scanning
  • Security headers

Backup & Recovery

  • Automated database backups
  • Point-in-time recovery
  • Disaster recovery procedures
  • Data retention policies

πŸ“š API Documentation

Interactive API documentation is available via Swagger UI:

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

For support and questions:

  • Create an issue in the repository
  • Contact the development team
  • Check the documentation wiki

Happy Learning! πŸŽ“

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published