A modern Spring Boot REST API for managing students, subjects, departments, and enrollments using a DTO-driven architecture and clean controller-repository pattern.
- Manage Students, Departments, Subjects, ID Cards, Users, and Enrollments
- Clean architecture: DTOs + Repository pattern (No Service Layer)
- Many-to-Many enrollment with
Enrollmententity - One-to-One mapping between Student ↔ IDCard, Student ↔ User
- Unified API responses via
ResponseBean<T> - Swagger/OpenAPI UI enabled
- PostgreSQL integration with JPA/Hibernate
- No business logic in services — all logic inside controllers
student/
├── src/
│ ├── main/
│ │ ├── java/com/fsd/student/
│ │ │ ├── controller/ # REST controllers (DTO-based)
│ │ │ ├── dto/ # All request/response DTOs
│ │ │ ├── entity/ # JPA entities
│ │ │ ├── repository/ # Spring Data JPA repositories
│ │ │ ├── response/ # ResponseBean<T> wrapper
│ │ │ └── StudentApplication.java
│ │ └── resources/
│ │ └── application.properties
│ └── test/
│ └── java/com/fsd/student/StudentApplicationTests.java
| Entity | Description |
|---|---|
| Department | Academic department (e.g. CS, IT) |
| Student | Student profile (with Department & IDCard) |
| Subject | Academic subject |
| Enrollment | Join table for Many-to-Many (Student ↔ Subject) |
| StudentIDCard | One-to-One with Student |
| User | Authentication entity linked to Student |
All entities now use DTOs for input/output:
StudentDTO,DepartmentDTO,SubjectDTO,EnrollmentDTO,UserDTO,StudentIDCardDTO- Controllers map entities ↔ DTOs internally
- JSON payloads are clean, flattened, and avoid recursion
- Java 21
- Spring Boot 3.x
- Spring Data JPA
- PostgreSQL
- Lombok
- Swagger/OpenAPI
- Maven
git clone https://github.com/yourusername/student-management-backend.git
cd student-management-backendspring.datasource.url=jdbc:postgresql://localhost:5432/studentdb
spring.datasource.username=your_db_user
spring.datasource.password=your_db_password
spring.jpa.hibernate.ddl-auto=updatemvn spring-boot:runOr:
java -jar target/student-0.0.1-SNAPSHOT.jarSwagger UI is enabled by default. After starting the app, visit:
http://localhost:8080/swagger-ui/index.html
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/students |
List all students |
| POST | /api/students |
Add new student |
| GET | /api/subjects |
List all subjects |
| POST | /api/enrollments |
Enroll student in subject |
| DELETE | /api/users/{id} |
Delete a user |
curl -X POST http://localhost:8080/api/enrollments \
-H "Content-Type: application/json" \
-d '{
"studentId": "STU001",
"subjectId": "SUBJ101",
"enrollmentDate": "2025-07-14"
}'- Controllers use repositories directly (no service layer)
- Business logic is controller-managed
- DTOs used for cleaner request/response models
ResponseBean<T>ensures consistent success/error responses
Open-source under the MIT License