Small REST API for a small online store with multiple product categories.
Project is a backend API of store that supports:
- User registration and login (used with JWT-based security)
- Managing products and their categories
- Shopping cart management
- Order creation and validation
- System of product reviews
- Admin-only access for sensitive operations
The purpose of project was to learn and practice:
- Designing a REST API from scratch
- Manage the transaction
- Get well with Spring Boot Framework and its components (Spring Security, Spring JDBC)
- Operation on SQL database without an ORM
- Error handling and validation
- Use JWT to authentication & authorization
All security is base on Spring Security Framework and JWT authentication. In security features are:
- Secure handling of password (with BCrypt encryption)
- Role-based access (USER / ADMIN)
- JWT-based authentication
- Base CRUD operations for products
- Available management restricted to ADMIN users
The goal was to implement shopping cart on backed side of store with:
- Basic CRUD operation on products in cart
- Calculate the quantity and value of cart
- Automatic adjustment to product price and availability changes
- Create order base on products in cart
- Validate products before order creation
- Transactional management of multiple operations
- User can add reviews to product (text and grade)
- Prevent multiple reviews from the same user for a single product
- Admins can manage product categories
Backend
- Java 25
- Spring Boot 3.5.6
- Spring Web
- Spring Security + JWT
- Spring JDBC
Database
- SQLite
No ORM is used - database operation are performed using plain JDBC and SQL queries.
The endpoints were tested and documented used Postman app. Link to documentation: Postman documentation
Project is divided to a couple of packages:
- controller - package for all REST controllers
- service - package for all service with business logic
- dao - package with DAO classes for database operations
- databaseinit - package with all database start configuration (like load example products from API)
- dto - package for Data Transfer Objects
- exception - package for created exceptions with global handler
- mapper - package for classes that map row from database to Java object
- model - package for models that represents tables
- security - package for all security filters and JWT authentication
- config - package for all configuration files
git clone https://github.com/FaFikPL367/Simple-Store-API.git
cd Simple-Store-APIIn the project is a example .env file and it contains what should be in .env file.
cp .env.example .env
rm -f .env.exampleJWT_SECRET_KEY="YOUR SECRET KEY FOR JWT"
./mvnw spring-boot::runor
mvnw spring-boot::run