onlineshop

๐Ÿ›’ OnlineShop โ€“ Full REST API Backend for E-Commerce

Java Spring Boot PostgreSQL Docker Maven Status REST API


๐Ÿ“Œ Overview

OnlineShop is a full REST API backend for an e-commerce system.
This is a training project, frontend-independent, and usable by any client (Web, Mobile, Desktop) over HTTP.

It implements product catalog, categories, orders, user roles, security, and full CRUD operations.
HTML documentation is available at the root endpoint of the running application.


โœจ Key Features


๐Ÿงฐ Technology Stack

Backend

Database

Infrastructure


๐Ÿ— Architecture Diagram

General Structure

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   REST API      โ”‚โ—„โ”€โ”€โ”€โ”‚   Business       โ”‚โ—„โ”€โ”€โ”€โ”‚   Data Access   โ”‚
โ”‚   Controllers   โ”‚    โ”‚   Services       โ”‚    โ”‚   Layer (JPA)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ–ผ                       โ–ผ                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   HTTP          โ”‚    โ”‚   Business       โ”‚    โ”‚   PostgreSQL    โ”‚
โ”‚   Clients       โ”‚    โ”‚   Logic & DTOs   โ”‚    โ”‚   Database      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ—„ Database Diagram (Mermaid)

erDiagram
    USERS {
        integer user_id PK
        string username
        string email
        string phone_number
        string hash_password
        string role
        string status
    }

    CART {
        integer cart_id PK
        integer user_id FK
    }

    CART_ITEMS {
        integer cart_item_id PK
        integer cart_id FK
        integer product_id FK
        int quantity
    }

    PRODUCTS {
        integer product_id PK
        string product_name
        string product_description
        decimal product_price
        decimal product_discount_price
        string image
        integer category_id FK
    }

    CATEGORIES {
        integer category_id PK
        string category_name
        string image
    }

    ORDERS {
        integer order_id PK
        integer user_id FK
        datetime created_at
        datetime updated_at
        string delivery_address
        string delivery_method
        string contact_phone
        string status
    }

    ORDER_ITEMS {
        integer order_item_id PK
        integer order_id FK
        integer product_id FK
        int quantity
        decimal price_at_purchase
    }

    FAVOURITES {
        integer favourite_id PK
        integer user_id FK
        integer product_id FK
    }

    USERS ||--o{ CART : owns
    USERS ||--o{ ORDERS : places
    USERS ||--o{ FAVOURITES : has
    CART ||--o{ CART_ITEMS : contains
    PRODUCTS ||--o{ CART_ITEMS : appears_in
    PRODUCTS ||--o{ ORDER_ITEMS : appears_in
    CATEGORIES ||--o{ PRODUCTS : includes
    ORDERS ||--o{ ORDER_ITEMS : includes


๐Ÿ“ฆ Entities & DTOs Overview

User

Cart & CartItem

Product & Category

Order & OrderItem

Favourite

Statistic


๐Ÿ›  Services Overview

UserService

CartService

CartItemService

ProductService

CategoryService

OrderService

OrderItemService

FavouriteService

StatisticService

ConfirmationCodeService


๐Ÿ“˜ API Documentation


โš™ Installation

Clone repository

git clone https://github.com/YuriyDolgikh/onlineshop.git
cd onlineshop


โ–ถ Local Run

  1. Install Java 17 & Maven
  2. Configure PostgreSQL in application.properties
  3. Run from IDE or:
mvn spring-boot:run

โ–ถ Run with Maven

mvn clean install
mvn spring-boot:run

๐Ÿณ Run with Docker

docker-compose up --build

๐Ÿ”ง Configuration

File:

src/main/resources/application.properties

Example:

server.port=8080

spring.datasource.url=jdbc:postgresql://localhost:5432/onlineshop
spring.datasource.username=your_user
spring.datasource.password=your_password

spring.jpa.hibernate.ddl-auto=update

๐Ÿงช Testing

Run all tests:

mvn test

โ˜ Deployment

Previously deployed to Heroku:

https://api.onlineshop.name

Suitable for:


๐Ÿ“‚ Project Structure

onlineshop/
 โ”œโ”€โ”€ src/
 โ”‚   โ”œโ”€โ”€ main/
 โ”‚   โ”‚   โ”œโ”€โ”€ java/
 โ”‚   โ”‚   โ”œโ”€โ”€ resources/
 โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ application.properties
 โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ static/ (HTML documentation)
 โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ templates/
 โ”‚   โ”œโ”€โ”€ test/
 โ”œโ”€โ”€ docker-compose.yml
 โ”œโ”€โ”€ Dockerfile
 โ”œโ”€โ”€ pom.xml
 โ””โ”€โ”€ README.md

๐ŸŽ‰ Summary

A complete full-stack-ready REST backend for an e-commerce system with: