Skip to content

byte2code/college-management-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

College Management API

Spring Boot REST API for managing students, courses, and grades with JPA, H2 persistence, and query-focused service design.

Overview

This project demonstrates a compact Spring Boot API for academic record management. It models students, courses, and grade records, and highlights how JPA relationships, derived queries, JPQL, and native SQL can be used to manage enrollments and fetch academic data in a clean learning-oriented codebase.

Concepts and Features Covered

  • Spring Boot REST API setup
  • Spring Data JPA repository pattern
  • H2 in-memory database integration
  • Many-to-many relationship between students and courses
  • Grade tracking with student-course associations
  • GET endpoint for retrieving a student by ID
  • GET endpoint for listing all students
  • POST endpoint for saving a student
  • POST endpoint for assigning courses and marks to a student
  • Derived JPA query for finding students by course name
  • GET endpoint for retrieving all students enrolled in a given course
  • JPQL query for retrieving all course names by student ID
  • GET endpoint for retrieving the list of enrolled course names for a given student
  • Native query for calculating average grades by student ID
  • GET endpoint for retrieving a student's average grade

Tech Stack

  • Java 17
  • Spring Boot 3
  • Spring Web
  • Spring Data JPA
  • H2 Database
  • Maven
  • JUnit 5

Project Structure

college-management-api/
├── CHANGELOG.md
├── README.md
├── pom.xml
├── mvnw
├── mvnw.cmd
└── src/
    ├── main/
    │   ├── java/com/codingninjas/jpaqueries/
    │   │   ├── controllers/
    │   │   ├── entities/
    │   │   ├── repository/
    │   │   ├── services/
    │   │   └── JpaqueriesApplication.java
    │   └── resources/
    │       └── application.yml
    └── test/

How to Run

  1. Open a terminal in the project root.
  2. Run mvn test.
  3. Run mvn spring-boot:run.
  4. Use the API under http://localhost:8080.
  5. Optional: access the H2 console if needed from the configured Spring Boot app.

Available endpoints:

  • GET /student/{id}
  • GET /student/{id}/averageGrade
  • POST /student
  • POST /student/{id}/courses_marks
  • GET /students
  • GET /students/{course}
  • GET /students/{id}/courses

Example request body for creating a student:

{
  "name": "Aarav"
}

Example request body for assigning courses and marks:

[
  {
    "course": "Mathematics",
    "marks": 91
  },
  {
    "course": "Physics",
    "marks": 87
  }
]

Learning Highlights

  • Demonstrates how to model academic entities with many-to-many and many-to-one JPA relationships
  • Shows how service logic can coordinate course creation, grade creation, and student enrollment
  • Highlights derived query methods like student lookup by course name for query-driven API design
  • Introduces JPQL-based repository queries for targeted projection-style lookups
  • Adds native-query based aggregation for average-grade reporting
  • Uses H2 in-memory persistence to keep setup lightweight for practice and demos

GitHub Metadata

  • Suggested repository description: Spring Boot REST API for managing students, courses, and grades with JPA, H2 persistence, plus derived-query, JPQL, and native-query academic lookups.
  • Suggested topics: java, java-17, spring-boot, spring-data-jpa, h2-database, rest-api, college-management, jpa-queries, jpql, native-query, maven, learning-project, portfolio-project

About

Spring Boot REST API for managing students, courses, and grades with JPA, H2 persistence, plus derived-query, JPQL, and native-query academic lookups.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages