Skip to main content

Command Palette

Search for a command to run...

πŸš€ Building a Production Ready Smart Course Management System with Spring Boot, MySQL & Docker

Updated
β€’8 min readβ€’View as Markdown
πŸš€ Building a Production Ready Smart Course Management System with Spring Boot, MySQL & Docker

A production-style backend project built using Spring Boot, Spring Data JPA, Hibernate, MySQL, and Docker that manages Courses, Students, Instructors, and Enrollments with real-world business validations.

πŸ”— GitHub Repository: https://github.com/satyajitmishra-dev/smart-course-management

πŸ“Œ Project Overview

Managing educational courses manually becomes difficult when dealing with:

  • Hundreds of students

  • Multiple instructors

  • Course capacities

  • Enrollment tracking

  • Duplicate registrations

  • Course assignments

To solve these challenges, I built a Smart Course Management System using Spring Boot.

This project provides a complete REST API solution to manage:

βœ… Courses

βœ… Students

βœ… Instructors

βœ… Enrollments

βœ… Soft Delete

βœ… Business Validations

βœ… Dockerized Deployment


πŸ—οΈ Tech Stack

Technology Usage
Java 25 Programming Language
Spring Boot 4 Backend Framework
Spring Data JPA ORM Layer
Hibernate Persistence Provider
MySQL Database
Maven Build Tool
Docker Containerization
REST API Communication
Lombok Boilerplate Reduction

πŸ“‚ Project Structure

src
β”‚
β”œβ”€β”€ controller
β”‚
β”œβ”€β”€ service
β”‚
β”œβ”€β”€ repository
β”‚
β”œβ”€β”€ entity
β”‚
β”œβ”€β”€ dto
β”‚
β”œβ”€β”€ exception
β”‚
β”œβ”€β”€ validation
β”‚
└── SmartCourseManagementApplication

🎯 Features

Course Management

  • Create Course

  • Update Course

  • Get Course By ID

  • Get All Courses

  • Assign Instructor

  • Soft Delete Course


Student Management

  • Create Student

  • Update Student

  • Get Student By ID

  • Get All Students

  • Soft Delete Student


Instructor Management

  • Create Instructor

  • Update Instructor

  • Get Instructor By ID

  • Get All Instructors

  • Soft Delete Instructor


Enrollment Management

  • Enroll Student

  • Prevent Duplicate Enrollment

  • Capacity Validation

  • Complete Enrollment

  • Cancel Enrollment

  • Enrollment Tracking


🧠 Business Rules Implemented

This project is not just CRUD.

Several real-world validations have been implemented.


Duplicate Student Prevention

A student cannot register with the same email twice.

if(studentRepository.existsByEmail(email)){
    throw new DuplicateResourceException();
}

Duplicate Instructor Prevention

Every instructor must have a unique email.


Course Capacity Validation

A student cannot enroll if the course capacity is already full.

Example:

Course Capacity = 50

Already Enrolled = 50

New Enrollment ❌ Rejected

Duplicate Enrollment Prevention

A student cannot enroll in the same course twice.

Example:

Student 1 -> Spring Boot

Trying Again

Result:
409 CONFLICT

Soft Delete

Records are never physically deleted.

Instead:

active = false

This preserves historical data.


πŸ—„οΈ Database Design

Student

Student
β”‚
β”œβ”€β”€ id
β”œβ”€β”€ name
β”œβ”€β”€ email
β”œβ”€β”€ mobileNo
β”œβ”€β”€ active
β”œβ”€β”€ createdAt
└── updatedAt

Instructor

Instructor
β”‚
β”œβ”€β”€ id
β”œβ”€β”€ name
β”œβ”€β”€ email
β”œβ”€β”€ specialization
β”œβ”€β”€ active
└── createdAt

Course

Course
β”‚
β”œβ”€β”€ id
β”œβ”€β”€ title
β”œβ”€β”€ description
β”œβ”€β”€ capacity
β”œβ”€β”€ price
β”œβ”€β”€ instructor
└── active

Enrollment

Enrollment
β”‚
β”œβ”€β”€ id
β”œβ”€β”€ student
β”œβ”€β”€ course
β”œβ”€β”€ enrollmentDate
└── enrollmentStatus

πŸ”— Entity Relationships

Instructor
    |
    | One To Many
    |
Course
    |
    | One To Many
    |
Enrollment
    |
    | Many To One
    |
Student

🌐 REST APIs

Base URL

http://localhost:8080/api/v1

πŸ“˜ Course APIs

Create Course

POST /courses

Request

{
  "title": "Spring Boot Masterclass",
  "description": "Complete Spring Boot course",
  "capacity": 50,
  "price": 4999
}

Get All Courses

GET /courses

Get Course By Id

GET /courses/{id}

Update Course

PUT /courses/{id}

Soft Delete Course

PATCH /courses/{id}

Assign Instructor

PATCH /courses/{courseId}/assign-instructor/{instructorId}

πŸ‘¨β€πŸŽ“ Student APIs

Create Student

POST /students

Request

{
  "name": "Satyajit Mishra",
  "email": "satyajit@gmail.com",
  "mobileNo": "9123456789"
}

Get All Students

GET /students

Get Student By Id

GET /students/{id}

Update Student

PUT /students/{id}

Soft Delete Student

PATCH /students/{id}

πŸ‘¨β€πŸ« Instructor APIs

Create Instructor

POST /instructor

Request

{
  "name": "John Smith",
  "email": "john@example.com",
  "specialization": "Spring Boot"
}

Get All Instructors

GET /instructor

Get Instructor By Id

GET /instructor/{id}

Update Instructor

PUT /instructor/{id}

Soft Delete Instructor

PATCH /instructor/{id}

πŸ“ Enrollment APIs

Create Enrollment

POST /enrollments

Request

{
  "studentId": 1,
  "courseId": 1
}

Get All Enrollments

GET /enrollments

Get Enrollment By Id

GET /enrollments/{id}

Complete Enrollment

PATCH /enrollments/completed?id=1

Cancel Enrollment

PATCH /enrollments/cancel?id=1

πŸ§ͺ Complete API Testing Flow

Step 1

Create Instructors

{
  "name": "John Smith",
  "email": "john@example.com",
  "specialization": "Spring Boot"
}
{
  "name": "Sarah Wilson",
  "email": "sarah@example.com",
  "specialization": "AWS"
}

Step 2

Create Courses

{
  "title": "Spring Boot Masterclass",
  "description": "Complete Spring Boot course",
  "capacity": 50,
  "price": 4999
}
{
  "title": "AWS Cloud Practitioner",
  "description": "AWS Fundamentals",
  "capacity": 40,
  "price": 5999
}

Step 3

Assign Instructors

PATCH /courses/1/assign-instructor/1
PATCH /courses/2/assign-instructor/2

Step 4

Create Students

{
  "name": "Satyajit Mishra",
  "email": "satyajit@gmail.com",
  "mobileNo": "9123456789"
}
{
  "name": "Ananya Sharma",
  "email": "ananya@gmail.com",
  "mobileNo": "9876543210"
}

Step 5

Enroll Students

{
  "studentId": 1,
  "courseId": 1
}
{
  "studentId": 2,
  "courseId": 2
}

Step 6

Verify Data

GET /courses
GET /students
GET /instructor
GET /enrollments

Step 7

Complete Enrollment

PATCH /enrollments/completed?id=1

Step 8

Cancel Enrollment

PATCH /enrollments/cancel?id=2

❌ Failure Scenarios Covered

Scenario Status
Duplicate Student Email 409 Conflict
Duplicate Instructor Email 409 Conflict
Student Already Enrolled 409 Conflict
Course Capacity Full 409 Conflict
Invalid Student ID 404 Not Found
Invalid Course ID 404 Not Found
Invalid Instructor ID 404 Not Found
Deleted Student Access 404 Not Found
Deleted Course Access 404 Not Found
Deleted Instructor Access 404 Not Found

🐳 Docker Support

The application can run completely inside Docker containers.

Docker Compose

services:

  mysql:
    image: mysql:8.0
    container_name: mysql-db

    environment:
      MYSQL_ROOT_PASSWORD: root123
      MYSQL_DATABASE: smart_course_management

    ports:
      - "3307:3306"

  app:
    build: .
    container_name: smart-course-app

    depends_on:
      - mysql

    ports:
      - "8080:8080"

    environment:
      SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/smart_course_management
      SPRING_DATASOURCE_USERNAME: root
      SPRING_DATASOURCE_PASSWORD: root123

Run:

docker compose up --build

πŸš€ Future Improvements

Planned features:

  • JWT Authentication

  • Role Based Access Control

  • Course Categories

  • Course Reviews & Ratings

  • Payment Integration

  • Email Notifications

  • Pagination & Sorting

  • Search APIs

  • Swagger Documentation

  • CI/CD Pipeline

  • AWS Deployment

  • Redis Caching

  • Docker Multi-stage Build

  • Kubernetes Deployment


πŸ“š What I Learned

While building this project I gained hands-on experience with:

  • Spring Boot Architecture

  • Layered Design Pattern

  • JPA Relationships

  • Hibernate

  • Exception Handling

  • DTO Mapping

  • Validation

  • Business Rules Implementation

  • Docker Containerization

  • REST API Design

  • MySQL Integration


πŸ”— Project Repository

GitHub:

https://github.com/satyajitmishra-dev/smart-course-management


πŸ’¬ Final Thoughts

This project helped me move beyond basic CRUD operations and understand how real-world backend systems are designed.

By implementing business validations, entity relationships, enrollment workflows, soft deletion, and Docker deployment, I gained practical experience that closely resembles production-grade application development.

If you're learning Spring Boot and want a project that covers CRUD, JPA, Hibernate, MySQL, REST APIs, validation, and Docker in one place, this project is a great reference.

⭐ If you found this project useful, consider giving it a star on GitHub.

πŸš€ Java Backend to Cloud

Part 1 of 4

ava Backend to Cloud is my public learning journey where I document everything I learn while becoming a Java Full Stack & Cloud Developer. Through real-world projects, beginner-friendly tutorials, and hands-on examples, I explore Java, Spring Boot, Spring Data JPA, MySQL, REST APIs, Spring Security, Docker, AWS, and modern backend developmentβ€”one article at a time.

Up next

πŸš€ JDBC to Spring Data JPA: The Evolution of Java Database Access Explained for Beginners

title: JDBC to Spring Data JPA: The Evolution of Java Database Access Explained for Beginners seoTitle: JDBC vs Hibernate vs JPA vs Spring Data JPA seoDescription: Learn the evolution of Java database