Skip to content

E-commerce Service API

πŸ›οΈ

A comprehensive e-commerce platform REST API built with Java, Spring Boot, and PostgreSQL. Manages product catalogs, shopping carts, inventory, orders, and customer purchases.


Features

Feature Description Icon
Product Catalog Manage products, categories, and descriptions πŸ“¦
Inventory Management Track stock levels and availability πŸ“Š
Shopping Cart Add, remove, and manage items in cart πŸ›’
Order Processing Process orders from cart to fulfillment πŸ“‹
Product Search Search and filter products with facets πŸ”
Reviews & Ratings Manage customer reviews and product ratings ⭐
Multi-Tenant Support Isolate catalogs and orders per tenant 🏒

Architecture Overview

flowchart TD
    A[Client] -->|REST API| B(EcommerceController)
    B --> C[ProductService]
    C --> D[InventoryService]
    C --> E[CartService]
    D --> F[ProductRepository]
    D --> G[InventoryRepository]
    E --> H[CartRepository]
    F --> I[(PostgreSQL)]
    G --> I
    H --> I
    C --> J[Search Engine]
Hold "Alt" / "Option" to enable pan & zoom

API Endpoints

Note: Real API endpoints to be provided and included here.

Method Endpoint Description Notes/Parameters
POST /api/v1/products Create product tenantId header, product data
GET /api/v1/products/{id} Get product details
POST /api/v1/cart Create shopping cart Customer ID
POST /api/v1/orders Create order from cart Cart ID

Sequence: Create Order from Cart

sequenceDiagram
    participant U as User
    participant API as EcommerceController
    participant C as CartService
    participant I as InventoryService
    participant O as OrderService
    participant Repo as OrderRepository
    U->>API: POST /orders (cartId)
    API->>C: retrieve cart
    C-->>API: cart items
    API->>I: verify inventory
    I-->>API: inventory confirmed
    API->>O: create order
    O->>Repo: save order
    Repo-->>O: order created
    O->>I: reserve inventory
    I-->>O: inventory reserved
    O-->>API: OrderResponse
    API-->>U: 201 Created + order details
Hold "Alt" / "Option" to enable pan & zoom

Database Schema

erDiagram
    products {
        UUID id PK
        UUID tenant_id
        VARCHAR product_name
        TEXT description
        DECIMAL price
        VARCHAR sku
        VARCHAR category
        TIMESTAMP created
        TIMESTAMP updated
    }

    inventory {
        UUID id PK
        UUID product_id FK
        INTEGER quantity_on_hand
        INTEGER reserved_quantity
        INTEGER reorder_level
        TIMESTAMP last_updated
    }

    shopping_carts {
        UUID id PK
        UUID customer_id
        UUID tenant_id
        VARCHAR status
        TIMESTAMP created
        TIMESTAMP updated
    }

    cart_items {
        UUID id PK
        UUID cart_id FK
        UUID product_id FK
        INTEGER quantity
        DECIMAL unit_price
        TIMESTAMP added_at
    }

    orders {
        UUID id PK
        UUID customer_id
        UUID tenant_id
        DECIMAL total_amount
        VARCHAR status
        TIMESTAMP order_date
        TIMESTAMP updated
    }

    products ||--o{ inventory : "has"
    products ||--o{ cart_items : "added_to"
    shopping_carts ||--o{ cart_items : "contains"
    orders ||--o{ cart_items : "includes"
Hold "Alt" / "Option" to enable pan & zoom

Getting Started

Prerequisites

  • Java 17+
  • PostgreSQL
  • Gradle

Setup

git clone https://github.com/Olanna-tech/ecommerce-service-java.git
cd ecommerce-service-java
./gradlew build

Database

  • Configure your PostgreSQL credentials in src/main/resources/application.yml.
  • Run Flyway migrations (auto on startup).

Run

./gradlew bootRun

Configuration

Set the following environment variables in application.yml:

ecommerce:
  search-enabled: true
  inventory-reservation-timeout-minutes: 15
  product-image-storage: aws-s3
  cart-expiry-hours: 24


Contributing

Pull requests are welcome! For major changes, please open an issue first.


License

MIT


Contact