A production-style RESTful CRUD API built with Spring Boot featuring persistent storage using MySQL, Spring Data JPA (Hibernate), and Flyway database migrations.
This project was developed as part of the Prodigy InfoTech Internship β Task 2: Persistent Storage with Database Integration.
The application extends a basic REST API by integrating MySQL for permanent data storage. It follows a clean layered architecture using Controller β Service β Repository, with Spring Data JPA and Hibernate ORM handling database interactions.
Database schema creation and versioning are managed automatically using Flyway Migrations, making the project scalable and production-ready.
- β Create User
- β Retrieve All Users
- β Retrieve User by ID
- β Update Existing User
- β Delete User
- β Persistent Data Storage using MySQL
- β Spring Data JPA Repository
- β Hibernate ORM
- β Flyway Database Migration
- β UUID-based User IDs
- β DTO Validation
- β Global Exception Handling
- β Environment Variable Configuration (.env)
- β HikariCP Connection Pooling
- β Tested using Postman
| Technology | Purpose |
|---|---|
| Java 21 | Programming Language |
| Spring Boot | Backend Framework |
| Spring Web | REST API Development |
| Spring Data JPA | Database Access Layer |
| Hibernate | ORM Framework |
| MySQL | Relational Database |
| Flyway | Database Migration |
| Maven | Dependency Management |
| Postman | API Testing |
| IntelliJ IDEA | Development Environment |
Client (Postman)
β
βΌ
βββββββββββββββββββββββ
β UserController β
βββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββ
β UserService β
βββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββ
β UserRepository (JPA) β
βββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββ
β Hibernate ORM β
βββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββ
β MySQL Database β
βββββββββββββββββββββββ
basic-rest-api
β
βββ docs
β βββ screenshots
β
βββ src
β βββ main
β β βββ java
β β β βββ com.example.basic_rest_api
β β β βββ controller
β β β βββ dto
β β β βββ exception
β β β βββ model
β β β βββ repository
β β β βββ service
β β β βββ BasicRestApiApplication
β β β
β β βββ resources
β β βββ application.properties
β β βββ db
β β βββ migration
β β βββ V1__create_users_table.sql
β
βββ pom.xml
βββ .gitignore
βββ README.md
βββ .env (ignored)
Database: MySQL
Schema: prodigy_task2_db
Migration Tool: Flyway
ORM: Hibernate (Spring Data JPA)
| Column | Type |
|---|---|
| id | UUID |
| name | VARCHAR |
| VARCHAR | |
| age | INTEGER |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/users |
Create User |
| GET | /api/users |
Retrieve All Users |
| GET | /api/users/{id} |
Retrieve User by ID |
| PUT | /api/users/{id} |
Update Existing User |
| DELETE | /api/users/{id} |
Delete User |
git clone https://github.com/uddishasinghh31/springboot-user-crud-api.gitCreate a database named:
CREATE DATABASE prodigy_task2_db;Create a .env file in the project root.
DB_URL=jdbc:mysql://localhost:3306/prodigy_task2_db
DB_USERNAME=your_username
DB_PASSWORD=your_passwordNote: The
.envfile is intentionally excluded from GitHub using.gitignoreto keep credentials secure.
Using Maven:
mvn spring-boot:runOr simply run:
BasicRestApiApplication.java
Flyway will automatically create the required database tables on application startup.
Shows the layered package structure used in the application.
Successful retrieval of users through the REST API.
Persistent records stored inside the MySQL database after API requests.
---[
{
"id": "81acc614-cae5-44a2-881e-d85156fa6efb",
"name": "Riya",
"email": "riya@gmail.com",
"age": 34
},
{
"id": "aa1cb954-f377-4f53-aa4b-643ba9924ad3",
"name": "Maya",
"email": "maya@gmail.com",
"age": 5
}
]- Swagger / OpenAPI Documentation
- Spring Security Authentication
- JWT Authentication
- Pagination & Sorting
- Search APIs
- Docker Support
- Unit Testing with JUnit
- Logging using SLF4J
- CI/CD Pipeline
- Cloud Deployment (AWS / Railway / Render)
Udisha Singh
GitHub: https://github.com/uddishasinghh31
Organization: Prodigy InfoTech
Task 1: Build a REST API for CRUD Operations
Task 2: Extend the REST API with Persistent Storage using MySQL, Hibernate, Spring Data JPA, and Flyway Database Migrations.


