# 🚀 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

```text
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.

```java
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:

```text
Course Capacity = 50

Already Enrolled = 50

New Enrollment ❌ Rejected
```

* * *

## Duplicate Enrollment Prevention

A student cannot enroll in the same course twice.

Example:

```text
Student 1 -> Spring Boot

Trying Again

Result:
409 CONFLICT
```

* * *

## Soft Delete

Records are never physically deleted.

Instead:

```java
active = false
```

This preserves historical data.

* * *

# 🗄️ Database Design

## Student

```text
Student
│
├── id
├── name
├── email
├── mobileNo
├── active
├── createdAt
└── updatedAt
```

* * *

## Instructor

```text
Instructor
│
├── id
├── name
├── email
├── specialization
├── active
└── createdAt
```

* * *

## Course

```text
Course
│
├── id
├── title
├── description
├── capacity
├── price
├── instructor
└── active
```

* * *

## Enrollment

```text
Enrollment
│
├── id
├── student
├── course
├── enrollmentDate
└── enrollmentStatus
```

* * *

# 🔗 Entity Relationships

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

* * *

# 🌐 REST APIs

Base URL

```http
http://localhost:8080/api/v1
```

* * *

# 📘 Course APIs

## Create Course

```http
POST /courses
```

### Request

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

* * *

## Get All Courses

```http
GET /courses
```

* * *

## Get Course By Id

```http
GET /courses/{id}
```

* * *

## Update Course

```http
PUT /courses/{id}
```

* * *

## Soft Delete Course

```http
PATCH /courses/{id}
```

* * *

## Assign Instructor

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

* * *

# 👨‍🎓 Student APIs

## Create Student

```http
POST /students
```

### Request

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

* * *

## Get All Students

```http
GET /students
```

* * *

## Get Student By Id

```http
GET /students/{id}
```

* * *

## Update Student

```http
PUT /students/{id}
```

* * *

## Soft Delete Student

```http
PATCH /students/{id}
```

* * *

# 👨‍🏫 Instructor APIs

## Create Instructor

```http
POST /instructor
```

### Request

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

* * *

## Get All Instructors

```http
GET /instructor
```

* * *

## Get Instructor By Id

```http
GET /instructor/{id}
```

* * *

## Update Instructor

```http
PUT /instructor/{id}
```

* * *

## Soft Delete Instructor

```http
PATCH /instructor/{id}
```

* * *

# 📝 Enrollment APIs

## Create Enrollment

```http
POST /enrollments
```

### Request

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

* * *

## Get All Enrollments

```http
GET /enrollments
```

* * *

## Get Enrollment By Id

```http
GET /enrollments/{id}
```

* * *

## Complete Enrollment

```http
PATCH /enrollments/completed?id=1
```

* * *

## Cancel Enrollment

```http
PATCH /enrollments/cancel?id=1
```

* * *

# 🧪 Complete API Testing Flow

## Step 1

Create Instructors

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

```json
{
  "name": "Sarah Wilson",
  "email": "sarah@example.com",
  "specialization": "AWS"
}
```

* * *

## Step 2

Create Courses

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

```json
{
  "title": "AWS Cloud Practitioner",
  "description": "AWS Fundamentals",
  "capacity": 40,
  "price": 5999
}
```

* * *

## Step 3

Assign Instructors

```http
PATCH /courses/1/assign-instructor/1
```

```http
PATCH /courses/2/assign-instructor/2
```

* * *

## Step 4

Create Students

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

```json
{
  "name": "Ananya Sharma",
  "email": "ananya@gmail.com",
  "mobileNo": "9876543210"
}
```

* * *

## Step 5

Enroll Students

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

```json
{
  "studentId": 2,
  "courseId": 2
}
```

* * *

## Step 6

Verify Data

```http
GET /courses
GET /students
GET /instructor
GET /enrollments
```

* * *

## Step 7

Complete Enrollment

```http
PATCH /enrollments/completed?id=1
```

* * *

## Step 8

Cancel Enrollment

```http
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

```yaml
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:

```bash
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.
