Serverless ticket-drop backend on AWS. Prevents double-selling, keeps group bookings atomic, and refunds cancelled events exactly once.
Gatehold is a portfolio project that models the hard parts of a high-demand ticket sale: concurrent seat claiming, group adjacency, payment uncertainty, and mass refunds under rate limits.
It targets a realistic on-sale scenario: tens of thousands of buyers, a few thousand seats, families that need adjacent seats, an unreliable payment provider, and an event that may be cancelled mid-sale.
The system is fully serverless. Core services are TypeScript; operational tooling (mock payment provider, sweeper, reconciler, auditor, load generator) is Go. Infrastructure is AWS CDK.
| Goal | Outcome |
|---|---|
| Concurrency safety | A seat is never sold twice |
| Payment safety | Retries and duplicates never double-charge |
| Atomic groups | Adjacent seats are held completely or not at all |
| Cancellation | Every paid order is refunded once, within provider rate limits |
This is a learning and portfolio system, not production ticketing software. Payment and gate scanning are simulated.
| Language | Use |
|---|---|
| TypeScript | Core business logic (holds, orders, saga steps, cancellation, refunds) and CDK infrastructure |
| Go | Mock payment provider, hold sweeper, reconciler, stream relay, load generator, auditor |
| Tool | Role |
|---|---|
| AWS CDK (TypeScript) | Infrastructure as code |
| Node.js 20+ | Runtime for TypeScript Lambdas and CDK |
| Docker | Local emulator and reproducible tooling |
| MiniStack | Local AWS emulator for development and failure tests |
| Service | Role |
|---|---|
| API Gateway | Public HTTP API with throttling, validation, and JWT authorizers |
| Amazon Cognito | Fan authentication and admin group for cancellation |
| AWS Lambda | Holds, orders, saga steps, cancel, and refund workers |
| Amazon DynamoDB | Events, seats, orders, ledger, idempotency, refund batches |
| DynamoDB Streams | Change events relayed to EventBridge |
| AWS Step Functions | Purchase saga with compensation |
| Amazon SQS (+ DLQ) | Order buffering and rate-limited refund queue |
| Amazon EventBridge | Domain events (email, audit, analytics) |
| EventBridge Scheduler | Hold sweeper and reconciler schedules |
| Amazon SNS + SES | Notifications and email delivery |
| Amazon S3 | Signed tickets, refund reports, optional seat-map frontend |
| AWS KMS | Encryption at rest and ticket signing |
| Secrets Manager / SSM Parameter Store | Secrets and tunable configuration |
| Amazon CloudFront | Optional CDN for the seat-map frontend |
| Amazon CloudWatch + AWS X-Ray | Logs, metrics, alarms, and tracing |
- About
- Technologies
- The Problem
- Guarantees
- Design Challenges
- How It Works
- Architecture
- Tech Stack Rationale
- Data Model
- Key Design Decisions
- Failure Scenarios
- API Reference
- Repository Structure
- Getting Started
- Testing and Results
- Observability
- Security
- Cost
- Roadmap (detailed plan)
- Limitations
- License
High-demand ticket sales repeatedly fail in the same ways:
- The same seat is sold to two buyers
- A buyer is charged but never receives a ticket
- A retry or duplicate message charges someone twice
- A family of four is split across the venue, or left with a partial hold
- The API collapses under the on-sale burst
Cancellation makes it worse. Thousands of refunds must pass through a throttled payment provider. Some calls fail. No order should be refunded twice, and none should be forgotten.
Gatehold addresses these failure modes with managed AWS services only.
| # | Guarantee | Meaning |
|---|---|---|
| 1 | One seat, one buyer | A seat is never sold twice under concurrent claim |
| 2 | One purchase, one charge | Client retries, duplicate messages, and crashes do not double-charge |
| 3 | No charge without a ticket | Mid-purchase failure returns both money and seat |
| 4 | Together or not at all | A group hold succeeds completely or fails cleanly |
| 5 | Cancelled means refunded once | Every paid order is refunded once, within provider rate limits |
Two questions drive the design:
What happens when a 5-minute seat hold expires while payment is still in flight?
What happens when 5,000 refunds must go through a provider limited to 50 requests per second, while some purchases are still mid-saga?
| Challenge | Why it is hard |
|---|---|
| Overselling under concurrency | Thousands of buyers compete for the same seats at once |
| Exactly-once effect | At-least-once delivery can deliver the same message twice |
| Unknown outcomes | A payment call times out; success is ambiguous |
| Hold expiry race | The hold expires while payment is in progress |
| TTL lag | DynamoDB TTL deletion can lag by minutes and cannot be trusted for correctness |
| Hot keys | Popular seats create contention on single partitions |
| Traffic spikes | Bursts must be absorbed without losing requests |
| Compensation | Failure after a seat is taken must undo state safely |
| Group atomicity | Holding four seats means four writes that must all succeed or all fail |
| Overlapping groups | Two groups want overlapping seats; one must lose with no partial holds |
| Cancellation race | The event is cancelled while purchases are mid-saga |
| Refund backpressure | The provider throttles; the system must slow down without losing work |
| Double refunds | Retries must never refund the same order twice |
| Unknown refund outcomes | A refund times out; the money may or may not have returned |
Gatehold uses a two-level flow: a cheap concurrency gate, then a durable purchase saga.
POST /events/{eventId}/holds performs a conditional write on one seat or a group of seats:
AVAILABLE → HELD (holdId, owner, expiresAt = now + 5 minutes)
- No order, payment, or saga at this stage
- Cheap enough to absorb a flood of clicks
- The conditional write is the concurrency gate; losers get an immediate conflict
- There is no timer process. Hold validity is
statusandexpiresAt, checked at decision time
Holding seats one by one risks a partial hold (three of four succeed). Gatehold claims a group atomically:
- The client requests
groupSizeseats in a section, or names specific seats (cap default: 8). - The server reads the row (seat IDs are zero-padded and sorted) and finds consecutive free blocks.
- It attempts one block with
TransactWriteItems. Every seat must beAVAILABLE(or have an expired hold), or the transaction is rejected. - On conflict, it re-reads and tries the next candidate block, up to a bounded number of attempts.
- Transaction conflicts retry with jittered backoff.
- If nothing fits, the client receives
409and no seat remains held.
All seats in a group share one holdId, one expiry, and one order. The saga locks, confirms, and releases them as a unit.
Group A wants seats 10-13 Group B wants seats 12-15
│ │
└──────── both run a transaction ┘
│
one commits, the other is cancelled
cleanly. No seat is left half-held.
This path exercises DynamoDB transaction semantics, per-item cancellation reasons, the 2x write cost of transactions, and conflict handling as a normal outcome.
POST /orders stays fast. It:
- Claims the idempotency key (conditional write)
- Verifies the caller owns the hold and it has not expired
- Checks the event is still on sale
- Locks seats
HELD → PAYINGand creates the order asPENDING(one DynamoDB transaction) - Enqueues a message on SQS
- Stores the
202response on the idempotency record and returns202 Accepted
Body includes eventId, holdId, and seatIds (from the hold response). Heavy work runs later in a Step Functions saga (not Phase 4).
hold start payment
AVAILABLE ───────────► HELD ───────────────────────► PAYING
▲ │ │
│ hold expired │ expired (checked at │ confirmed
│ (sweeper/check) │ decision time) ▼
│ ▼ SOLD
└──────────────── AVAILABLE ◄──── payment failed ──┘
(compensation)
PAYING solves the hold-expiry race. While payment runs, the seat stays protected until payUntil, even if the original hold has expired.
| # | Step | Behavior |
|---|---|---|
| 1 | VerifyHold | Confirms ownership, event on sale, and enough time to pay |
| 2 | LockSeatForPayment | HELD → PAYING for all seats in the hold; sets payUntil |
| 3 | AuthorizePayment | Reserves funds (does not capture); idempotent |
| 4 | CheckPaymentStatus | After timeout, queries the provider for the outcome |
| 5 | ConfirmSeat | PAYING → SOLD only if the same holdId still owns the seats |
| 6 | CapturePayment | Captures the authorized amount |
| 7 | IssueTicket | Issues one ticket per seat, signs with KMS, stores in S3 |
| 8 | MarkConfirmed | Sets the order to CONFIRMED |
Compensation paths: VoidAuthorization, RefundPayment, ReleaseSeat, MarkFailed, MarkRefunded.
Authorize first, capture last. If the seat cannot be confirmed, the system voids a reservation. No money moved, so no refund is required.
VerifyHold → LockSeatForPayment → AuthorizePayment → ConfirmSeat
│ unknown │ fail
▼ ▼
CheckPaymentStatus VoidAuthorization
→ ReleaseSeat
→ MarkFailed
ConfirmSeat → CapturePayment → IssueTicket → MarkConfirmed
│ fail
▼
RefundPayment → ReleaseSeat → MarkRefunded
Every step is idempotent, with retries and backoff, a timeout, and a catch that routes to the correct compensation.
When an event is cancelled, Gatehold stops selling, finishes or fails in-flight purchases, and refunds every paid order.
Event lifecycle:
ON_SALE ──► CANCELLING ──► CANCELLED
│
└─ new holds and orders rejected immediately
Flow:
- Admin cancels via
POST /admin/events/{eventId}/cancel. A conditional write movesON_SALE → CANCELLING. New holds and orders are rejected;VerifyHoldfails for work that has not started paying. - The refund orchestrator queries orders by status (GSI), creates a
RefundBatch, and enqueues one refund job per order. - Refund workers run with capped concurrency to respect provider rate limits. On
429, the message returns to the queue with a longer delay. - Each refund is idempotent: key derived from order ID, plus a conditional ledger
REFUNDwrite. - On timeout, the worker queries refund status before retrying.
- Success sets the order to
REFUNDED; DynamoDB Streams triggers the fan notification. - Atomic counters on
RefundBatchtrack progress. When complete, a report is written to S3. - Persistent failures go to a DLQ, raise an alarm, and can be replayed.
- Mid-saga purchases finish or fail normally. The orchestrator sweeps again until no non-terminal orders remain; the reconciler finds confirmed orders in cancelled events without a refund.
- Ticket verification checks event status, so cancelled-event tickets are rejected even with a valid signature.
Admin ─► cancel-event ─► Events table (ON_SALE → CANCELLING)
│
▼
refund-orchestrator
(pages through orders, creates RefundBatch)
│
▼
SQS refund queue ──► DLQ ──► alarm + replay
│
▼
refund-worker (capped concurrency)
│ idempotent per order
▼
Payment provider (rate limited)
│
▼
Ledger REFUND ─► Order REFUNDED ─► Streams ─► email to fan
│
▼
RefundBatch counters ─► complete ─► report in S3
The cancellation path covers backpressure, idempotency at scale, partial failure, and recovery after the happy path breaks.
┌──────────────┐
Fan (browser) ─────► │ CloudFront │ ──► S3 (seat map frontend, optional)
│ └──────────────┘
▼
┌─────────────────┐ JWT ┌──────────┐
│ API Gateway │ ─────► │ Cognito │ (fan users + admin group)
│ (+ throttling) │ └──────────┘
└───────┬─────────┘
│
▼
┌─────────────────┐ ┌───────────────┐
│ Lambda (TS): │ ──► │ DynamoDB │ Events, Seats, Orders, Idempotency,
│ hold, order, │ └───────┬───────┘ Ledger, RefundBatches
│ cancel-event │ │ Streams
└───────┬─────────┘ ▼
│ ┌───────────────┐
▼ │ Lambda (Go): │ ──► EventBridge ──► email, audit,
┌─────────────────┐ │ stream-relay │ analytics
│ SQS + DLQ │ └───────────────┘
└───────┬─────────┘
▼
┌─────────────────┐ start ┌──────────────────────────────┐
│ Lambda: saga │ ──────► │ Step Functions (saga) │
│ starter │ │ + compensation paths │
└─────────────────┘ └──────┬───────────────────────┘
│
┌────────────────────────┼─────────────────────┐
▼ ▼ ▼
Mock payment provider Ticket issuer Notifications
(Go, with chaos config) (S3 + KMS signing) (SNS → SQS → SES)
Cancellation path:
cancel-event → refund-orchestrator → SQS refunds (+DLQ) → refund-worker
→ payment provider
EventBridge Scheduler ──► hold sweeper (Go) + reconciler (Go)
CloudWatch + X-Ray ─────► logs, metrics, alarms, traces
Auditor (Go) ───────────► independent check of all invariants after a run
| Service / Tool | Role | Why |
|---|---|---|
| API Gateway | Public HTTP API | Throttling, validation, and authorizers before Lambda |
| Cognito | Authentication and roles | JWT auth; user ID from token; admin group for cancellation |
| Lambda | Business logic | Scales with bursts; forces explicit concurrency and retry design |
| DynamoDB | Persistent data | Conditional writes and transactions for atomic seat and group claims |
| DynamoDB Streams | Change events | Change and event stay coupled without a separate outbox |
| Step Functions (Standard) | Purchase saga | Durable execution with visible history and compensation |
| SQS + DLQ | Buffering and refund queue | Absorbs spikes, caps concurrency, captures poison messages |
| EventBridge | Domain events | Decouples producers from consumers |
| EventBridge Scheduler | Sweeper and reconciler | Managed scheduling without cron servers |
| SNS + SES | Notifications | Fan-out and email, including refund notices |
| S3 | Tickets and refund reports | Durable storage with presigned downloads |
| KMS | Encryption and signing | Tamper-evident tickets; customer-managed keys |
| Secrets Manager / SSM | Secrets and config | Keys out of code; tunable hold time, group cap, refund rate |
| CloudWatch + X-Ray | Observability | Logs, metrics, alarms, and traces across saga and refunds |
| AWS CDK (TypeScript) | Infrastructure as code | Repeatable environments and reviewable changes |
| TypeScript | Core services | Critical money and seat rules in one typed codebase |
| Go | Tooling and workers | Concurrency-friendly workers, auditor, and load generator |
| MiniStack | Local AWS emulator | Fast local development and automated failure tests |
| Attribute | Notes |
|---|---|
eventId (PK) |
Event identifier |
status |
ON_SALE, CANCELLING, CANCELLED |
cancelledAt, refundBatchId |
Set when cancellation starts |
| Attribute | Notes |
|---|---|
eventId (PK) |
Event identifier |
seatId (SK) |
Zero-padded (e.g. A-12-07) so a row is one range query |
status |
AVAILABLE, HELD, PAYING, SOLD |
holdId, holdOwner |
Current hold; a group shares one holdId |
expiresAt |
Hold deadline; correctness reads this, not TTL |
payUntil |
Payment deadline, set on entering PAYING |
orderId |
Set when sold |
version |
Optimistic locking |
Hold one seat:
UpdateItem
SET status = HELD, holdId = :h, holdOwner = :u, expiresAt = :exp
CONDITION status = AVAILABLE
OR (status = HELD AND expiresAt < :now)
Hold a group (all or nothing):
TransactWriteItems [
Update seat A-12-10 (same SET and CONDITION as above)
Update seat A-12-11
Update seat A-12-12
Update seat A-12-13
]
# If any condition fails, the whole transaction is cancelled
# and the reason for each item is returned.
Confirm a sale (all seats of the order):
TransactWriteItems [
Update each seat:
SET status = SOLD, orderId = :o
CONDITION holdId = :h AND status = PAYING
]
orderId (PK), userId (GSI), eventId + status (GSI for refund orchestration), seatIds, holdId, amount, status (PENDING, CONFIRMED, FAILED, REFUND_PENDING, REFUNDED), executionArn, idempotencyKey, createdAt.
Append-only entries (AUTH, CAPTURE, VOID, REFUND) with a conditional write on the idempotency key so duplicates are rejected.
batchId (PK), eventId, enqueued, succeeded, failed, status (RUNNING, COMPLETE, COMPLETE_WITH_FAILURES), startedAt, finishedAt, optional lastEvaluatedKey / fanOutComplete / lastFanOutAt (orchestrator checkpoint + sweeper), optional reportKey. Counters use atomic ADD.
key (PK), status, stored response, and a ttl for cleanup.
Summaries below. Full records live in docs/adr.
| Decision | Choice | Reason |
|---|---|---|
| Hold expiry | Check expiresAt at decision time; never trust TTL |
TTL deletion can lag by minutes |
| Orchestration | Step Functions over pure choreography | Visible failure paths and execution history |
| Seat modeling | One item per seat, not a counter | Spreads writes; avoids one hot partition |
| Payment protection | PAYING state with payUntil |
Prevents the hold-expiry race |
| Payment flow | Authorize, confirm seat, then capture | Avoids most refunds |
| Event publishing | DynamoDB Streams relay | Change and event cannot drift apart |
| Storage | DynamoDB only | Conditional writes and transactions cover needs without VPC setup |
| Language split | TypeScript core, Go tooling | Critical rules in one language; Go where concurrency helps |
| Group holds | TransactWriteItems with a size cap |
All-or-nothing without a lock manager; accepts 2x write cost |
| Adjacent seats | Server-side search over a sorted row | Client cannot be trusted to pick a valid block |
| Refund fan-out | SQS with capped worker concurrency | Direct backpressure; Distributed Map is a documented alternative |
| Refund safety | Idempotency key per order + conditional ledger write | Duplicates never refund twice |
| Cancellation | Event status checked at hold, order, and saga entry | Single source of truth for selling state |
| Verification | Independent Go auditor | The system does not grade its own homework |
| Scenario | Handling |
|---|---|
| Two buyers take the same seat | Conditional write: one wins, one gets a conflict |
| Client retries the purchase | Idempotency key returns the stored result |
| SQS delivers a message twice | Execution name equals order ID; duplicate start is rejected |
| Payment times out | Query provider status by idempotency key before retry or release |
| Duplicate payment callback | Ledger conditional write rejects the second entry |
| Hold expires during payment | PAYING lock protects the seat until payUntil |
| Hold expires and another buyer takes the seat | ConfirmSeat fails, then void or refund |
| TTL deletes late | Correctness uses expiresAt checks and the sweeper |
| Ticket issuance fails | Retry, then refund and release the seat |
| Lambda crashes mid-step | Step Functions retries the idempotent step |
| Inconsistent data slips through | Scheduled reconciler repairs it |
| Payment provider is down | Retry with backoff, then FAILED |
| Message keeps failing | DLQ, alarm, replay tool |
| Only 3 of 4 group seats are free | Transaction rejected; nothing held; try another block or 409 |
| Two groups want overlapping seats | One commits; the other cancels cleanly |
| Transaction conflict under load | Jittered backoff, bounded attempts, then clear error |
| Group hold expires mid-payment | Whole group stays PAYING until payUntil |
| Event cancelled mid-saga | New steps rejected; captured money refunded by cancel flow or reconciler |
Provider throttles refunds (429) |
Longer queue delay; capped concurrency |
| Refund call times out | Check refund status by idempotency key before retry |
| Duplicate refund message | Idempotency key and conditional ledger write |
| Refund keeps failing | DLQ; batch ends COMPLETE_WITH_FAILURES; alarm; replay |
| Orchestrator crashes halfway | Batch record and idempotent jobs make rerun safe |
| Fan opens a ticket for a cancelled event | Verification checks event status and rejects |
Write endpoints require a Cognito JWT. User ID comes from the token, never the request body. Admin endpoints require the admin group.
| Method | Path | Description |
|---|---|---|
GET |
/events |
List events (public; paginated) |
GET |
/events/{eventId} |
Event name + status (public; seat-map browse) |
GET |
/events/{eventId}/seats |
Seat availability for the map (public; paginated) |
POST |
/events/{eventId}/holds |
Hold seats (seatIds or groupSize). Returns holdId, seatIds, expiresAt, or 409 |
POST |
/orders |
Submit a purchase for a hold. Requires Idempotency-Key. Returns 202 |
GET |
/orders/{orderId} |
Poll order status; when CONFIRMED, short-lived ticket download URLs |
POST |
/tickets/verify |
Simulated gate: { payload, signature } → valid true/false |
POST |
/admin/events/{eventId}/cancel |
Cancel event and start refund batch (admin) |
GET |
/admin/events/{eventId}/refunds |
Refund batch progress (admin) |
Hold a group of four:
POST /events/evt_001/holds
Authorization: Bearer <jwt>
{ "groupSize": 4, "section": "A", "adjacent": true }HTTP/1.1 201 Created
{
"holdId": "h_01HXYZ",
"seatIds": ["A-12-10", "A-12-11", "A-12-12", "A-12-13"],
"expiresAt": "2026-11-01T20:05:00Z"
}Submit the order:
POST /orders
Idempotency-Key: 7b1c9a52-0c3e-4f5e-9a3d-2f1a8d6e4b10
Authorization: Bearer <jwt>
{ "holdId": "h_01HXYZ", "eventId": "evt_001", "seatIds": ["A-12-10", "A-12-11", "A-12-12", "A-12-13"] }HTTP/1.1 202 Accepted
{ "orderId": "ord_01HABC", "status": "PENDING" }Check refund progress:
GET /admin/events/evt_001/refundsHTTP/1.1 200 OK
{
"eventId": "evt_001",
"eventStatus": "CANCELLING",
"batchId": "rb_01HDEF",
"status": "RUNNING",
"enqueued": 3120,
"succeeded": 2840,
"failed": 12,
"fanOutComplete": true,
"startedAt": "2026-11-01T00:00:00.000Z",
"finishedAt": null
}gatehold/
├── infra/ # AWS CDK app (TypeScript)
│ ├── lib/
│ │ ├── gatehold-stack.ts # Thin composer (wires constructs)
│ │ ├── constructs/ # DataPlane, Holds, Orders, Purchase, Http
│ │ └── helpers/ # createNodeFn, saga-task, stack outputs
│ └── bin/
├── services/ # Core services (TypeScript)
│ ├── health/ # Phase 0 smoke / DynamoDB read check
│ ├── hold-seat/ # single and group holds
│ ├── create-order/
│ ├── saga-steps/ # verify, lock, authorize, confirm, capture, issue
│ ├── cancel/ # admin cancel API (ON_SALE → CANCELLING)
│ ├── refund-worker/ # Phase 11d — per-order refund (TS)
│ └── shared/ # DynamoDB helpers, idempotency, types
├── scripts/ # seed + host-side smoke helpers
├── web/ # Fan seat-map UI (Vite + React)
├── go/ # Go components
│ ├── mock-payment/ # configurable provider (latency, errors, duplicates, rate limit)
│ ├── hold-sweeper/
│ ├── refund-orchestrator/ # Phase 11c/11f1 — stream + sweeper → RefundBatch + SQS
│ ├── reconciler/
│ ├── stream-relay/
│ ├── notify-email/
│ ├── loadgen/ # concurrent load generator
│ └── auditor/ # independent invariant checker
├── tests/
│ ├── integration/
│ └── failure/ # failure-injection scenarios
├── docs/
│ ├── adr/ # architecture decision records
│ ├── development-plan.md # learn-while-building implementation order
│ ├── runbook.md
│ └── contracts.md # seat states, conditions, event shapes
└── README.md
- Node.js 20+ and npm
- Go 1.22+
- Docker
- AWS CLI and CDK (
npm install -g aws-cdk) - An AWS account (required for cloud deploy and load tests)
MiniStack is an open-source local AWS emulator for development and failure tests. Step-by-step ops live in docs/runbook.md.
npm install
cp .env.example .env # optional; or: set -a && source .env.example && set +a
npm run ministack:up
npm run deploy:local # cdklocal bootstrap + deploy
npm run seed
npm run get-seat
# Health API (use ApiUrl from stack outputs / .cdk-outputs.json)
curl "$API_URL/health"
curl "$API_URL/health?eventId=evt_001&seatId=A-12-01"
# Fan seat-map UI (paste ApiUrl into Connection after first open)
npm run seed:auth
npm run webReset emulator state between runs with npm run ministack:reset, then redeploy and reseed. See web/README.md for Connection setup.
unset AWS_ENDPOINT_URL
aws configure # or use SSO
cd infra
npx cdk bootstrap
npx cdk deploy --all --context stage=devSet a billing alarm before deploying.
npm test # unit and integration tests
cd go && go test -race ./... # Go tests with the race detector
npm run test:failure # failure-injection scenarioscd go/loadgen
go run . \
--api https://<your-api-url> \
--event evt_001 \
--users 50000 \
--group-share 0.3 \
--concurrency 1000 \
--duration 30scurl -X POST https://<your-api-url>/admin/events/evt_001/cancel \
-H "Authorization: Bearer <admin-jwt>"
curl https://<your-api-url>/admin/events/evt_001/refunds \
-H "Authorization: Bearer <admin-jwt>"
cd go/auditor && go run . --event evt_001cd infra && npx cdk destroy --all| Layer | Coverage |
|---|---|
| Unit | Conditional-write logic, idempotency, state transitions, group block search |
| Integration | Full flow against MiniStack |
| Failure injection | Payment timeouts, duplicate callbacks, mid-saga crashes, hold expiry during payment, overlapping groups, refund throttling |
| Load | Burst of purchase attempts (including groups) against real AWS |
| Cancellation | Cancel at a chosen moment with in-flight orders |
| Audit | Independent Go program checks invariants from raw data |
| Metric | Target |
|---|---|
| Seats oversold | 0 |
| Duplicate charges | 0 |
| Charged without a ticket (after reconciliation) | 0 |
| Partially held or partially sold groups | 0 |
| Burst handled | ~1,000 requests/second for 30 seconds |
| API response time (p99) | under 300 ms |
| Time to final state | under 60 seconds |
| Injected inconsistencies fixed by reconciler | 100% |
| Paid orders refunded after cancellation | 100% |
| Duplicate refunds | 0 |
| Provider refund rate limit exceeded | 0 sustained violations |
| Time to refund ~5,000 orders | under 10 minutes (example target) |
Results will be filled with measured numbers from real AWS runs. Estimates are not published as results.
| Metric | Target | Result |
|---|---|---|
| Seats available | 5,000 | |
| Purchase attempts | ||
| Group requests (share of attempts) | ||
| Seats oversold | 0 | |
| Duplicate charges | 0 | |
| Partially held or sold groups | 0 | |
| Orders confirmed / failed / refunded | ||
| p99 API latency | < 300 ms | |
| Burst sustained | 1,000 rps for 30 s | |
| Time to final state (p99) | < 60 s | |
| Orders refunded after cancellation | 100% | |
| Duplicate refunds | 0 | |
| Time to complete refund batch | ||
| Refunds sent to DLQ | ||
| Cost per 1,000 purchases |
Bottlenecks and fixes will be documented after load testing.
Already in place from earlier phases:
- Lambda / worker logs (stdout → CloudWatch Logs)
- Reconciler EMF metric + alarm (
ReconcilerInconsistencies) - Refund DLQ depth alarm
Phase 13 focus:
- X-Ray across the purchase path (API → SQS → Step Functions → saga Lambdas)
- Trace annotations with
orderIdso one purchase is searchable
Richer dashboards and extra custom metrics/alarms stay possible extensions.
- JWT on every write endpoint; user ID from the token only
- Admin group for cancellation and refund endpoints
- Least-privilege IAM role per function and state machine
- Encryption at rest with KMS for tables, queues, and S3
- Tickets signed with KMS; verification also checks event status
- Secrets in Secrets Manager; configuration in Parameter Store
- Short-lived presigned URLs for ticket downloads
- Rate limiting and throttling at the API layer
- DynamoDB on-demand (transactions cost about twice a normal write)
- Serverless services with low cost at test volumes
- No NAT Gateways or always-on containers
- Billing alarm before any deployment
- Stacks destroyed after load tests
Measured cost per 1,000 purchases is reported in Results.
Implementation order for learning while building lives in docs/development-plan.md. Follow that document phase by phase so dependencies (holds → orders → payment mock → saga → refunds) stay correct.
Summary (details, “done when”, and what not to skip are in the plan):
- Phase 0: Local MiniStack loop, shared types, seed event/seats
- Phase 1: Single-seat hold (conditional write)
- Phase 2: Hold expiry checks + sweeper logic (manual)
- Phase 2b: EventBridge Scheduler → sweeper Lambda
- Phase 3: Group holds (
seatIds1..8 +TransactWriteItems; block search deferred) - Phase 4: Orders, idempotency, SQS (+ DLQ; no consumer yet)
- Phase 5: Mock payment provider (Go)
- Phase 6: Step Functions saga, ledger,
PAYING/ compensation - Phase 7: CDK composite constructs (thin
GateholdStack+ domain constructs) - Phase 8a: Orders stream + stream-relay (log)
- Phase 8b: EventBridge bus + OrderConfirmed
- Phase 8c: SNS → SQS
- Phase 8d: SES email consumer
- Phase 9a: Cognito pool + local users
- Phase 9b: JWT authorizer + identity from claims
- Phase 9c: Admin group + reserved admin routes
- Phase 9d.1: Config construct + StackPort secrets/ssm
- Phase 9d.2: Secrets Manager → payment Lambdas
- Phase 9d.3: SSM hold TTL + seat cap
- Phase 9d.4: Least-privilege IAM + permission map
- Phase 10a: TicketStore (S3 + KMS) + contracts / helpers
- Phase 10b: IssueTicket KMS sign + S3 artifacts
- Phase 10c: GET /orders/{orderId} + presigned ticket URLs
- Phase 10d: POST /tickets/verify (KMS Verify + event status)
- Phase 11: Event cancellation, refund orchestrator/workers, batch tracking
- Phase 12: Reconciler (detect-only: CONFIRMED without SOLD → CloudWatch; slices 12a–12e)
- Phase 13: X-Ray tracing on the purchase path (orderId-searchable; slices 13a–13d)
- Phase 14: WebSocket notify buyer when order is
CONFIRMED/FAILED
Possible extensions:
- Waiting room and bot defenses
- Live seat map over WebSockets (broadcast availability; Phase 14 is order-done only)
- Seat map frontend on CloudFront and S3
- Independent auditor CLI / loadgen + README results table
- CI/CD and dev/prod stages
- CloudWatch dashboard + richer custom metrics/alarms (beyond Phase 12 + DLQ)
- Postgres ledger for a relational comparison
- Purchase analytics with Kinesis Firehose, S3, and Athena
- Partial cancellation (refund selected ticket types only)
- Learning and portfolio project, not production software
- Payment provider and ticket scanning are simulated
- Local runs use an emulator; performance numbers come only from real AWS
- No real payment processing, PCI compliance, or fraud detection
- Group booking assumes simple row-based adjacency (no accessibility or venue-geometry rules)
MIT. See LICENSE.