Orchestra Internal API Mapping

Cart

Shopping cart operations with 3-layer architecture: API Gateway -> Cart & Checkout Orchestrator -> Core Microservices

View Postman Documentation

3-Layer Architecture

API Gateway Public (Internet)
Cart & Checkout Internal Orchestration
Core Microservices Internal Services

Add/Update Cart Items

Full Computation

Complete flow with validation, pricing, promotions, and cart computation (10 steps)

POST

REQUEST BODY

{
  "operations": [
    { "op": "SET", "product_id": "...", "variant_id": "...", "quantity": 2, "addons": [...] },
    { "op": "ADD", "product_id": "...", "quantity": 1 },
    { "op": "UPDATE", "item_id": "...", "quantity": 3 },
    { "op": "DELETE", "item_id": "..." }
  ]
}
API Gateway Layer 1 - Public
POST /cart/items
Cart & Checkout Layer 2 - Orchestration
POST /cart/items

Orchestrates 10 service calls (with parallel execution)

Layer 3 - Service Calls (10 Steps)
1 Cart Service Core Microservices
POST /api/carts/find-or-create

Get existing cart or create new one in single call

Parallel Calls (Steps 2-6)
2 Product Service
GET /api/products/search

Validate products, addons & variants

3 Inventory Service
POST /api/inventory/check-availability

Check stock availability

4 Seller Order & Fulfillment
POST /api/shipping/calculate-rate

Calculate delivery charges (conditional)

5 Seller Admin
GET /merchant/api/v1/domains/:domain_id/stores/:store_id

Check store active/online status, basic details

6 Seller Admin
GET /api/v1/domains/:domain_id/stores/:store_id/tax_settings

Get store tax configuration

7 Marketing & Promotions Service Core Microservices
POST /api/promotions/applicable

Get auto-applicable promotions, combo offers

8 Cart Service Core Microservices
POST /api/carts/:cart_id/items/batch

Apply batch operations (SET, ADD, UPDATE, DELETE)

9 Cart Service Core Microservices
POST /api/carts/:cart_id/compute

Recalculate cart totals with all charges and discounts

10 Caching Service Shared Services
POST /api/caching/set
Key: cart:{cart_id}:computed | TTL: 1800s (30 mins)

RESPONSE

{
  "success": true,
  "operations_applied": 4,
  "results": [
    { "operation": "SET", "status": "SUCCESS", "action_taken": "ADDED", "item": {...} },
    { "operation": "UPDATE", "status": "SUCCESS", "item_id": "..." },
    { "operation": "ADD", "status": "SUCCESS", "item": {...} },
    { "operation": "DELETE", "status": "FAILED", "error": "Item not found", "item_id": "..." }
  ],
  "cart": { ...full computed cart... },
  "coupon_applied": [...]
}

Add/Update Cart Items

No Computation

Lightweight flow - skips validation and computation, only applies operations (3 steps)

POST

REQUEST BODY

{
  "operations": [
    { "op": "SET", "product_id": "...", "variant_id": "...", "quantity": 2, "addons": [...] },
    { "op": "ADD", "product_id": "...", "quantity": 1 },
    { "op": "UPDATE", "item_id": "...", "quantity": 3 },
    { "op": "DELETE", "item_id": "..." }
  ]
}
API Gateway Layer 1 - Public
POST /cart/items
Cart & Checkout Layer 2 - Orchestration
POST /cart/items

Lightweight flow - 3 sequential calls only

Layer 3 - Service Calls (3 Steps Only)
1 Cart Service Core Microservices
POST /api/carts/find-or-create

Get existing cart or create new one

2 Cart Service Core Microservices
POST /api/carts/:cart_id/items/batch

Apply batch operations directly

3 Caching Service Shared Services
POST /api/caching/set
Key: cart:{cart_id}:computed | TTL: 1800s

RESPONSE

{
  "success": true,
  "operations_applied": 4,
  "results": [
    { "operation": "SET", "status": "SUCCESS", "action_taken": "ADDED", "item": {...} },
    { "operation": "UPDATE", "status": "SUCCESS", "item_id": "..." },
    { "operation": "ADD", "status": "SUCCESS", "item": {...} },
    { "operation": "DELETE", "status": "FAILED", "error": "Item not found", "item_id": "..." }
  ],
  "cart": { ...full computed cart... },
  "coupon_applied": [...]
}

