Skip to main content

Ecommerce Order Service

A production-ready REST API service for managing orders in e-commerce platforms with event-driven architecture, domain-driven design, and comprehensive testing.

POST /orders
”items”: [“productId”: ”…”…],
“address”: ”…
→ 201 Created

Quick start

Get your order service running in minutes

1

Clone and setup dependencies

Clone the repository and ensure you have the required infrastructure running:
git clone https://github.com/e-commerce-sample/ecommerce-order-service.git
cd ecommerce-order-service
Start RabbitMQ and Zipkin from the devops repository (required for the full system).
2

Run the service locally

Use the provided script to start MySQL and run the service:
./run.sh
The service will start on port 8080 with a debug port on 5005.
3

Create your first order

Send a POST request to create an order:
curl -X POST http://localhost:8080/orders \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {
        "productId": "product-123",
        "count": 2,
        "itemPrice": 29.99
      }
    ],
    "address": {
      "province": "California",
      "city": "San Francisco",
      "detail": "123 Market St"
    }
  }'
{
  "id": "ORDER_20240304123456789"
}
4

Query the order

Retrieve the order details using the returned ID:
curl http://localhost:8080/orders/ORDER_20240304123456789
The response includes the order status, items, total price, and address.

Key features

Built for production with modern patterns and comprehensive testing

Event-driven architecture

Built with RabbitMQ for reliable event publishing and CQRS pattern for query optimization

Domain-driven design

Clean domain model with aggregates, factories, and rich business logic encapsulation

Comprehensive testing

Multi-level testing strategy with unit, component, and API tests using JUnit 5 and Rest Assured

Java SDK included

Published SDK with commands, events, and models for seamless integration

RESTful API

Complete order lifecycle management through intuitive REST endpoints

Production ready

Docker support, MySQL persistence, distributed tracing with Zipkin

Explore by topic

Deep dive into architecture, APIs, and integration patterns

Architecture

Understand the system design and component structure

Order lifecycle

Learn how orders transition through states

Configuration

Configure database, messaging, and application properties

API reference

Complete REST API documentation with examples

SDK integration

Use the Java SDK in your microservices

Deployment

Deploy to staging and production environments

Ready to build?

Start integrating the order service into your e-commerce platform today.