Back to Case Study Catalog
☕
Serverless · AWS
DEMO INACTIVE (PAUSED)Status: STOPPED (Scaled to 0)

Coffee Shop

Full-Stack Serverless CRUD

Execution Profile: Serverless On-Demand (Zero Idle Cost)
Cost Guardrail:< $0.20 / mo (Free Tier Optimized)

Problem Statement & Investigation

Traditional relational databases incur constant hourly costs even when traffic drops to zero overnight. For occasional and variable-traffic applications, an architectural model was required that scales to zero cost while delivering sub-20ms transactional writes.

Architectural Hypothesis

By organizing orders, customers, and inventory items into a single DynamoDB table using composite partition/sort keys, we can satisfy all primary access patterns within single-digit millisecond latency without running persistent database instances.

System Runtime Flow

11. Edge Ingress

Client requests hit AWS CloudFront with Origin Access Control (OAC) and TLS 1.2 termination, routing static UI assets from S3.

22. API Routing

REST operations route to AWS API Gateway HTTP APIs with CORS validation and route-level rate limiting.

33. Compute Execution

Node.js 20 Lambda functions execute order validation and atomic state updates inside a minimal 512MB memory profile.

44. Atomic Persistence

Transactions write to Amazon DynamoDB using conditioned put operations (`attribute_not_exists`) to prevent duplicate orders.

Architecture Decision Records (ADRs)

ADR-001: Single-Table DynamoDB over Multi-TableACCEPTED
Decision: Colocate orders, items, and customer metadata into a single DynamoDB table with GSI1 and GSI2.
Alternatives Evaluated: Separate tables for Users, Orders, and Products; Amazon RDS PostgreSQL.
Consequences: Eliminated cross-table joins and reduced read capacity units (RCU); increased upfront schema design complexity.
ADR-002: API Gateway HTTP API over REST APIACCEPTED
Decision: Use API Gateway v2 (HTTP APIs) instead of v1 (REST APIs).
Alternatives Evaluated: Application Load Balancer (ALB), CloudFront Lambda@Edge, REST APIs.
Consequences: 70% lower API Gateway cost, lower baseline latency (~10ms reduction); lack of native request validation schemas.

Failure-Mode & Resilience Analysis

Scenario: Sudden Traffic Spike (1,000 orders/sec)
Observed Behavior: DynamoDB on-demand mode dynamically allocates partition splits within seconds.
Architectural Mitigation: Lambda reserved concurrency cap prevents accidental exhaustion of account-level concurrency limits.
Scenario: Duplicate Order Submission
Observed Behavior: Idempotency keys passed in request headers.
Architectural Mitigation: DynamoDB conditional writes reject duplicate idempotency IDs with HTTP 409 Conflict.

Key Engineering Takeaways

  • Single-table DynamoDB requires identifying 100% of read and write access patterns before writing any application code.
  • Tree-shaking AWS SDK v3 client packages reduced Lambda package size from 38MB to 4.2MB, cutting cold starts by over 50%.
  • API Gateway HTTP APIs provide significantly lower latency than REST APIs for lightweight microservices.

Empirical Benchmarks

Median p95 Latency18ms
Warm execution latency for transactional order placement
Cold-Start Duration185ms
Node.js 20 ES module runtime with bundled tree-shaken dependencies
Idle Monthly Cost$0.00
Zero fixed baseline cost when no incoming requests are received
CloudFront TTFB11ms
Edge-cached static asset delivery via Global POPs

Technology Primitives

frontend
React 19 + Vite
backend
Node.js 20 Lambda
database
DynamoDB (on-demand)
infra
Terraform + CloudFront + OAC

Architecture Tags

AWS LambdaDynamoDBAPI GatewayReact 19TerraformCloudFront
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.