Update Cart Options

Full Validation

Update coupons, addresses, tips, delivery, payment, gift wrap, instructions (12 steps)

PUT

REQUEST BODY

{
  "coupons": [{ "code": "SAVE20" }],
  "address": {
    "shipping_address": { "address_id": "addr_456" },
    "billing_address": { "same_as_shipping": false, "address_id": "addr_456" }
  },
  "tips": { "amount": 50, "currency": "INR", "description": "Thank you tip" },
  "delivery_option": { "delivery_option_id": "deliv_opt_123" },
  "delivery_preference": {
    "scheduled": { "date": "2025-11-10", "slot": { "id": "slot_today_1", "label": "6:00 PM - 6:30 PM" } },
    "immediate": null
  },
  "pickup_point": { "pickup_point_id": "pickup-point-option-id" },
  "payment_method": { "payment_method_id": "pay_method_789" },
  "gift_wrap": { "id": "gift_wrap_standard", "message": "Happy Birthday!" },
  "special_instructions": { "instructions": "Please leave at front door." }
}
API Gateway Layer 1 - Public
PUT /cart
Cart & Checkout Layer 2 - Orchestration
PUT /cart

Orchestrates 12 service calls (with parallel validation)

Layer 3 - Service Calls (12 Steps)
1 Cart Service Core Microservices
GET /api/carts/:cart_id

Get existing cart

Parallel Validation (Steps 2-7) - Based on Request Fields
2 Marketing Service
POST /api/coupons/validate

Validate coupon codes (if provided)

3 Customer Service
GET /api/addresses/:address_id

Validate shipping/billing addresses

4 Seller Admin
GET /api/delivery-options/:id

Validate delivery option

5 Seller Admin
GET /api/pickup-points/:id

Validate pickup point

6 Payment Service
GET /api/payment-methods/:id

Validate payment method

7 Seller Admin
GET /api/gift-wrap-options/:id

Validate gift wrap option & pricing

8 Cart Service Core Microservices
PUT /api/carts/:cart_id/options

Update cart with validated options

9 Seller Order & Fulfillment Orchestration
POST /api/shipping/calculate-rate

Calculate delivery charges (if delivery option changed)

10 Marketing Service Core Microservices
POST /api/promotions/applicable

Recalculate promotions based on new cart state

11 Cart Service Core Microservices
POST /api/carts/:cart_id/compute

Recalculate totals with tips, gift wrap, delivery

12 Caching Service Shared Services
POST /api/caching/set
Key: cart:{cart_id}:computed | TTL: 1800s (30 mins)

RESPONSE

{
  "success": true,
  "cart": { ...full computed cart with updated options... },
  "validations": {
    "coupon": { "status": "VALID", "discount": 200 },
    "address": { "status": "VALID" },
    "delivery_option": { "status": "VALID", "charge": 50 },
    "payment_method": { "status": "VALID" }
  }
}

Get Cart

Full Computation

Retrieve cart with full recomputation - validates items, pricing, inventory, promotions (11 steps)

GET

QUERY PARAMETERS

?compute=true (default)
API Gateway Layer 1 - Public
GET /cart
Cart & Checkout Layer 2 - Orchestration
GET /cart

Orchestrates 11 service calls (with parallel validation)

Layer 3 - Service Calls (11 Steps)
1 Cart Service Core Microservices
GET /api/carts/:cart_id

Get existing cart

Parallel Validation (Steps 2-6)
2 Product Service
GET /api/products/search

Validate products still active with current pricing

3 Inventory Service
POST /api/inventory/check-availability

Check stock availability for all items

4 Seller Admin
GET /merchant/api/v1/.../stores/:store_id

Check store is active

5 Seller Admin
GET /api/v1/.../tax_settings

Get store tax configuration

6 Seller Admin
GET /api/delivery-options/:id

Validate delivery option (if set)

7 Seller Order & Fulfillment Orchestration
POST /api/shipping/calculate-rate

Calculate delivery charges (if delivery option selected)

8 Marketing Service Core Microservices
POST /api/promotions/applicable

Get auto-applicable promotions, combo offers

9 Marketing Service Core Microservices
POST /api/coupons/validate

Re-validate any applied coupons are still valid

10 Cart Service Core Microservices
POST /api/carts/:cart_id/compute

Recalculate totals: subtotal, discounts, taxes, delivery, tips, gift wrap, net_payable

11 Caching Service Shared Services
POST /api/caching/set
Key: cart:{cart_id}:computed | TTL: 1800s (30 mins)

RESPONSE

{
  "success": true,
  "cart": {
    "cart_id": "...",
    "items": [...],
    "coupons_applied": [...],
    "address": { "shipping": {...}, "billing": {...} },
    "delivery_option": {...},
    "tips": {...},
    "gift_wrap": {...},
    "totals": {
      "subtotal": 1000,
      "discount": -200,
      "tax": 50,
      "delivery_charge": 50,
      "tips": 50,
      "gift_wrap": 25,
      "net_payable": 975
    }
  },
  "inventory_status": [
    { "product_id": "...", "available": true, "quantity_available": 10 }
  ],
  "warnings": []
}

Get Cart

Cached / No Computation

Fast retrieval from cache - returns last computed state without recomputation (2 steps)

GET

QUERY PARAMETERS

?compute=false (returns cached cart)
API Gateway Layer 1 - Public
GET /cart?compute=false
Cart & Checkout Layer 2 - Orchestration
GET /cart?compute=false

Fast path - 2 steps max (cache first, fallback to DB)

Layer 3 - Service Calls (2 Steps)
1 Caching Service Shared Services
GET /api/caching/get
Key: cart:{cart_id}:computed

Try to get from cache first (fast path)

2 Cart Service Core Microservices FALLBACK (if cache miss)
GET /api/carts/:cart_id

Get basic cart from DB without computation

RESPONSE

{
  "success": true,
  "from_cache": true,
  "cart": { ...cached computed cart... },
  "cache_age_seconds": 120
}

Delete Cart

Clear Cart

Delete entire cart - removes all items, clears cache, releases inventory reservations (3 steps)

DELETE
API Gateway Layer 1 - Public
DELETE /cart
Cart & Checkout Layer 2 - Orchestration
DELETE /cart

Delete cart and cleanup resources - 3 steps

Layer 3 - Service Calls (3 Steps)
1 Cart Service Core Microservices
DELETE /api/carts/:cart_id

Delete cart from database

2 Caching Service Shared Services
DELETE /api/caching/delete
Key: cart:{cart_id}:computed
3 Inventory Service Core Microservices
POST /api/inventory/release-reservations

Release any held inventory reservations

RESPONSE

{
  "success": true,
  "message": "Cart deleted successfully",
  "cart_id": "..."
}

Buy Now

Express Checkout

Quick purchase flow - creates cart and proceeds directly to checkout (3 steps)

POST

REQUEST BODY

{
  "operations": [
    { "op": "ADD", "product_id": "...", "quantity": 1 }
  ]
}
API Gateway Layer 1 - Public
POST /buy-now
Cart & Checkout Layer 2 - Orchestration
POST /buy-now

Express checkout flow - 3 sequential calls

Layer 3 - Service Calls (3 Steps)
1 Cart Service Core Microservices
POST /api/carts/find-or-create

Get existing cart or create new one

2 Cart Service Core Microservices
POST /api/carts/:cart_id/items/batch

Apply cart item operations

3 Caching Service Shared Services
POST /api/caching/set
Key: cart:{cart_id}:computed | TTL: 1800s

RESPONSE

{
  "success": true,
  "operations_applied": 1,
  "results": [
    { "operation": "ADD", "status": "SUCCESS", "item": {...} }
  ],
  "cart": { ...full computed cart... },
  "coupon_applied": [...]
}

Place Order

Checkout

Converts cart to order with multi-payment support: GATEWAY, WALLET, MANUAL/COD (13 steps)

POST

REQUEST BODY

{
  "payment_instruction": [
    { "full_amount": false, "amount": 150, "currency": "INR", "payment_mode": "GATEWAY", "gateway": "PHONEPE", "client_callback_url": "https://..." },
    { "full_amount": false, "amount": 50, "currency": "INR", "payment_mode": "WALLET", "gateway": "STORE-WALLET", "meta": { "wallet_id": "...", "otp": "..." } },
    { "full_amount": false, "amount": 50, "currency": "INR", "payment_mode": "MANUAL", "gateway": "COD" }
  ],
  "total_order_amount": 250,
  "multiple_payment_methods": true,
  "order_initiated_from": "WEB",
  "device": { "type": "MOBILE", "fingerprint": "fp_hash_456", "ip_address": "192.168.1.1", "user_agent": "Mozilla/5.0", "timezone": "Asia/Kolkata" }
}
API Gateway Layer 1 - Public
POST /cart/place-order
Cart & Checkout Layer 2 - Orchestration
POST /cart/place-order

Orchestrates multi-phase order flow (Phase 1: Order Creation, Phase 2: Post-Payment)

Phase 1: Pre-Order Validation & Order Creation
1 Cart Service Core Microservices
GET /api/carts/:cart_id

Get cart with all items and options

Parallel Validation (Step 2) - Pre-Order Check
2a Inventory Service
POST /api/inventory/check-availability

Final stock check (strict: true)

2b Product Service
GET /api/products/search

Compare current vs cart prices

2c Marketing Service
POST /api/coupons/validate

Re-validate coupons still applicable

2d Payment Validation
Σ payment_instruction.amount == total_order_amount

Ensure payment amounts match

3 Inventory Service Core Microservices
POST /api/inventory/reserve

TTL: 900s (15 min) - temporary hold on stock

4 Order Service Core Microservices
POST /api/orders

Create master order (type: MASTER, status: PENDING)

5 Order Service Core Microservices
POST /api/orders/:master_order_id/sub-orders

Create sub-orders per store/seller

6 Order Service Core Microservices
PUT /api/orders/:order_id/payment-status

Set payment status: PENDING

Parallel Payment Processing (Step 7) - Per Payment Instruction
7a Payment Service
POST /api/payments/initiate

GATEWAY (PhonePe, Razorpay)

→ redirect_url, gateway_order_id

7b Payment Service
POST /api/payments/initiate

WALLET (Store Wallet)

→ Instant debit with OTP

7c Payment Service
POST /api/payments/initiate

MANUAL (COD)

→ Auto-success, collect later

Phase 2: Post Payment Success (Backend Operations)

Triggered after payment confirmation webhook/callback

8 Inventory Service Core Microservices
POST /api/inventory/deduct

Convert reservation to actual deduction

9 Marketing Service Core Microservices
POST /api/coupons/used

Mark coupons as used for this order

10 Cart Service Core Microservices
DELETE /api/carts/:cart_id

Clear cart after successful order

11 Caching Service Shared Services
DELETE /api/caching/delete
Key: cart:{cart_id}:computed
Async Operations (Steps 12-13)
12 Notification Service
POST /api/notifications/send

Order confirmation: EMAIL, SMS, PUSH

13 Event Service
POST /api/events/publish

Event: ORDER_PLACED + device fingerprint

RESPONSE

{
  "success": true,
  "order": {
    "id": "order_999",
    "number": "ORD-2025-1234",
    "order_status": "PENDING",
    "payment_status": "PENDING",
    "total": 250,
    "currency": "INR",
    "sub_orders": [
      { "id": "sub_order_001", "number": "ORD-2025-1234-01", "store_id": "store_123", "order_status": "PENDING", "total": 250 }
    ]
  },
  "payment": [
    { "id": "pay_001", "status": "PENDING", "payment_mode": "GATEWAY", "gateway": "PHONEPE", "amount": 150, "redirect_url": "https://phonepe.com/pay/..." },
    { "id": "pay_002", "status": "SUCCESS", "payment_mode": "WALLET", "gateway": "STORE-WALLET", "amount": 50 },
    { "id": "pay_003", "status": "SUCCESS", "payment_mode": "MANUAL", "gateway": "COD", "amount": 50 }
  ]
}

Get Smart Cart Suggestions

AI-Powered

Intelligent product recommendations: complementary, bundles, upsells, threshold offers, reminders (9 steps)

GET
Layer 1: API Gateway
GET /cart/suggestions
Layer 2: Cart & Checkout Orchestrator

Coordinates suggestion generation from multiple recommendation sources

Layer 3: Core Microservices
1 Cart Service Core Microservices
GET /api/carts/:cart_id

Get current cart items for analysis

Parallel Suggestion Generation (Steps 2-6)
2 Recommendations
POST /api/recommendations/complementary

Frequently Bought Together

3 Marketing
POST /api/bundles/applicable

Bundle Deals

4 Recommendations
POST /api/recommendations/upsells

Upgrade Your Items

5 Marketing
POST /api/promotions/threshold-offers

Free Delivery / Discounts

6 Recommendations
POST /api/recommendations/reminders

Did You Forget?

7 Product Service Core Microservices
POST /api/products/search

Fetch full product details: images, prices, stock status

8 Inventory Service Core Microservices
POST /api/inventory/check-availability

Filter out out-of-stock suggestions

9 Orchestrator Internal Logic
Assemble & Rank Suggestions

Combine, deduplicate, rank by relevance/conversion probability

RESPONSE

{
  "success": true,
  "suggestions": [
    {
      "type": "COMPLEMENTARY",
      "title": "Frequently Bought Together",
      "items": [{ "product_id": "prod_456", "name": "Phone Case", "price": 299, "reason": "80% of customers bought this" }]
    },
    {
      "type": "THRESHOLD_BASED",
      "title": "Add ₹99 more for FREE Delivery!",
      "threshold": { "target_amount": 599, "current_amount": 500, "remaining_amount": 99, "benefit": "FREE_DELIVERY" },
      "items": [{ "product_id": "prod_789", "name": "Screen Protector", "price": 149 }]
    },
    {
      "type": "BUNDLE",
      "title": "Bundle Deal - Save 25%",
      "bundle": { "bundle_id": "bundle_123", "name": "Complete Accessory Kit", "bundle_price": 899, "savings": 301 },
      "items": [{ "product_id": "prod_456", "name": "Phone Case" }, { "product_id": "prod_789", "name": "Screen Protector" }]
    },
    {
      "type": "UPSELL",
      "title": "Upgrade Your Items",
      "items": [{ "product_id": "prod_premium_456", "name": "Premium Leather Case", "price": 799, "reason": "Better durability" }]
    },
    {
      "type": "REMINDER",
      "title": "Did You Forget?",
      "items": [
        { "product_id": "prod_saved_123", "name": "Bluetooth Earbuds", "price": 1299, "source": "WISHLIST" },
        { "product_id": "prod_viewed_456", "name": "Power Bank", "price": 899, "source": "RECENTLY_VIEWED" }
      ]
    }
  ],
  "meta": { "total_suggestions": 7, "suggestion_types": ["COMPLEMENTARY", "THRESHOLD_BASED", "BUNDLE", "UPSELL", "REMINDER"] }
}

Services Used in Cart Module

🛒

Cart Service

Find/create, batch ops, compute, options

📦

Product Service

Product validation, pricing

📊

Inventory Service

Stock availability, reservations

🎯

Marketing Service

Promotions, coupons, offers

🏪

Seller Admin

Store, tax, delivery, pickup, gift wrap

🚚

Shipping Service

Delivery rate calculation

👤

Customer Service

Address validation

💳

Payment Service

Payment method validation

Caching Service

Redis cache for cart

📋

Order Service

Master orders, sub-orders, seller orders

🎁

Loyalty Service

Points redemption, rewards

🔔

Notification Service

Email, SMS, Push notifications

📊

Event Service

Order events, analytics tracking

🤖

Recommendations Service

AI-powered suggestions, upsells, reminders

Cart API Summary

Method Endpoint Variant Steps Description
POST /cart/items Full 10 Add/update items with full validation & computation
POST /cart/items Lite 3 Add/update items without computation
PUT /cart Update 12 Update cart options (coupons, address, tips, etc.)
GET /cart Full 11 Get cart with full recomputation
GET /cart?compute=false Cached 2 Get cached cart (fast)
DELETE /cart Delete 3 Delete cart and cleanup
POST /buy-now Express 3 Quick purchase / express checkout
POST /cart/place-order Checkout 13 Convert cart to order with multi-payment (2 phases)
GET /cart/suggestions AI-Powered 9 Smart suggestions: complementary, bundles, upsells, reminders

Orchestra Internal API Mapping - Cart Module

Last Updated: December 2025