A Spring Boot-based RESTful API for managing product categories, products, and user authentication with role-based access. Includes PostgreSQL and Redis integration, currency conversion, and JWT authentication.
This project is containerized using Docker with all dependencies included (PostgreSQL + Redis).
- Docker
- Docker Compose
- Java 17+
- Maven 3.9+
├── src/ # Java source files
├── postman/ # Postman collection
├── docker-compose.yml # Compose services: app + postgres + redis
├── Dockerfile # Spring Boot build image
├── .env # Environment variables
├── schema.sql # DB schema (auto-run)
├── data.sql # Sample data (auto-run)
└── README.md # This file
- Build your JAR:
./mvnw clean package- Start the containers:
docker-compose up --build- Access the app:
http://localhost:8080
- Environment variables are stored in the
.envfile (used by Docker Compose).
schema.sqlanddata.sqlare automatically executed when the app starts (via Spring Boot + PostgreSQL config).- If you rebuild or reset the DB container, these scripts will recreate the schema and preload sample categories, products, and users.
- Use the
/api/users/registerand/api/users/loginendpoints to create and login users. - The login endpoint returns a JWT token.
- Include this token in
Authorization: Bearer <your_token>for all protected endpoints. - (It should be auto-filled in Postman after login.)
A ready-to-use Postman collection is included:
📁
postman/product-category.postman_collection.json
- Open Postman.
- Click Import, select the
.jsonfile. - Set these environment variables:
baseUrl→http://localhost:8080/apitoken→ Once login is successful, it will be auto-filled.
It includes:
- User registration/login
- Product & category creation, update, delete
- Currency conversion validations
| Method | Endpoint | Access |
|---|---|---|
| POST | /users/register |
Public |
| POST | /users/login |
Public |
| GET | /products |
USER, ADMIN |
| POST | /products |
ADMIN only |
| GET | /categories |
USER, ADMIN |
| DELETE | /categories/{id} |
ADMIN only |
- Spring Boot 3.3
- PostgreSQL
- Redis
- MapStruct
- JWT
- Docker / Docker Compose
- JPA / Hibernate
- Maven
- DB migrations: Handled via
schema.sql+data.sql. - Soft deletes for products.
- Automatic currency conversion using Fixer API.
Roman Ivanov
Feel free to fork or contribute!