Skip to content

gajendra-ingle/learnify-platform

Repository files navigation

πŸŽ“ Learnify Platform

Online Learning Platform β€” Microservices Architecture

A full-scale, cloud-native e-learning platform inspired by Udemy and Coursera, built with 12 Spring Boot 3.x microservices. Demonstrates distributed systems design, event-driven architecture, and modern DevOps practices.





πŸ“Œ Repository Description

Learnify is a microservices-based online learning platform built using Java 17, Spring Boot 3.2, and Spring Cloud. The system features 12 independent services communicating via OpenFeign (sync) and Apache Kafka (async), with full JWT authentication, Redis caching, Flyway migrations, Resilience4j circuit breakers, distributed tracing via Zipkin, and Docker Compose orchestration.


πŸ“¦ Microservices

# Service Port Responsibility Key Tech
1 API Gateway 8080 Single entry point, JWT filter, rate limiting, routing Spring Cloud Gateway, Redis
2 Config Server 8888 Centralized configuration management Spring Cloud Config
3 Service Registry 8761 Service discovery & registration Netflix Eureka
4 Auth Service 8081 Login, signup, JWT issuance, refresh tokens, RBAC Spring Security, JJWT
5 User Service 8082 User profiles, instructor management, Redis caching JPA, Redis
6 Course Service 8083 Course CRUD, categories, publish workflow, caching JPA, Redis, MapStruct
7 Lesson Service 8084 Sections, video/text lessons, ordering JPA, Flyway
8 Enrollment Service 8085 Enroll students, track progress, Kafka consumer Feign, Kafka, Resilience4j
9 Review Service 8086 Course ratings (1–5), reviews, average calculation JPA
10 Payment Service 8087 Payment processing, Kafka event publisher Kafka Producer
11 Notification Service 8090 Email notifications via Kafka consumers Spring Mail, Kafka
12 Analytics Service 8091 Revenue tracking, enrollment stats, Kafka consumers JPA, Kafka

πŸ›  Tech Stack

CoreJava 17, Spring Boot 3.2, Maven (multi-module)
Service MeshSpring Cloud 2023 β€” Config, Eureka, Gateway, OpenFeign
SecuritySpring Security 6, JWT (JJWT 0.12), RBAC (STUDENT / INSTRUCTOR / ADMIN)
MessagingApache Kafka 3.x (async events), OpenFeign (sync RPC)
PersistenceSpring Data JPA, Hibernate, PostgreSQL 15 (database-per-service)
CachingRedis 7 β€” course catalog, user profiles (TTL: 30 min)
ResilienceResilience4j β€” Circuit Breaker, Retry, Rate Limiter
MigrationsFlyway β€” versioned SQL migrations per service
ObservabilitySpring Actuator, Micrometer, Zipkin distributed tracing
DocsSpringDoc OpenAPI 3 / Swagger UI β€” per service + gateway aggregation
Code GenLombok (boilerplate), MapStruct (compile-time DTO mapping)
TestingJUnit 5, Mockito, Testcontainers
DevOpsDocker, Docker Compose (20+ containers)

πŸ—ƒ Database Design

Each service owns its own PostgreSQL schema (database-per-service pattern):

 auth_db
 └── users            (id, email, password, role, is_active)
 └── refresh_tokens   (id, token, user_id, expires_at, is_revoked)

 user_db
 └── user_profiles    (id, email, first_name, bio, headline, role)

 course_db
 └── categories       (id, name, slug, parent_id)
 └── courses          (id, title, instructor_id, category_id, price, status, avg_rating)

 lesson_db
 └── sections         (id, course_id, title, order_index)
 └── lessons          (id, section_id, title, type, video_url, order_index)

 enrollment_db
 └── enrollments      (id, student_id, course_id, status, progress_pct) UNIQUE(student,course)

 review_db
 └── reviews          (id, student_id, course_id, rating 1-5, comment) UNIQUE(student,course)

 payment_db
 └── payments         (id, student_id, course_id, amount, status, transaction_id)

 analytics_db
 └── course_analytics (course_id, total_enrollments, total_revenue, completion_rate)

🌐 Service URLs

Portal URL
πŸ”€ API Gateway http://localhost:8080
πŸ—‚ Eureka Dashboard http://localhost:8761
πŸ“‹ Swagger β€” Auth http://localhost:8081/swagger-ui.html
πŸ“‹ Swagger β€” Courses http://localhost:8083/swagger-ui.html
πŸ“‹ Swagger β€” Enrollment http://localhost:8085/swagger-ui.html
πŸ“Š Kafka UI http://localhost:8092
πŸ” Zipkin Tracing http://localhost:9411

πŸ” Authentication & Authorization

Roles

Role Permissions
STUDENT Browse courses, enroll, review, track progress
INSTRUCTOR Create & publish courses, manage lessons, view analytics
ADMIN Full platform access

Auth Flow

# 1. Register
curl -X POST http://localhost:8080/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "firstName": "Jane",
    "lastName": "Doe",
    "email": "jane@example.com",
    "password": "Secure@1234",
    "role": "STUDENT"
  }'

# 2. Login β†’ receive JWT
curl -X POST http://localhost:8080/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"jane@example.com","password":"Secure@1234"}'

# 3. Use JWT in subsequent requests
curl http://localhost:8080/api/courses \
  -H "Authorization: Bearer <your_jwt_token>"

πŸ“– API Documentation

Core Endpoints

Courses

GET    /api/courses              β†’ Search & filter published courses
GET    /api/courses/{id}         β†’ Get course details (cached in Redis)
POST   /api/courses              β†’ Create course [INSTRUCTOR]
PUT    /api/courses/{id}         β†’ Update course [INSTRUCTOR]
PATCH  /api/courses/{id}/publish β†’ Publish course [INSTRUCTOR]
GET    /api/courses/popular      β†’ Top courses by enrollment

Enrollment

POST  /api/enrollments           β†’ Enroll in a course (via Feign β†’ Course Service)
GET   /api/enrollments/my        β†’ My enrolled courses
PATCH /api/enrollments/{courseId}/progress β†’ Update lesson progress

Payments

POST /api/payments               β†’ Process payment (publishes Kafka event)
GET  /api/payments/my            β†’ My payment history
GET  /api/payments/{id}          β†’ Payment details

Reviews

POST /api/reviews                β†’ Submit course review (1–5 stars)
GET  /api/reviews/course/{id}    β†’ Course reviews (paginated)
GET  /api/reviews/course/{id}/rating β†’ Average rating
PUT  /api/reviews/{id}           β†’ Update review

Analytics (INSTRUCTOR/ADMIN)

GET /api/analytics/courses/{courseId}   β†’ Course stats & revenue
GET /api/analytics/courses/top-revenue  β†’ Top earning courses

πŸ§ͺ Testing

# Run all unit tests
mvn test

# Run tests for specific service
cd auth-service && mvn test
cd enrollment-service && mvn test
cd payment-service && mvn test
cd course-service && mvn test

# Run with coverage report
mvn test jacoco:report

Test coverage includes:

  • βœ… AuthServiceTest β€” register, login, duplicate email, invalid credentials
  • βœ… CourseServiceTest β€” create, fetch, not-found, publish flow
  • βœ… EnrollmentServiceTest β€” enroll, duplicate check, progress update, completion
  • βœ… PaymentServiceTest β€” process payment, duplicate payment rejection, Kafka publish

πŸ› Architecture Patterns

Pattern Implementation
Database per Service Each service has its own PostgreSQL instance
API Gateway Single entry point β€” auth, routing, rate limiting
Event-Driven (Saga) Payment β†’ Enrollment choreography via Kafka
Circuit Breaker Resilience4j on all Feign clients
CQRS (lite) Redis cache for hot read paths
DTO Pattern Request/Response DTOs, never expose entities
Repository Pattern Spring Data JPA repositories
Compile-time Mapping MapStruct β€” zero reflection DTO mapping

πŸ”­ Observability

# Health check any service
curl http://localhost:808X/actuator/health

# View distributed traces
open http://localhost:9411     # Zipkin UI

# Monitor Kafka topics & consumers
open http://localhost:8092     # Kafka UI

# Metrics (Prometheus-compatible)
curl http://localhost:808X/actuator/metrics
curl http://localhost:808X/actuator/prometheus

🀝 Contributing

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

About

Learnify is a microservices-based online learning platform built using Java 17, Spring Boot 3.2, and Spring Cloud.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors