The Better Store: domain-driven design and microservices on AWS serverless
An introduction to The Better Store, an open-source demo ecommerce store showing domain-driven design, microservice patterns and AWS serverless services, the article series I wrote about building it, and how I have since used it to explore AI on AWS.
Before Cirruscape, I wrote a series of articles on dev.to about building The Better Store: an open-source ecommerce system I created to show how domain-driven design (DDD), microservice patterns and AWS serverless services fit together in a realistic application. This post brings those articles together in one place, with a short guide to what each one covers.
What is The Better Store?
The Better Store is a sample online store with a single-page web app. Visitors browse a product catalogue, then sign up or sign in, add products to a cart, and check out (with test payments only). Behind that simple experience is a set of independently deployable services, each owning its own data and communicating through events.
It was built to answer a question I kept running into: microservices promise scalability, resilience and the ability to change quickly, but how do you decide where one service ends and the next begins, and how do you keep them consistent without a shared database? The Better Store is my worked answer, from event storming the domain right through to running it on AWS.
The code is on GitHub at github.com/thebetterstore, with documentation at docs.thebetterstore.net.
The articles
Part 1: Introduction to Microservice Architecture
Sets the scene. What microservice architecture is, why it suits cloud-native systems, and the hard problems it brings: choosing service boundaries, avoiding shared databases, and rolling back work that spans services. It makes the case for DDD as the way to design service boundaries, and introduces The Better Store and its technology choices: TypeScript on Node.js, API Gateway and Lambda, InversifyJS and the Onion Architecture.
Part 2: Defining DDD Strategic Patterns
Discovering the domain before writing code. This part walks through Event Storming (run remotely with Miro), capturing behaviour as BDD Given/When/Then feature files, and CRC cards. It then separates core, supporting and generic subdomains, defines bounded contexts and their ubiquitous language, and builds a context map using integration patterns such as Customer-Supplier, Anti-Corruption Layer and Open-Host Service, to avoid ending up with a “big ball of mud”. The store’s feature files are published with its documentation.
Part 3: DDD Tactical Patterns and App Architecture
From strategy to code. Using the Order bounded context, this part covers DDD’s tactical building blocks (entities, value objects, aggregates, repositories, factories, services and domain events) and then shows how to structure a service with the Onion Architecture and inversion of control, so the domain model stays free of infrastructure concerns and dependencies can be swapped (a real payments client in production, a mock in tests). The scaffolding is in tbs-app-order.
Part 4: Implementing a Microservices Architecture with Cloud Native Patterns and AWS Services
Putting it on AWS. Following the “order purchased” scenario end to end, this part applies patterns from Chris Richardson’s microservices.io:
- decomposition by subdomain, with each service in its own CloudFormation stack,
- database per service: DynamoDB for orders, Aurora Serverless v2 for reports,
- sagas with compensating transactions,
- asynchronous messaging with SQS, SNS, EventBridge and DynamoDB Streams,
- idempotent consumers and dead-letter queues,
- Stripe payment webhooks received through API Gateway straight into SQS, and
- observability with CloudWatch metrics, logs, dashboards and alarms, plus X-Ray and OpenTelemetry tracing.
Beyond the series: The Better Store meets AI
Since the series, The Better Store has become my test bed for AI on AWS. A real, distributed application makes a much better proving ground than a toy example.
AI-based incident analysis with AWS DevOps Agent
What happens when a bad deployment breaks production, and an AI agent is on call? I deliberately
shipped a bug to the Order service (renaming the DynamoDB key it writes to) through the store’s
GitHub Actions and CodeDeploy blue/green pipeline. The CreateOrder Lambda function’s error alarm
fired, and a small Lambda function forwarded the alarm to AWS DevOps Agent to open an
investigation.
In under four minutes, at an estimated cost of about US$2, the agent traced the failures to the
errant commit and the DynamoDB ValidationException, recommended a rollback, and flagged follow-up
risks I hadn’t asked about, including a possible gap in reconciling Stripe payments.
Adding a GenAI chatbot with Strands Agents
The first in a new series, this adds a chat window to the store that answers questions about product inventory and reviews. Questions go through API Gateway to a Python Lambda function that calls Anthropic’s Claude through the Amazon Bedrock Converse API, with tools to look up the store’s own Products API and external book and review sources.
The article builds the agentic loop twice: first by hand, with tool timeouts, an iteration cap
and parallel tool calls, so you can see exactly how an agent works; then with the open-source
Strands Agents SDK, which replaces most of that code. Both
versions are in the
tbs-app-chat repository, on the
feature/tools-python and feature/tools-strands branches.
What’s next
Next up for the chatbot is rehosting it on Amazon Bedrock AgentCore, which I’ll write about here on Cirruscape.
If you’re exploring DDD or event-driven architecture on AWS, the source code is a good place to dig in. I’d love to hear what you build with it.
← All posts