Case study
EventFlow
An event-driven order processing platform on AWS serverless. Four services that never call each other, an order that moves through them one event at a time, and a stack that deploys with one command.
Why I built it
At AWS I spent a lot of time helping partner teams design event-driven systems on EventBridge, Lambda and Step Functions. I wanted a project where I owned every decision end to end, wrote down why I made it, and lived with the consequences, the way I would on a real team. So I ran it like one: tickets, feature branches, pull requests into a develop branch, and an architecture decision record for every choice that mattered.
How an order moves

An order.placed event lands on a custom EventBridge bus. The order service validates it and publishes order.validated. Inventory reserves stock and publishes stock.reserved, or stock.insufficient if it can’t. Payment charges the order and publishes payment.charged, and the order service marks it confirmed. Failures route back the same way: a stock.insufficient or payment.failed event cancels the order and notifies the customer. Every hop is an EventBridge rule delivering to that service’s own SQS queue, with its own Lambda consumer and dead-letter queue.
Decisions that shaped it
EventBridge over SNS
EventBridge routes on the content of an event, so one rule matching detail-type "payment.failed" sends that event exactly where it needs to go. With SNS I would have needed a topic per event type, more than ten of them, and the routing would have lived in topic names instead of in one readable rule. EventBridge also gave me an event archive for replay.
SQS between EventBridge and every Lambda
EventBridge can invoke Lambda directly, but then a failed event has nowhere to go. Putting a queue in front of each consumer gives every service its own retries, its own visibility timeout, and a dead-letter queue after three failed attempts. In an order system, a failed payment event has to be captured and investigated, not dropped.
A typed event envelope on every message
Every event is a Pydantic v2 model with the same envelope: event_id, event_type, version, timestamp and correlation_id. Only the event that starts a chain (OrderPlaced) can create a correlation_id. Every downstream event has to receive one explicitly, so the tracing chain is enforced by the type system instead of by convention.
Carry context forward on events
Partway through building the inventory service I found that OrderValidated didn’t carry the order items, so inventory couldn’t reserve stock without looking something up. Instead of letting inventory listen to OrderPlaced (which would reserve stock for orders that fail validation), I added the items to OrderValidated and wrote it up as an addendum to the ADR. That became the project’s convention: events carry what the next consumer needs.
CDK in TypeScript
I picked CDK over Terraform and raw CloudFormation for this one. The grant methods (grantPutEventsTo, grantReadWriteData) generate least-privilege IAM for me, which removes a whole class of misconfiguration. cdk synth runs in CI on every pull request, so broken infrastructure fails review the same way broken Python does.
How I build and ship it
I wrote the service layer first against an in-memory event bus, so the business logic was fully testable before any AWS existed. Then I lifted it onto Lambda one service at a time. Every pull request into develop runs ruff, mypy, pytest with an 80% coverage gate, and cdk synth. Merging to main deploys the whole stack through GitHub Actions. After a deploy, a smoke test publishes a real order to the live bus and polls DynamoDB until the order, inventory and payment records all appear.
For operations there’s a CloudWatch dashboard with invocations, errors, duration and queue depth for every service, an alarm on every dead-letter queue and every handler, and two composite alarms that roll them up, so one alert tells you something is wrong anywhere in the pipeline.
What’s not done yet
I’d rather list these myself than have you find them:
- Some state still lives in Lambda memory. Inventory checks a seeded dictionary and the payment service tracks pending charges in a module variable, so both reset on a cold start. The fix is reading stock from DynamoDB with a conditional update.
- Nothing is idempotent yet. SQS delivers at least once, so a redelivered message can write twice. The plan is a conditional put keyed on event_id.
- The deployed order handler updates status but doesn’t emit order.confirmed or order.cancelled yet. The rules and the notification consumer are ready; the handler isn’t.
- Payment is a stub that always succeeds, so the payment.failed path is wired and tested in the service layer but never fires in AWS. Credentials come from Secrets Manager; there’s no real processor behind them yet.
Stack
Python 3.12 · Pydantic v2 · boto3 · uv · ruff · mypy · pytest · AWS CDK (TypeScript) · EventBridge · SQS · Lambda · DynamoDB · Secrets Manager · CloudWatch · GitHub Actions