A production-style REST API built using Spring Boot, Spring Security, JWT Authentication, Redis Caching, MySQL, Flyway Database Migration, and Docker.
This project demonstrates how modern backend applications are built using Spring Boot with secure authentication, database persistence, caching, and database version control.
The application follows a clean layered architecture:
- Controller
- Service
- Repository
- Database
The project secures all protected endpoints using JWT Authentication and improves performance using Redis Cache running inside a Docker container.
- ๐ JWT Authentication
- ๐ค User Registration
- ๐ User Login
- ๐ก Spring Security
- ๐ฆ CRUD Operations
- ๐ MySQL Database
- โก Redis Cache
- ๐ณ Dockerized Redis
- ๐ Flyway Database Migration
- ๐ Request Validation
- โ Global Exception Handling
- ๐งฉ Layered Architecture
- ๐ Maven Build
- ๐ฌ API Testing using Postman
| Technology | Used |
|---|---|
| Java 25 | โ |
| Spring Boot | โ |
| Spring Security | โ |
| JWT | โ |
| Spring Data JPA | โ |
| Hibernate | โ |
| MySQL | โ |
| Redis | โ |
| Docker | โ |
| Flyway | โ |
| Maven | โ |
| IntelliJ IDEA | โ |
| Postman | โ |
Client (Postman)
โ
โผ
Spring Security
โ
โผ
JWT Authentication
โ
โผ
User Controller
โ
โผ
Service Layer
โ โ
Redis Cache JPA Repository
โ โ
Docker Hibernate ORM
โ
โผ
MySQL Database
basic-rest-api
โ
โโโ docs
โ โโโ screenshots
โ
โโโ src
โ โโโ main
โ โ
โ โโโ java
โ โ โโโ com.example.basic_rest_api
โ โ
โ โ โโโ config
โ โ โโโ controller
โ โ โโโ dto
โ โ โโโ exception
โ โ โโโ model
โ โ โโโ repository
โ โ โโโ security
โ โ โโโ service
โ โ โโโ BasicRestApiApplication
โ โ
โ โโโ resources
โ โโโ application.properties
โ โโโ db
โ โโโ migration
โ
โโโ pom.xml
โโโ docker-compose.yml
โโโ README.md
โโโ .gitignore
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/register |
Register User |
| POST | /auth/login |
Login User |
| Method | Endpoint | Description |
|---|---|---|
| GET | /users |
Get All Users |
| GET | /users/{id} |
Get User by ID |
| PUT | /users/{id} |
Update User |
| DELETE | /users/{id} |
Delete User |
๐ All User APIs require a valid JWT Token.
Register User
โ
โผ
Login
โ
โผ
JWT Token Generated
โ
โผ
Authorization Header
Bearer <JWT Token>
โ
โผ
Spring Security Filter
โ
โผ
Protected APIs
Client
โ
GET /users
โ
โผ
Redis Cache ?
YES โโโโโโโโโโบ Return Cached Response
NO
โ
โผ
MySQL Database
โ
โผ
Store Data in Redis
โ
โผ
Return Response
Redis is used to cache frequently requested user data to reduce unnecessary database queries and improve response time.
Redis runs inside a Docker container.
docker run -d --name redis-server -p 6379:6379 redisdocker start redis-serverdocker psDatabase schema is managed automatically using Flyway.
V1__create_users_table.sql
โ
V2__insert_initial_data.sql
โ
Executed Automatically
During Application Startup
git clone https://github.com/uddishasinghh31/YOUR_REPOSITORY_NAME.gitOpen the project using IntelliJ IDEA.
Update your application.properties.
spring.datasource.url=jdbc:mysql://localhost:3306/prodigy_task2_db
spring.datasource.username=root
spring.datasource.password=your_passworddocker start redis-servermvn spring-boot:runor run
BasicRestApiApplication.java
Application starts on:
http://localhost:8080
- Register a new user.
- Login using registered credentials.
- Copy the generated JWT Token.
- Add it to the Authorization Header.
Authorization
Bearer your_jwt_token
- Access all protected APIs.
- ๐ Swagger / OpenAPI Documentation
- ๐ฅ Role-Based Authentication
- ๐ Refresh Tokens
- ๐ Pagination & Sorting
- ๐ Search APIs
- ๐งช Unit Testing
- โ Cloud Deployment
- โ CI/CD Pipeline
- ๐ Monitoring using Prometheus & Grafana
Aspiring Java Backend Developer
- โ Java
- ๐ฑ Spring Boot
- ๐ Spring Security
- ๐ซ JWT Authentication
- ๐ MySQL
- โก Redis
- ๐ณ Docker
- ๐ REST APIs
Linkedin: https://www.linkedin.com/in/udisha-singh-47170b338
---
# โญ Support
If you found this project useful,
โญ Consider giving this repository a **Star**!
<div align="center">
## Made with โค๏ธ using Spring Boot
</div>




