Low-Level Design (LLD) for AWS Architecture: Cosmetics E-Commerce Platform
MiniMax-A1 Design Document
1. System Overview
Objective: Design a scalable, secure, and highly available AWS architecture for a global cosmetics e-commerce platform.
Key Requirements:
- High-traffic frontend with product catalog, search, and recommendations.
- Secure user accounts, order processing, and payment integration.
- Multi-region deployment for low-latency access.
- Compliance with GDPR and PCI-DSS.
2. Architecture Diagram (Text Representation)
[Users]
│
▼
[CloudFront CDN] → [S3 Static Hosting (Frontend)]
│
├─API Requests→ [Application Load Balancer (ALB)] → [EC2 Auto Scaling Group (Backend)]
│ │
│ ├─[RDS PostgreSQL (Primary + Read Replicas)]
│ ├─[ElastiCache Redis (Session/Product Data)]
│ └─[SQS (Order Queue)] → [Lambda (Order Processor)]
│
├─[S3 Media Bucket (Product Images)]
└─[DynamoDB (User Clicks/Analytics)]
3. Component Details
3.1 Web Tier (Frontend)
Service: Amazon S3 + CloudFront
- S3 Bucket:
cosmetics-frontend-assets
- Static files (HTML/CSS/JS, React/Angular bundles).
- Bucket Policy: Restrict access to CloudFront via OAI (Origin Access Identity).
- Versioning: Enabled for rollback.
- CloudFront Distribution:
- Origin: S3 bucket (configured as website endpoint).
- Cache Policy:
CachingOptimized with 1-day TTL for static assets.
- SSL: ACM certificate for
*.cosmetics.com.
- Geo-Restriction: Block regions as needed.
3.2 Application Tier (Backend)
Service: EC2 + ALB + Auto Scaling
- EC2 Configuration:
- Instance Type:
t3.large (2 vCPUs, 8 GB RAM).
- AMI: Amazon Linux 2 with Docker (containerized Node.js/Python backend).
- Security Group: Allow HTTP/HTTPS only from ALB.
- Placement: Private subnets across 2 AZs.
- Auto Scaling Group:
- Min: 4 instances, Max: 20 (scales on CPU >60%).
- Load Balancer: ALB with HTTPS listener (redirect to HTTP).
- Containerization: Docker images stored in ECR.
3.3 Database Tier
Service: Amazon RDS (PostgreSQL)
- Instance Class:
db.m5.xlarge (4 vCPUs, 16 GB RAM).
- Storage: 1 TB gp3 (provisioned IOPS).
- Multi-AZ: Enabled (standby in secondary AZ).
- Backup: Automated daily snapshots (retention: 30 days).
- Encryption: AES-256 at rest, SSL for data in transit.
- Read Replicas: 2 replicas in different AZs for read-heavy workloads.
3.4 Caching
Service: Amazon ElastiCache (Redis)
- Cluster Mode: Enabled (2 shards, 3 nodes per shard).
- Node Type:
cache.m5.large.
- Use Case:
- Session storage (sticky sessions via ALB).
- Product catalog caching (TTL: 1 hour).
3.5 Media Storage
Service: Amazon S3
- Bucket:
cosmetics-media-bucket
- Product images, videos, user-generated content.
- Lifecycle Policy: Transition to Glacier after 90 days.
- Encryption: SSE-S3.
- Access:
- CloudFront signed URLs for private content.
3.6 Serverless Components
Service: AWS Lambda
- Order Processor:
- Triggered by SQS messages (order details).
- Integrates with payment gateway (Stripe/PayPal).
- Timeout: 30 seconds, Memory: 512 MB.
- Image Thumbnail Generator:
- Triggered on S3 upload (product images).
3.7 Analytics
Service: Amazon DynamoDB
- Table:
user_behavior
- Attributes:
user_id, product_viewed, timestamp.
- Capacity: On-Demand mode.
4. Security
4.1 Network Security
- VPC:
- 2 public subnets (NAT Gateway), 2 private subnets (EC2, RDS).
- NACLs: Restrict inbound to HTTP/HTTPS on public subnets.
- Security Groups:
- ALB: Allow 443/80 from 0.0.0.0/0.
- EC2: Allow traffic only from ALB.
- RDS: Allow traffic only from EC2 security group.
4.2 IAM
- Roles:
- EC2: Role for accessing S3 (read product data).
- Lambda: Role with RDS write and SQS read permissions.
- Policies: Least privilege (e.g., S3 access limited to specific buckets).
4.3 Data Protection
- SSL/TLS: Enforced via ACM on CloudFront and ALB.
- Secrets: RDS credentials stored in AWS Secrets Manager.
- PCI Compliance:
- RDS encryption, CloudTrail logging for audit.
5. Scalability & High Availability
- Multi-AZ: RDS, ElastiCache, and EC2 across 2+ AZs.
- Global Accelerator: Optional for reducing latency in EU/Asia.
- S3 Cross-Region Replication: For media bucket redundancy.
6. Backup & Disaster Recovery
- RDS: Automated snapshots + point-in-time recovery.
- S3: Versioning + cross-region replication.
- Recovery Time Objective (RTO): <1 hour.
- Recovery Point Objective (RPO): <5 minutes.
7. CI/CD Pipeline
- CodePipeline:
- Source: GitHub repo (frontend/backend code).
- Build: CodeBuild (Docker image build + ECR push).
- Deploy: CodeDeploy to EC2 instances (rolling update).
- Testing:
- Staging environment in
us-east-2 (mirrors production).
8. Monitoring & Logging
- CloudWatch:
- Alarms for CPU, memory, HTTP 5xx errors.
- Dashboard: Track request count, latency, RDS connections.
- CloudTrail: Audit API calls for security compliance.
9. Cost Optimization
- Spot Instances: For non-critical batch jobs (e.g., image processing).
- S3 Intelligent-Tiering: For media storage.
- Reserved Instances: For steady-state EC2/RDS usage.
Approval
[ ] Architect: _________________
[ ] DevOps Lead: _________________
Document Version: 1.0 | Last Updated: February 2025
This LLD provides actionable configurations for a resilient, secure, and scalable AWS architecture tailored to a cosmetics e-commerce platform.