System Design & Internals

Platform Architecture

Event-driven, serverless cloud topology engineered for zero idle compute costs, atomic inventory reservations, and automatic scaling during high-traffic textile sale events.

End-to-End System Topology

Vastra Platform routes all traffic through AWS CloudFront with AWS WAF security inspection before serving SPAs or invoking Lambda APIs.

[Route 53 DNS]
       |
  [AWS WAF] (Rate-limiting, Turnstile check, SQLi / XSS protection)
       |
[CloudFront Global CDN]
       |--> S3 Customer SPA Bucket (React 19 customer storefront)
       |--> S3 Admin SPA Bucket (Merchant catalog & operations desk)
       |--> S3 Product Assets (WebP swatches, product photography)
       |
[Amazon API Gateway (HTTP/REST)]
       |
[AWS Lambda Runtime (ARM64 / Node.js 22)]
       |
       |---> [Amazon DynamoDB] (Single-table transactional store)
       |---> [Amazon SES] (Transactional order confirmations & refund notices)
       |---> [Paytm Payment Gateway API] (Order tokenization & refund dispatch)
       |---> [Shiprocket Logistics API] (AWB booking & shipping manifest generation)

DynamoDB Single-Table Schema

To avoid RDS connection pooling overhead and cold-start connection penalties, all entities reside in a single high-performance DynamoDB table.

Entity Partition Key (PK) Sort Key (SK) GSI1-PK / GSI1-SK Attributes
Product PRODUCT#<productId> METADATA CATEGORY#<slug> / PRICE#<cents> Title, SKU, basePrice, images, stockCount, tags
Product Variant PRODUCT#<productId> VARIANT#<variantId> SKU#<skuCode> / METADATA Color, size, fabric, stockQuantity, priceDelta
Customer Order ORDER#<orderId> DETAILS CUSTOMER#<custId> / CREATED#<isoDate> Items, totalAmount, status, paytmTxnId, shippingAddress
Order Item ORDER#<orderId> ITEM#<sku> Unit price, quantity, color, product title
Inventory Lock LOCK#<sku> ORDER#<orderId> Reserved units, lockExpiresAt (TTL attribute)

Order Lifecycle State Machine

Atomic state transitions ensure no double-charging, no phantom inventory reservations, and 100% automated refund processing.

1

Checkout & Lock

Customer initiates payment. Inventory reservation lock is created with a 15-minute TTL. Transaction token generated via Paytm API.

2

Payment Verification

Asynchronous webhook from Paytm received. HMAC checksum validated. If verified, order status updates to CONFIRMED and stock is permanently decremented.

3

Dispatch & Delivery

Shiprocket AWB generated automatically. Label printed in merchant desk. Customer receives tracking SMS & email.

4

Cancellation & Refund

If cancelled by merchant or customer, Lambda calls Paytm Refund API. On success, stock units are atomically incremented back to inventory.