Skip to content

About

A distributed system capable of processing high-volume order traffic with eventual consistency guarantees. Features include a custom implementation of the Saga Pattern for distributed transactions, optimistic locking for inventory management, and a fully containerized deployment pipeline.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Distributed Order Fulfillment Platform

Developed by Bhushan Asati GitHub

A production-grade microservices platform for order fulfillment with high concurrency, distributed transactions (Saga pattern), and fault tolerance.

Go Version License Docker Kubernetes

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              Client Applications                             β”‚
β”‚                         (Web App, Mobile App, Partners)                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              API Gateway                                     β”‚
β”‚                    (Auth, Rate Limiting, Routing, CORS)                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β–Ό                 β–Ό                 β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚    Order     β”‚  β”‚  Inventory   β”‚  β”‚   Payment    β”‚
            β”‚   Service    β”‚  β”‚   Service    β”‚  β”‚   Service    β”‚
            β”‚   (Saga)     β”‚  β”‚  (Locking)   β”‚  β”‚ (Idempotent) β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚                 β”‚                 β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                            Apache Kafka                                      β”‚
β”‚              (orders.created, inventory.reserved, payment.success)           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚                 β”‚                 β”‚
                    β–Ό                 β–Ό                 β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚  Fulfillment β”‚  β”‚ Notification β”‚  β”‚    Redis     β”‚
            β”‚   Service    β”‚  β”‚   Service    β”‚  β”‚    Cache     β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

✨ Features

  • Saga Pattern - Distributed transactions with compensating actions
  • Idempotency - Duplicate request handling with idempotency keys
  • Database Locking - Pessimistic & optimistic locking for inventory
  • Event-Driven - Kafka-based async communication
  • Multi-Cloud - Terraform for AWS & GCP
  • Observability - Structured logging, tracing, metrics

πŸ“¦ Project Structure

distributed-fulfillment-platform/
β”œβ”€β”€ .github/workflows/          # CI/CD pipelines
β”œβ”€β”€ api/                        # API contracts
β”‚   β”œβ”€β”€ openapi/                # REST API specs
β”‚   └── proto/                  # gRPC definitions
β”œβ”€β”€ apps/                       # Microservices
β”‚   β”œβ”€β”€ api-gateway/
β”‚   β”œβ”€β”€ order-service/
β”‚   β”œβ”€β”€ inventory-service/
β”‚   β”œβ”€β”€ payment-service/
β”‚   β”œβ”€β”€ fulfillment-service/
β”‚   └── notification-service/
β”œβ”€β”€ libs/                       # Shared libraries
β”‚   β”œβ”€β”€ common/
β”‚   β”œβ”€β”€ database/
β”‚   β”œβ”€β”€ messaging/
β”‚   └── logger/
β”œβ”€β”€ infra/                      # Infrastructure
β”‚   β”œβ”€β”€ docker-compose.yml
β”‚   β”œβ”€β”€ k8s/
β”‚   └── terraform/
└── tools/                      # Scripts & utilities

πŸš€ Quick Start

Prerequisites

  • Go 1.23+
  • Docker & Docker Compose
  • Make

Local Development

# Clone repository
git clone https://github.com/bhushanasati25/Distributed-Order-Fulfillment-Platform.git
cd Distributed-Order-Fulfillment-Platform

# Start infrastructure (PostgreSQL, Redis, Kafka)
make infra-up

# Run all services
make run-all

# Or run individual service
make run-order

API Testing

# Create an order
curl -X POST http://localhost:8080/api/v1/orders \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "customer_id": "cust_123",
    "items": [
      {"sku": "PROD-001", "quantity": 2, "price": 29.99}
    ],
    "shipping_address": {
      "street": "123 Main St",
      "city": "New York",
      "state": "NY",
      "zip": "10001"
    }
  }'

# Check order status
curl http://localhost:8080/api/v1/orders/{order_id}

πŸ”„ Saga Flow

1. Client β†’ Order Service: POST /orders
2. Order Service: Creates PENDING order
3. Order Service β†’ Kafka: Publish "OrderCreated"
4. Inventory Service: Consumes event β†’ Reserves stock
5. Inventory Service β†’ Kafka: Publish "StockReserved"
6. Payment Service: Consumes event β†’ Charges card
7. Payment Service β†’ Kafka: Publish "PaymentSuccess"
8. Order Service: Consumes event β†’ Updates to CONFIRMED
9. Notification Service: Sends confirmation email

Compensating Transactions

If Payment fails:
1. Payment Service β†’ Kafka: Publish "PaymentFailed"
2. Inventory Service: Releases reserved stock
3. Order Service: Updates to CANCELLED
4. Notification Service: Sends cancellation email

πŸ› οΈ Tech Stack

Component Technology
Language Go 1.23
API REST + gRPC
Messaging Apache Kafka
Database PostgreSQL 15
Cache Redis 7
Container Docker
Orchestration Kubernetes
IaC Terraform
CI/CD GitHub Actions

πŸ“Š Services

Service Port Description
API Gateway 8080 Entry point, auth, rate limiting
Order Service 8081 Order lifecycle, Saga orchestrator
Inventory Service 8082 Stock management, reservations
Payment Service 8083 Payment processing, Stripe/PayPal
Fulfillment Service 8084 Shipping, FedEx/UPS integration
Notification Service 8085 Email/SMS notifications

πŸ§ͺ Testing

# Run all tests
make test

# Run with coverage
make test-coverage

# Integration tests (requires Docker)
make test-integration

# Load testing
make test-load

πŸ“ˆ Monitoring

  • Metrics: Prometheus + Grafana
  • Tracing: Jaeger / OpenTelemetry
  • Logging: Structured JSON logs (zerolog)

🚒 Deployment

Docker Compose (Development)

docker-compose -f infra/docker-compose.yml up -d

Kubernetes (Production)

# Apply Helm charts
helm install fulfillment-platform ./infra/k8s/charts/platform

# Or using kubectl
kubectl apply -f ./infra/k8s/manifests/

Terraform (Cloud Infrastructure)

cd infra/terraform/aws  # or gcp
terraform init
terraform plan
terraform apply

πŸ“„ License

MIT License - see LICENSE for details.

πŸ‘₯ Contributing

See CONTRIBUTING.md for contribution guidelines.

πŸ‘¨β€πŸ’» Author

Bhushan Asati

About

A distributed system capable of processing high-volume order traffic with eventual consistency guarantees. Features include a custom implementation of the Saga Pattern for distributed transactions, optimistic locking for inventory management, and a fully containerized deployment pipeline.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages