Thiết kế kiến trúc

VinaShoes E-commerce Platform

VinaShoes là một hệ thống thương mại điện tử bán giày được xây dựng dựa trên kiến trúc microservices trên AWS Cloud. Dự án sử dụng Next.js cho frontend và NestJS cho backend, được thiết kế để đảm bảo tính mở rộng, độ tin cậy và bảo mật cao.

Kiến trúc AWS Cloud

Kiến trúc tổng thể của VinaShoes E-commerce trên AWS Cloud
Kiến trúc tổng thể của VinaShoes E-commerce trên AWS Cloud

Tổng quan kiến trúc

Hệ thống được thiết kế với 3 accounts chính để đảm bảo security và separation of concerns:

Production Account

  • Frontend: Next.js hosted trên AWS Amplify với CloudFront CDN
  • API Gateway: HTTP API routing requests tới các microservices
  • ECS Fargate: Container platform chạy các microservices
  • Network Load Balancer: Internal traffic distribution
  • RDS PostgreSQL: Main database với Multi-AZ deployment
  • ElastiCache Redis: Session management và caching
  • S3 + CloudFront: Static assets delivery
  • VPC Security: Private subnets, Security Groups, WAF

Security Account

  • CloudTrail: Centralized audit logging
  • AWS Config: Compliance monitoring và rules
  • Cross-Account IAM: Secure access management
  • Backup & DR: Disaster recovery strategies
  • GuardDuty + Security Hub: Threat detection

CI/CD Account

  • CodeCommit: Source code repositories
  • CodeBuild: Automated builds và testing
  • CodePipeline: Blue/Green deployment automation
  • ECR: Docker container registry
  • S3: Build artifacts storage

Multi-AZ Design Benefits:

  • High Availability: Automatic failover giữa AZs
  • Load Distribution: Traffic được phân bổ đều
  • Disaster Recovery: RDS Multi-AZ với automatic backup
  • Performance: Reduced latency với regional deployment

Công nghệ sử dụng

Frontend Stack

  • Framework: Next.js 14 với TypeScript
  • Styling: Tailwind CSS cho responsive design
  • State Management: Zustand cho client state
  • Hosting: AWS Amplify với automatic builds
  • CDN: CloudFront với global edge locations

Backend Stack

  • Framework: NestJS với TypeScript
  • Database ORM: Prisma cho type-safe database access
  • Caching: Redis cho session và frequently accessed data
  • Container: Docker containers trên ECS Fargate
  • API Design: RESTful APIs với OpenAPI documentation

Infrastructure Stack

  • Cloud Provider: AWS với multi-region capability
  • Compute: ECS Fargate cho serverless containers
  • Database: RDS PostgreSQL với read replicas
  • Networking: VPC với public/private subnet separation
  • Monitoring: CloudWatch với custom metrics và alarms

Kiến trúc Microservices

Core Business Services

User Service

  • Authentication với NextAuth.js
  • User profile management
  • Role-based access control (RBAC)

Product Service

  • Product catalog với advanced search
  • Category và brand management
  • Inventory integration

Cart Service

  • Shopping cart với Redis persistence
  • Real-time updates với WebSocket
  • Session management

Order Service

  • Order processing workflow
  • Payment integration với Stripe/VNPay
  • Status tracking và notifications

Notification Service

  • Email notifications với SES
  • Push notifications cho mobile
  • SMS integration với SNS

Service Communication

API Gateway Pattern

  • Centralized routing và authentication
  • Rate limiting và throttling
  • Request/response transformation

Service-to-Service Communication

  • HTTP REST APIs cho synchronous calls
  • Event-driven architecture với SQS/SNS
  • Database per service pattern

Data Management

  • PostgreSQL cho transactional data
  • Redis cho caching và sessions
  • S3 cho file storage và static assets

Kiến trúc này được thiết kế để support high-traffic e-commerce workload với khả năng scale từ startup đến enterprise level.