A Spring Boot REST API for inventory management with Swagger, validation, and Docker support.
- RESTful API with full CRUD operations
- Swagger UI for live API documentation
- Input Validation with clean error responses
- Docker ready (PostgreSQL) for production
- H2 in-memory database for local development
- Java 17+
- Spring Boot 3.2
- Spring Data JPA
- H2 (local) / PostgreSQL (Docker)
- Docker & Docker Compose
- Swagger / OpenAPI
mvn spring-boot:rundocker-compose up --buildAPI available at: http://localhost:8080
Swagger UI: http://localhost:8080/swagger-ui.html
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/items |
List all items |
| GET | /api/items/{id} |
Get item by ID |
| POST | /api/items |
Create new item |
| PUT | /api/items/{id} |
Update item |
| DELETE | /api/items/{id} |
Delete item |
| GET | /api/items/search?name=keyword |
Search by name |
# Add item
curl -X POST http://localhost:8080/api/items \
-H "Content-Type: application/json" \
-d '{"name": "Laptop", "quantity": 10, "price": 999.99}'
# Validation error
curl -X POST http://localhost:8080/api/items \
-H "Content-Type: application/json" \
-d '{"name": "", "quantity": -5, "price": 0}'src/main/java/com/inventory/
├── InventoryApplication.java
├── controller/ItemController.java
├── model/Item.java
├── repository/ItemRepository.java
└── exception/GlobalExceptionHandler.java
Built by Surya Sasaank Y.