A Spring Boot application for managing student records with MongoDB integration.
This Student Management System provides RESTful APIs to perform CRUD operations on student data. The application uses Spring Boot with MongoDB as the database and follows a layered architecture with controllers, services, repositories, and models.
- Java 21
- Spring Boot 4.0.1
- MongoDB (Database)
- Spring Data MongoDB
- Spring Web MVC
- Lombok (For reducing boilerplate code)
- Maven (Build tool)
- Add single or multiple student records
- Retrieve all student data
- Fetch student by ID
- Search students by name and CGPA
- Find students by city
- Query students by country or arrears status
- Filter students by enrollment date range
The application stores the following student information:
- ID: Unique identifier (auto-generated)
- Name: Student's full name
- CGPA: Cumulative Grade Point Average
- Has Arrears: Boolean indicating if student has pending arrears
- Course List: List of courses the student is enrolled in
- Address: Student's address details
- Enrollment Date: Date of student enrollment (format: dd-MM-yyyy)
| Method | Endpoint | Description |
|---|---|---|
| POST | /student/addStudent |
Add a single student |
| POST | /student/addStudentsData |
Add multiple students |
| GET | /student/getAllStudentsData |
Get all students |
| GET | /student/getStudentById/{id} |
Get student by ID |
| GET | /student/getStudentByNameAndCgpa |
Get students by name and CGPA |
| GET | /student/getStudentByCity/{city} |
Get student by city |
| GET | /student/getStudentByCountryOrArrears |
Get students by country or arrears |
| GET | /student/getStudentByEnrollmentDate |
Get students by enrollment date |
- Java 21 or higher
- Maven 3.6 or higher
- MongoDB instance running on localhost:27017
-
Clone the repository
git clone <repository-url> cd StudentManagement
-
Configure MongoDB
- Ensure MongoDB is running on localhost:27017
- Create a database named
student(or modify the configuration inapplication.properties)
-
Build the application
mvn clean install
-
Run the application
mvn spring-boot:run
The application will start on
http://localhost:8080
The application configuration is located in src/main/resources/application.properties:
spring.application.name=StudentManagement
# MongoDB properties
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=studentcurl -X POST http://localhost:8080/student/addStudent \
-H "Content-Type: application/json" \
-d '{
"name": "Ravi Ranjan",
"cgpa": 8.0,
"hasArrears": false,
"courseList": ["Mathematics", "Physics", "Computer Science"],
"address": {
"street": "Salt Lake, Sector 2",
"city": "Kolkata",
"country": "IN"
},
"enrollmentDate": "15-01-2023"
}'curl http://localhost:8080/student/getAllStudentsDatacurl http://localhost:8080/student/getStudentById/{student-id}curl "http://localhost:8080/student/getStudentByNameAndCgpa?name=John&cgpa=8.5"src/main/java/com/example/StudentManagement/
├── StudentManagementApplication.java # Main application class
├── controller/
│ └── StudentController.java # REST API endpoints
├── modal/
│ ├── Student.java # Student entity
│ └── Address.java # Address entity
├── repository/
│ └── StudentRepository.java # Data access layer
└── service/
└── StudentService.java # Business logic layer
mvn testThe application includes Spring Boot DevTools for automatic restart during development.