QuickShip is a high-speed e-commerce data aggregation service that concurrently fetches product data (price, inventory, promotions) from multiple microservices to deliver lightning-fast API responses.
It uses Go’s Fan-Out / Fan-In concurrency pattern to drastically cut latency.
Modern e-commerce platforms depend on several microservices to compute real-time product information.
Calling them one-by-one is too slow.
QuickShip solves this by:
- Running all service calls in parallel
- Returning results as fast as the slowest service
- Ensuring consistent, low-latency API responses
50ms + 200ms + 400ms = 650ms
~400ms (determined by the slowest service)
| Service | Latency |
|---|---|
| fetchPromotionsSimulates | 50ms |
| fetchPriceSimulates | 200ms |
| fetchInventorySimulates | 400ms |
┌────────────────┐
Request → │ GetCartSummary │
└───────┬────────┘
│
(Fan-Out: Launch workers)
▼
┌──────────────┬──────────────┐
▼ ▼ ▼
Promotions Price Service Inventory
Worker Worker Worker
(50ms) (200ms) (400ms)
└──────────────┬──────────────┘
│
(Fan-In: Combine)
▼
Final Cart Summary JSON
- Go 1.18+
- Gorilla Mux router
go get github.com/gorilla/mux
---
Place main.go and main_test.go in your project directory.
Start the application:
go run main.goOpen in browser or Postman:
http://localhost:8080
Run:
curl http://localhost:8080/cart/summary/SKU-REFAC-TEST[Quickship_api] (https://go-quickship.onrender.com/cart/summary/32)
{
"product_id": "SKU-REFAC-TEST",
"final_price": 49.99,
"available_stock": 120,
"promotion_message": "Buy 1 Get 1 Half Off!",
"total_time_ms": 405
}go test -v .Tests verify:
- Correct data returned
- Concurrency reduces execution time
QuickShip/
├── main.go
├── main_test.go
├── go.mod
└── go.sum
📜 License You are free to use, modify, and distribute this project.
