Skip to content

uddishasinghh31/PRODIGY_BWD_02

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Spring Boot User CRUD REST API

Persistent Storage with MySQL | Spring Data JPA | Hibernate | Flyway

Java Spring Boot MySQL Hibernate Flyway Maven

A production-style RESTful CRUD API built with Spring Boot featuring persistent storage using MySQL, Spring Data JPA (Hibernate), and Flyway database migrations.


πŸ“Œ Project Overview

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.


✨ Features

  • βœ… 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

πŸ›  Tech Stack

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

πŸ— Project Architecture

                 Client (Postman)

                        β”‚
                        β–Ό

             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚  UserController      β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                        β–Ό

             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚    UserService       β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                        β–Ό

             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚ UserRepository (JPA) β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                        β–Ό

             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚   Hibernate ORM      β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                        β–Ό

             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
             β”‚   MySQL Database     β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‚ Project Structure

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 Details

Database: MySQL

Schema: prodigy_task2_db

Migration Tool: Flyway

ORM: Hibernate (Spring Data JPA)

Users Table

Column Type
id UUID
name VARCHAR
email VARCHAR
age INTEGER

πŸ”— REST API Endpoints

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

βš™οΈ How to Run the Project

Clone Repository

git clone https://github.com/uddishasinghh31/springboot-user-crud-api.git

Configure MySQL

Create a database named:

CREATE DATABASE prodigy_task2_db;

Configure Environment Variables

Create a .env file in the project root.

DB_URL=jdbc:mysql://localhost:3306/prodigy_task2_db
DB_USERNAME=your_username
DB_PASSWORD=your_password

Note: The .env file is intentionally excluded from GitHub using .gitignore to keep credentials secure.


Run the Application

Using Maven:

mvn spring-boot:run

Or simply run:

BasicRestApiApplication.java

Flyway will automatically create the required database tables on application startup.


πŸ“Έ Project Screenshots

πŸ— Project Structure

Shows the layered package structure used in the application.


🌐 API Testing using Postman

Successful retrieval of users through the REST API.


πŸ—„ MySQL Database

Persistent records stored inside the MySQL database after API requests.

ChatGPT Image Jul 23, 2026, 10_06_09 PM

---

πŸ§ͺ Sample JSON Response

[
  {
    "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
  }
]

πŸš€ Future Improvements

  • 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)

πŸ‘©β€πŸ’» Author

Udisha Singh

GitHub: https://github.com/uddishasinghh31


πŸ“„ Internship Details

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.


⭐ If you found this project useful, please consider giving it a Star!

About

Task 2: Extended REST API with persistent storage using MySQL, Hibernate, Spring Data JPA, Flyway migrations, and environment variables.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages