This is a Serverless Event-driven E-commerce project for TypeScript development with CDK.
- What's Included In This Repository
- Project Architecture
- Microservices Overview
- Prerequisites
- Run The Project
- Useful Commands
- Troubleshooting
- Author
This repository follows the reference architecture above, implementing a real-world Serverless E-commerce application with:
- 🌐 REST API and CRUD endpoints using AWS Lambda, API Gateway
- 📊 Data persistence using AWS DynamoDB
- 🔁 Decoupled microservices with events through Amazon EventBridge
- 📬 Message Queues for cross-service communication using AWS SQS
- 🏗️ Cloud stack development with IaC via AWS CloudFormation and AWS CDK
This project follows a serverless, event-driven architecture. Here’s a breakdown of the components:
- API Gateway: Exposes RESTful endpoints for users to interact with.
- AWS Lambda: Executes business logic for each microservice.
- DynamoDB: Stores product, basket, and order information in a scalable way.
- EventBridge: Manages event routing between microservices to ensure loose coupling.
- SQS: Acts as a message buffer to handle high-throughput, cross-service communication.
- Products Service: Manages product listings, including adding, updating, and retrieving products.
- Baskets Service: Handles user baskets, allowing items to be added or removed.
- Orders Service: Manages order creation and tracking, consuming events from other services.
You will need the following tools:
- 🪪 AWS Account and User
- 🖥️ AWS CLI
- 📦 NodeJS
- 🛠️ AWS CDK Toolkit
- 🐳 Docker
Follow these steps to get your development environment set up:
- Set up the AWS CLI by running the following command:
aws configure-
Clone the repository
-
In the root directory containing the cdk.json file, run the following command:
cdk deploy
⚠️ Note: Make sure that Docker is running before executing thecdk deploycommand.
-
Wait for all microservices to be provisioned into AWS cloud. That’s it! 🎉
-
You can launch microservices using the URLs below:
- Products API ->
https://xxx.execute-api.ap-southeast-1.amazonaws.com/{stage}/products - Baskets API ->
https://xxx.execute-api.ap-southeast-1.amazonaws.com/{stage}/baskets - Orders API ->
https://xxx.execute-api.ap-southeast-1.amazonaws.com/{stage}/orders
- Copy the Postman collection from the /postman folder for testing.
npm run build- Compile TypeScript to JavaScriptnpm run watch- Watch for changes and recompilecdk synth- Emit the synthesized CloudFormation templatecdk diff- Compare deployed stack with current statecdk deploy- Deploy this stack to your default AWS account/regioncdk destroy- Delete the deployed stack from your AWS accountcdk bootstrap- Prepare your AWS environment for deployment with CDK (required for first-time setup)
- Permissions Errors: Make sure your AWS user has sufficient permissions for Lambda, API Gateway, EventBridge, and DynamoDB.
- Docker Not Running: Ensure Docker is running before deploying, as some Lambda dependencies might need Docker.
- CDK Bootstrap Error: If CDK commands fail, try running
cdk bootstrapto set up the environment.
- Grisha Hovhanyan - github:grishahovhanyan