Skip to content

mistermotopl/Simple-Store-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Store API

Small REST API for a small online store with multiple product categories.

Project overview

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

Purpose of project

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

Features

Authentication & Security

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

Product Management

  • Base CRUD operations for products
  • Available management restricted to ADMIN users

Shopping cart

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

Orders

  • Create order base on products in cart
  • Validate products before order creation
  • Transactional management of multiple operations

Reviews

  • User can add reviews to product (text and grade)
  • Prevent multiple reviews from the same user for a single product

Categories

  • Admins can manage product categories

Tech Stack

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.


API Documentation

The endpoints were tested and documented used Postman app. Link to documentation: Postman documentation


Project Structure

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

Running the project

1. Clone repository

git clone https://github.com/FaFikPL367/Simple-Store-API.git
cd Simple-Store-API

2. Create and fill .env file

In the project is a example .env file and it contains what should be in .env file.

2.1 Copy .env.example to new .env file

cp .env.example .env
rm -f .env.example

2.2 Set a JWT_SECRET_KEY in .env file

JWT_SECRET_KEY="YOUR SECRET KEY FOR JWT"

3. Run the application

./mvnw spring-boot::run

or

mvnw spring-boot::run

About

Simple Store API project with products across multiple categories.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages