This project implements a microservices-based e-commerce system with a React frontend.
-
Order Service (backend-order)
- Manages customer orders
- Handles product catalog
- User authentication and authorization
-
Payment Service (backend-payment)
- Processes payments for orders
- React-based web application
- Provides user interface for interacting with the backend services
backend-order/
: Order service implementationbackend-payment/
: Payment service implementationfrontend/
: React-based frontend applicationinfra/
: Terraform configuration for AWS infrastructure
- Backend: Go, Gin framework, MongoDB
- Frontend: React, TypeScript
- Infrastructure: AWS (ECS, ECR, ALB, DocumentDB, S3, CloudFront)
- API Documentation: Swagger
- IaC: Terraform
-
Order Service:
cd backend-order cp .env.example .env go run main.go
The service will run on
http://localhost:8080
-
Payment Service:
cd backend-payment cp .env.example .env go run main.go
The service will run on
http://localhost:8081
-
Install dependencies:
cd frontend cp .env.local .env npm install
-
Start the development server:
npm start
The frontend will be available at
http://localhost:3000
- Order Service Swagger UI:
http://localhost:8080/swagger/index.html
- Payment Service Swagger UI:
http://localhost:8081/swagger/index.html
The project is deployed on AWS using Terraform. The infrastructure includes:
- ECS Fargate for running backend services
- ECR for Docker image storage
- Application Load Balancers for backend services
- DocumentDB for database
- S3 and CloudFront for frontend hosting
To deploy the infrastructure:
- Navigate to the
infra
directory - Initialize Terraform:
terraform init
- Apply the Terraform configuration:
terraform apply
- Navigate to the
backend-order
directory - Run the deployment script
cd backend-order ./deploy.sh
- Navigate to the
frontend
directory - Run the deployment script
cd frontend npm run deploy:prod
Both backend services use environment variables for configuration. Ensure these are set in your local .env
files and in the AWS ECS task definitions.
Key variables include:
MONGODB_URI
MONGODB_DATABASE
PORT
API_URL
API_PAYMENT_URL
(for Order Service)API_ORDER_URL
(for Payment Service)MAILTRAP_API_TOKEN
(for Order Service)
The backend services use AWS Cloud Map for service discovery, allowing them to communicate using internal DNS names within the VPC.
- HTTPS is enforced for all public endpoints
- MongoDB connections use TLS
- IAM roles are used for ECS task execution
CloudWatch is used for monitoring and logging of ECS tasks and other AWS resources.