Excerpt from the checkout orchestrator service
# Orchestrator Service
# Main system that integrates cart, inventory, and payment
from flask import Flask, jsonify, request
import requests
app = Flask(__name__)
INVENTORY_URL = "http://localhost:5001"
CART_URL = "http://localhost:5002"
PAYMENT_URL = "http://localhost:5003"
@app.route("/checkout", methods=["POST"])
def checkout():
data = request.get_json()
item = data.get("item")
quantity = data.get("quantity", 0)
method = data.get("method", "credit_card")
amount = data.get("amount", 0)
inventory_response = requests.get(f"{INVENTORY_URL}/inventory/{item}")
stock = inventory_response.json().get("stock", 0)
if stock >= quantity:
requests.post(f"{CART_URL}/cart/add", json={"item": item, "quantity": quantity})
requests.post(f"{INVENTORY_URL}/inventory/{item}/reduce", json={"quantity": quantity})
payment_response = requests.post(f"{PAYMENT_URL}/payment", json={"method": method, "amount": amount})
return jsonify(payment_response.json())
return jsonify({"message": f"Not enough stock for {item}."}), 400
if __name__ == "__main__":
app.run(port=5000)Project objective
Improve scalability, maintainability, and independent change by separating retail business functions that were coupled inside one monolithic program.
What I produced
- Compared software architecture patterns across retail, event ticketing, and other business scenarios.
- Selected microservices and cloud deployment for a retail environment with seasonal demand and changing vendors.
- Split the original Python system into cart, inventory, payment, and orchestration services.
- Used Flask HTTP endpoints and test cases to demonstrate service behavior and combined checkout flow.
Key decisions
- Separate services by business capability rather than arbitrary technical layers.
- Keep orchestration responsible for coordinating the checkout workflow.
- Use APIs so services can evolve independently and be deployed separately.
- Choose cloud hosting to support seasonal scaling rather than purchasing for peak demand.
4 servicesCart, inventory, payment, and orchestration
3 scenariosArchitecture patterns compared
Working prototypeHTTP-based checkout flow demonstrated
Validation and analysis
- Created functional test cases for service endpoints and checkout behavior.
- Demonstrated the prototype and documented expected results.
- Compared the prototype with the original monolithic implementation.