Back to Case Study Catalog
🛒
APIs · AWS
PUBLIC LIVE DEMOStatus: DEPLOYED (Running)

Shopify Embedded App

Serverless Multi-Tenant SaaS Integration

Execution Profile: Serverless Lambda + DynamoDB
Cost Guardrail:< $0.50 / mo

Problem Statement & Investigation

Third-party merchant applications receive massive bursts of webhook traffic (e.g. Flash sales, Black Friday) that can easily overwhelm standard VM-based web servers and lead to dropped order events.

Architectural Hypothesis

An event-driven serverless architecture using AWS Lambda and API Gateway can absorb 100x traffic surges instantly while maintaining strict webhook HMAC cryptographic verification and sub-50ms acknowledgment.

System Runtime Flow

11. Shopify Webhook Ingress

Shopify sends signed JSON payloads to AWS API Gateway endpoints with HMAC-SHA256 headers.

22. Cryptographic Attestation

FastAPI Mangum Lambda handler verifies request body signature against the Shopify client secret.

33. Distributed State Lock

DynamoDB atomic condition locks ensure order webhooks are processed exactly once per unique order ID.

44. Merchant Dashboard

React frontend embedded within the Shopify Admin iframe communicates with JWT session token verification.

Architecture Decision Records (ADRs)

ADR-001: Serverless Mangum Adapter for FastAPI on LambdaACCEPTED
Decision: Wrap FastAPI using Mangum to run on AWS Lambda without rewriting application routes.
Alternatives Evaluated: AWS ECS Fargate, Express.js on Lambda, Serverless Framework with raw handlers.
Consequences: Maintains Python standard framework code while leveraging serverless autoscaling and zero idle hosting cost.
ADR-002: DynamoDB for Merchant Session TokensACCEPTED
Decision: Store offline Shopify OAuth access tokens in DynamoDB with KMS encryption at rest.
Alternatives Evaluated: Redis/ElastiCache, RDS PostgreSQL.
Consequences: Eliminated $15+/mo persistent ElastiCache costs; predictable sub-5ms token lookup per request.

Failure-Mode & Resilience Analysis

Scenario: Webhook Burst During Flash Sales
Observed Behavior: Shopify sends thousands of concurrent order updates.
Architectural Mitigation: API Gateway automatically queues and invokes Lambda instances concurrently with zero packet drops.
Scenario: Invalid HMAC Signature
Observed Behavior: Spoofed or tampered webhook payload received.
Architectural Mitigation: Immediate cryptographic rejection with HTTP 401 Unauthorized before performing any database read.

Key Engineering Takeaways

  • Shopify requires webhooks to be acknowledged within 5 seconds; keeping handlers completely asynchronous is non-negotiable.
  • Raw request body bytes must be preserved untouched for HMAC-SHA256 signature verification.

Empirical Benchmarks

HMAC Validation Time1.2ms
Cryptographic SHA256 verification overhead per webhook
Webhook ACK Latency38ms
Total response latency returned to Shopify to prevent retries
Merchant Session Check3.6ms
DynamoDB token lookup with KMS decryption
Monthly Idle Cost< $0.50
Zero fixed instances; pay strictly per processed webhook

Technology Primitives

frontend
React 18 + Vite + Tailwind
backend
FastAPI + Mangum (Lambda)
database
DynamoDB (4 tables)
infra
Terraform + API Gateway + CloudFront
auth
Shopify OAuth 2.0 + JWT
payments
Stripe Subscriptions

Architecture Tags

Shopify OAuthFastAPIDynamoDBStripeAWS LambdaTerraform
Security Notice

Public Live Demo · Detailed Architecture & Deploy Keys Secured. Operational lifecycle commands (Deploy, Scale, Destroy) and raw cloud credentials remain sealed in the private control plane.