This is a RESTful Product Management API built using Java and Spring Boot.
The application supports:
- Full CRUD operations for Products
- JWT-based Authentication
- Role-based Authorization
- MySQL Database integration
- Swagger API documentation
- Docker & Docker Compose setup
- Unit Testing with JUnit & Mockito
This project was developed as a backend assignment for interview selection.
- Java 17
- Spring Boot 3
- Spring Data JPA (Hibernate)
- MySQL
- Spring Security
- JWT Authentication
- Swagger (Springdoc OpenAPI)
- JUnit 5 & Mockito
- Docker & Docker Compose
- Maven
src/main/java/com/lucky/productapi
- config → Security & configuration classes
- controller → REST Controllers
- service → Business logic
- repository → JPA Repositories
- entity → JPA Entities
- dto → Request DTOs
- security → JWT & Security classes
- exception → Global Exception Handling
- User logs in using
/api/v1/auth/login - If credentials are valid:
- JWT token is generated
- Token must be sent in request header:
Authorization: Bearer your_jwt_token
- Protected endpoints require valid token
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/auth/login | Login & get JWT |
| POST | /api/v1/auth/register | Register new user |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/products | Get all products (Pagination supported) |
| GET | /api/v1/products/{id} | Get product by ID |
| POST | /api/v1/products | Create product |
| PUT | /api/v1/products/{id} | Update product |
| DELETE | /api/v1/products/{id} | Delete product |
- id (Primary Key)
- product_name
- created_by
- created_on
- modified_by
- modified_on
- id (Primary Key)
- product_id (Foreign Key)
- quantity
Unit tests implemented using:
- JUnit 5
- Mockito
To run tests:
mvn test
mvn clean install
mvn spring-boot:run
Application runs on:
Swagger UI:
http://localhost:8081/swagger-ui/index.html
Build and start containers:
docker compose up --build
This will start:
- MySQL container
- Spring Boot application container
Example:
GET /api/v1/products?page=0&size=5
- Stateless Authentication
- JWT-based access control
- Custom JWT filter
- Role-based authorization
- Password encryption using BCrypt
- Simple layered architecture (Controller → Service → Repository)
- Basic JWT implementation suitable for beginner-level understanding
- Audit fields (createdBy, createdOn) handled during product creation
- Global exception handling for consistent error responses
- Dockerized for easy deployment
- This project focuses on backend REST API implementation.
- Architecture kept simple and beginner-friendly.
- Advanced enterprise-level optimizations intentionally avoided.
Laxman Kale Java Backend Developer (Fresher)