Skip to content

nimshafernando/AWS-CloudRetail-Project

Repository files navigation

πŸ›’ CloudRetail - Enterprise E-Commerce Platform

CloudRetail Logo AWS Vue.js Node.js License

A production-ready, scalable microservices-based e-commerce platform deployed on AWS

Features β€’ Architecture β€’ Tech Stack β€’ Getting Started β€’ API Docs β€’ Deployment


πŸ“‹ Table of Contents


🌟 Overview

CloudRetail is a full-stack, cloud-native e-commerce platform built with modern microservices architecture. Designed for scalability, reliability, and security, it demonstrates enterprise-level cloud deployment practices using AWS services.

This project showcases:

  • βœ… Microservices Architecture - Independent, scalable services
  • βœ… Event-Driven Design - Asynchronous communication using AWS EventBridge
  • βœ… Saga Pattern - Distributed transaction management
  • βœ… Cloud-Native Deployment - Containerized services on AWS ECS
  • βœ… Production-Ready - Complete CI/CD, monitoring, and security

✨ Features

πŸ›οΈ Customer Features

  • πŸ” User Authentication - JWT-based auth with Amazon Cognito
  • πŸ“¦ Product Catalog - Browse products with advanced search and filtering
  • πŸ›’ Shopping Cart - Real-time cart management
  • πŸ’³ Multiple Payment Methods - Credit Card, PayPal, Bank Transfer
  • πŸ“§ Order Notifications - Email updates via Amazon SES
  • πŸ‘€ User Profile - Manage account details and order history
  • ⭐ Product Reviews - Rate and review products

πŸ‘¨β€πŸ’Ό Admin Features

  • πŸ“Š Analytics Dashboard - Real-time sales and inventory metrics
  • πŸ“¦ Inventory Management - Low stock alerts and automatic notifications
  • 🏷️ Product Management - CRUD operations for products
  • πŸ“ˆ Order Management - Track and update order statuses
  • πŸ‘₯ User Management - Customer accounts administration

πŸ”§ Technical Features

  • πŸ”„ Event-Driven Architecture - EventBridge for service communication
  • πŸ” Saga Orchestration - Reliable distributed transactions
  • 🐳 Containerization - Docker containers on AWS ECS
  • πŸ—„οΈ Database Persistence - MySQL on Amazon RDS
  • 🌐 CDN Distribution - Amazon CloudFront for static assets
  • πŸ”’ Security - WAF protection, encryption at rest/transit
  • πŸ“Š Monitoring - CloudWatch metrics and alarms
  • πŸ’Ύ Automated Backups - AWS Backup for data protection

πŸ—οΈ Architecture

System Architecture Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         USER LAYER                               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚   Browser    │──────────────────────────│  Mobile App  β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚                                         β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚ HTTPS
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Amazon CloudFront  β”‚ ← CDN
                    β”‚    + AWS WAF        β”‚ ← Security
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   AWS API Gateway   β”‚ ← API Management
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    MICROSERVICES LAYER (ECS)                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚
β”‚  β”‚     User     β”‚  β”‚   Product    β”‚  β”‚    Order     β”‚          β”‚
β”‚  β”‚   Service    β”‚  β”‚   Service    β”‚  β”‚   Service    β”‚          β”‚
β”‚  β”‚  (Port 3001) β”‚  β”‚  (Port 3003) β”‚  β”‚  (Port 3002) β”‚          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚
β”‚         β”‚                  β”‚                  β”‚                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”          β”‚
β”‚  β”‚   Payment    β”‚  β”‚  Inventory   β”‚  β”‚   Customer   β”‚          β”‚
β”‚  β”‚   Service    β”‚  β”‚   Service    β”‚  β”‚   Products   β”‚          β”‚
β”‚  β”‚  (Port 3005) β”‚  β”‚  (Port 3004) β”‚  β”‚   Service    β”‚          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚
β”‚         β”‚                  β”‚                  β”‚                  β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚
β”‚                            β”‚                                     β”‚
β”‚                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”                           β”‚
β”‚                   β”‚  Saga           β”‚                           β”‚
β”‚                   β”‚  Orchestrator   β”‚                           β”‚
β”‚                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                           β”‚
└────────────────────────────┴──────────────────────────────────┐
                             β”‚                                    β”‚
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”                         β”‚
                   β”‚  Amazon EventBridgeβ”‚ ← Event Bus            β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                         β”‚
                             β”‚                                    β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”‚
              β”‚              β”‚              β”‚                    β”‚
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”             β”‚
     β”‚  AWS Lambda    β”‚ β”‚  Lambda  β”‚ β”‚  Lambda   β”‚             β”‚
     β”‚  Order Event   β”‚ β”‚ Welcome  β”‚ β”‚ Payment   β”‚             β”‚
     β”‚  Handler       β”‚ β”‚  Email   β”‚ β”‚Confirmationβ”‚             β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜             β”‚
              β”‚             β”‚              β”‚                    β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β”‚
                            β”‚                                    β”‚
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”                          β”‚
                   β”‚  Amazon SES     β”‚ ← Email Service          β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β”‚
                                                                 β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚                     DATA LAYER                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚
β”‚  β”‚   Amazon RDS     │◄────────│  AWS Backup      β”‚            β”‚
β”‚  β”‚   (MySQL 8.0)    β”‚         β”‚  (Daily Backups) β”‚            β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚
β”‚  β”‚   Amazon S3      β”‚         β”‚  Amazon ECR      β”‚            β”‚
β”‚  β”‚  (Images/Assets) β”‚         β”‚ (Docker Images)  β”‚            β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Design Patterns

  • 🎯 Microservices Pattern - Independent, loosely coupled services
  • πŸ”„ Event-Driven Architecture - Asynchronous messaging via EventBridge
  • 🎭 Saga Pattern - Distributed transaction coordination
  • πŸ”Œ API Gateway Pattern - Centralized API management
  • πŸͺ CQRS Lite - Separation of concerns in data operations
  • πŸ’Ύ Database per Service - Each service manages its own data

πŸš€ Tech Stack

Frontend

Vue.js JavaScript Axios Vuex

  • Framework: Vue.js 3.x
  • State Management: Vuex
  • HTTP Client: Axios
  • Routing: Vue Router
  • UI Components: Custom + Bootstrap

Backend

Node.js Express MySQL JWT

  • Runtime: Node.js (v18.x)
  • Framework: Express.js
  • Database: MySQL 8.0
  • Authentication: JWT + bcrypt
  • ORM: Raw SQL with connection pooling
  • API Specs: OpenAPI 3.0 (Swagger)

DevOps & Infrastructure

Docker AWS GitHub

  • Containerization: Docker
  • Cloud Platform: AWS
  • Version Control: Git/GitHub
  • Scripts: PowerShell, Bash

☁️ AWS Services Used

Service Purpose Configuration
Amazon ECS Container orchestration for microservices EC2 launch type, 7 services
Amazon EC2 Compute instances for ECS tasks t3.small instance
Amazon RDS Managed MySQL database db.t3.micro, Multi-AZ ready
AWS Lambda Serverless event handlers 7 functions (Node.js 18.x)
Amazon EventBridge Event bus for service communication Custom event patterns
Amazon API Gateway REST API management Regional endpoint
Amazon CloudFront CDN for frontend assets Global edge locations
Amazon S3 Static asset storage 2 buckets with versioning
Amazon ECR Docker image registry 14 repositories
AWS WAF Web application firewall CloudFront protection
Amazon Cognito User authentication User pool with JWT
Amazon SES Email notifications Verified domains
Amazon CloudWatch Monitoring and logging Custom metrics, alarms
AWS Backup Automated database backups Daily backups, 7-day retention
AWS IAM Identity and access management Least privilege policies
AWS KMS Encryption key management Data encryption at rest

πŸ“ Project Structure

CloudRetail/
β”œβ”€β”€ πŸ“‚ frontend/                    # Vue.js Frontend Application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/            # Reusable Vue components
β”‚   β”‚   β”œβ”€β”€ views/                 # Page components
β”‚   β”‚   β”œβ”€β”€ router/                # Vue Router configuration
β”‚   β”‚   β”œβ”€β”€ store/                 # Vuex state management
β”‚   β”‚   β”œβ”€β”€ services/              # API service layer
β”‚   β”‚   └── App.vue                # Root component
β”‚   β”œβ”€β”€ public/                    # Static assets
β”‚   β”œβ”€β”€ package.json
β”‚   └── Dockerfile
β”‚
β”œβ”€β”€ πŸ“‚ backend/                     # Microservices Backend
β”‚   β”œβ”€β”€ api-gateway/               # API Gateway Service (Port 3000)
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   β”‚   β”œβ”€β”€ package.json
β”‚   β”‚   └── Dockerfile
β”‚   β”‚
β”‚   β”œβ”€β”€ user-service/              # User Management (Port 3001)
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── Dockerfile
β”‚   β”‚
β”‚   β”œβ”€β”€ product-service/           # Product Catalog (Port 3003)
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── Dockerfile
β”‚   β”‚
β”‚   β”œβ”€β”€ order-service/             # Order Processing (Port 3002)
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── Dockerfile
β”‚   β”‚
β”‚   β”œβ”€β”€ payment-service/           # Payment Processing (Port 3005)
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   β”‚   └── Dockerfile
β”‚   β”‚
β”‚   β”œβ”€β”€ inventory-service/         # Inventory Management (Port 3004)
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   β”‚   └── Dockerfile
β”‚   β”‚
β”‚   β”œβ”€β”€ customer-products-service/ # Seller Products (Port 3006)
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   β”‚   └── Dockerfile
β”‚   β”‚
β”‚   β”œβ”€β”€ saga-orchestrator/         # Distributed Transaction Coordinator
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   β”‚   └── Dockerfile
β”‚   β”‚
β”‚   β”œβ”€β”€ database/                  # Database Scripts
β”‚   β”‚   β”œβ”€β”€ schema.sql
β”‚   β”‚   β”œβ”€β”€ init.sql
β”‚   β”‚   └── migrations/
β”‚   β”‚
β”‚   └── eventbridge-simulator.js  # Local EventBridge testing
β”‚
β”œβ”€β”€ πŸ“‚ lambda-functions/            # AWS Lambda Functions
β”‚   β”œβ”€β”€ order-notification/
β”‚   β”œβ”€β”€ welcome-email/
β”‚   β”œβ”€β”€ payment-confirmation/
β”‚   β”œβ”€β”€ low-inventory-alert/
β”‚   β”œβ”€β”€ order-status-update/
β”‚   └── product-notification/
β”‚
β”œβ”€β”€ πŸ“‚ infrastructure/              # Infrastructure as Code
β”‚   β”œβ”€β”€ cloudformation/            # CloudFormation templates
β”‚   β”œβ”€β”€ terraform/                 # Terraform configurations (optional)
β”‚   └── diagrams/                  # Architecture diagrams
β”‚
β”œβ”€β”€ πŸ“‚ ecs-tasks/                   # ECS Task Definitions
β”‚   β”œβ”€β”€ user-service.json
β”‚   β”œβ”€β”€ product-service.json
β”‚   β”œβ”€β”€ order-service.json
β”‚   └── ... (other services)
β”‚
β”œβ”€β”€ πŸ“‚ deployment-scripts/          # Deployment Automation
β”‚   β”œβ”€β”€ deploy-to-aws.ps1
β”‚   β”œβ”€β”€ setup-ecs.ps1
β”‚   β”œβ”€β”€ setup-rds.ps1
β”‚   β”œβ”€β”€ deploy-lambda.ps1
β”‚   └── stop-all-aws.ps1
β”‚
β”œβ”€β”€ πŸ“‚ configs/                     # Configuration Files
β”‚   β”œβ”€β”€ CloudRetail-API.postman_collection.json
β”‚   β”œβ”€β”€ cloudwatch-dashboard.json
β”‚   β”œβ”€β”€ waf-config.json
β”‚   └── grafana-dashboard-k6.json
β”‚
β”œβ”€β”€ πŸ“‚ scripts/                     # Utility Scripts
β”‚   β”œβ”€β”€ populate-db.js
β”‚   β”œβ”€β”€ backup-db.sh
β”‚   └── health-check.ps1
β”‚
β”œβ”€β”€ πŸ“‚ testing-showcase/            # Testing & Load Tests
β”‚   β”œβ”€β”€ k6/                        # Load testing scripts
β”‚   └── integration/               # Integration tests
β”‚
β”œβ”€β”€ πŸ“„ docker-compose.yml           # Local development setup
β”œβ”€β”€ πŸ“„ swagger.yaml                 # API documentation (OpenAPI 3.0)
β”œβ”€β”€ πŸ“„ package.json                 # Root package configuration
β”œβ”€β”€ πŸ“„ README.md                    # This file
└── πŸ“„ .gitignore

πŸš€ Getting Started

Prerequisites

  • Node.js v18.x or higher
  • Docker & Docker Compose
  • MySQL 8.0 (or use Docker)
  • AWS Account (for cloud deployment)
  • AWS CLI configured

Local Development Setup

1️⃣ Clone the Repository

git clone https://github.com/yourusername/CloudRetail.git
cd CloudRetail

2️⃣ Install Dependencies

# Install root dependencies
npm install

# Install backend dependencies
cd backend/user-service && npm install
cd ../product-service && npm install
cd ../order-service && npm install
# ... repeat for other services

# Install frontend dependencies
cd ../../frontend
npm install

3️⃣ Set Up Environment Variables

Create .env files in each service directory:

# backend/user-service/.env
PORT=3001
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=cloudretail
JWT_SECRET=your_jwt_secret_key
AWS_REGION=us-east-1
EVENTBRIDGE_BUS_NAME=cloudretail-events

4️⃣ Set Up Database

# Start MySQL using Docker
docker-compose up -d mysql

# Import database schema
mysql -u root -p cloudretail < backend/database/schema.sql

# Populate with sample data (optional)
node scripts/populate-db.js

5️⃣ Start All Services (Local)

Option A: Using Docker Compose

docker-compose up --build

Option B: Manual Start

# Terminal 1 - User Service
cd backend/user-service
npm start

# Terminal 2 - Product Service
cd backend/product-service
npm start

# Terminal 3 - Order Service
cd backend/order-service
npm start

# Terminal 4 - Payment Service
cd backend/payment-service
npm start

# Terminal 5 - Inventory Service
cd backend/inventory-service
npm start

# Terminal 6 - API Gateway
cd backend/api-gateway
npm start

# Terminal 7 - Frontend
cd frontend
npm run serve

6️⃣ Access the Application


🌩️ Deployment

Deploy to AWS

Prerequisites

  • AWS CLI configured with appropriate credentials
  • Docker installed for building images
  • PowerShell (for Windows) or Bash (for Linux/Mac)

Automated Deployment

# 1. Build and push Docker images to ECR
.\deployment-scripts\build-and-push-ecr.ps1

# 2. Set up RDS database
.\deployment-scripts\setup-rds.ps1

# 3. Deploy ECS services
.\deployment-scripts\setup-ecs.ps1

# 4. Deploy Lambda functions
.\deployment-scripts\deploy-lambda.ps1

# 5. Configure API Gateway
.\deployment-scripts\setup-api-gateway.ps1

# 6. Deploy frontend to S3 + CloudFront
.\deployment-scripts\deploy-frontend.ps1

Manual Deployment Steps

1. Create ECR Repositories

aws ecr create-repository --repository-name cloudretail/user-service
aws ecr create-repository --repository-name cloudretail/product-service
# ... create for all services

2. Build and Push Docker Images

# Login to ECR
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <account-id>.dkr.ecr.us-east-1.amazonaws.com

# Build and push each service
cd backend/user-service
docker build -t cloudretail/user-service .
docker tag cloudretail/user-service:latest <account-id>.dkr.ecr.us-east-1.amazonaws.com/cloudretail/user-service:latest
docker push <account-id>.dkr.ecr.us-east-1.amazonaws.com/cloudretail/user-service:latest

3. Create ECS Cluster

aws ecs create-cluster --cluster-name cloudretail-cluster

4. Register Task Definitions

aws ecs register-task-definition --cli-input-json file://ecs-tasks/user-service.json
aws ecs register-task-definition --cli-input-json file://ecs-tasks/product-service.json
# ... register all task definitions

5. Create ECS Services

aws ecs create-service \
  --cluster cloudretail-cluster \
  --service-name user-service \
  --task-definition user-service:1 \
  --desired-count 1 \
  --launch-type EC2

6. Deploy Lambda Functions

cd lambda-functions/order-notification
zip -r function.zip .
aws lambda create-function \
  --function-name order-notification \
  --runtime nodejs18.x \
  --role arn:aws:iam::<account>:role/lambda-role \
  --handler index.handler \
  --zip-file fileb://function.zip

πŸ“š API Documentation

Interactive API Docs

Access Swagger UI at: http://localhost:3000/api-docs (local) or your API Gateway URL

Base URL

Production: https://aygfmjsp82.execute-api.us-east-1.amazonaws.com/prod
Local: http://localhost:3000

Authentication

Most endpoints require JWT authentication. Include the token in the Authorization header:

Authorization: Bearer <your-jwt-token>

Key Endpoints

Authentication

POST   /users/register          # Register new user
POST   /users/login             # Login
GET    /users/profile           # Get user profile (Auth required)
PUT    /users/profile           # Update profile (Auth required)

Products

GET    /products                # List all products
GET    /products/:id            # Get product details
POST   /products                # Create product (Admin)
PUT    /products/:id            # Update product (Admin)
DELETE /products/:id            # Delete product (Admin)
GET    /products/search?q=      # Search products

Orders

POST   /orders                  # Create new order (Auth required)
GET    /orders                  # Get user orders (Auth required)
GET    /orders/:id              # Get order details (Auth required)
PUT    /orders/:id/status       # Update order status (Admin)
POST   /orders/:id/cancel       # Cancel order (Auth required)

Payments

POST   /payments                # Process payment (Auth required)
GET    /payments/:id            # Get payment details (Auth required)
POST   /payments/:id/refund     # Refund payment (Admin)

Inventory

GET    /inventory/:productId    # Check stock availability
PUT    /inventory/:productId    # Update stock (Admin)
POST   /inventory/alerts        # Configure low-stock alerts (Admin)

Response Format

Success Response:

{
  "success": true,
  "data": {
    // ... response data
  }
}

Error Response:

{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error message"
  }
}

πŸ”’ Security

Authentication & Authorization

  • πŸ” JWT Tokens - Stateless authentication
  • πŸ‘€ Amazon Cognito - User pool management
  • πŸ”‘ bcrypt - Password hashing (10 salt rounds)
  • 🎫 Role-Based Access Control (RBAC) - Admin vs. Customer roles

Data Security

  • πŸ”’ Encryption at Rest - AWS KMS for RDS encryption
  • πŸ” Encryption in Transit - TLS/SSL everywhere
  • πŸ›‘οΈ AWS WAF - Protection against common web exploits
  • πŸ” Input Validation - SQL injection prevention
  • 🚫 CORS Configuration - Controlled cross-origin requests

Network Security

  • πŸ” VPC Isolation - Private subnets for backend services
  • πŸ”’ Security Groups - Strict firewall rules
  • πŸ›‘οΈ WAF Rules - Rate limiting, IP filtering
  • πŸ” Secrets Management - AWS Secrets Manager

Best Practices Implemented

  • βœ… Principle of least privilege (IAM policies)
  • βœ… Regular security updates
  • βœ… Database connection pooling with limits
  • βœ… Request rate limiting
  • βœ… SQL injection prevention (parameterized queries)
  • βœ… XSS protection
  • βœ… CSRF tokens for state-changing operations

πŸ“Š Monitoring & Logging

Amazon CloudWatch

  • Metrics Collected:

    • API Gateway request count, latency, 4XX/5XX errors
    • ECS CPU/Memory utilization per service
    • RDS connections, CPU, storage
    • Lambda invocations, errors, duration
  • CloudWatch Alarms:

    • High API error rate (>5% 5XX errors)
    • High API latency (>3 seconds)
    • High ECS CPU (>80%)
    • Lambda errors
    • Low RDS storage

Logging

  • Service Logs: CloudWatch Logs for all ECS services
  • Lambda Logs: Automatic CloudWatch Logs integration
  • API Gateway Logs: Access logs and execution logs
  • Structured Logging: JSON format for easy parsing

Health Checks

# Check all services health
curl http://localhost:3000/health

# Individual service health
curl http://localhost:3001/health  # User Service
curl http://localhost:3002/health  # Order Service
curl http://localhost:3003/health  # Product Service

πŸ§ͺ Testing

Load Testing with K6

cd testing-showcase/k6
k6 run load-test.js

Integration Tests

npm test

Postman Collection

Import the collections from /configs directory:

  • CloudRetail-API.postman_collection.json - API testing
  • CloudRetail-Complete-Workflow.postman_collection.json - End-to-end flows

πŸ“ˆ Performance

Benchmarks

  • API Response Time: < 200ms average
  • Database Queries: < 50ms average
  • Order Processing: < 2 seconds end-to-end
  • Concurrent Users: Tested up to 1000 simultaneous users
  • Throughput: 500+ requests/second

Optimization Techniques

  • Database connection pooling
  • Redis caching (ready for implementation)
  • CDN for static assets (CloudFront)
  • Horizontal scaling with ECS
  • Async event processing with EventBridge
  • Database indexes on frequently queried columns

πŸ› οΈ Troubleshooting

Common Issues

1. Services can't connect to database

# Check RDS security group allows ECS security group
# Verify connection string in environment variables
# Test connectivity from EC2 instance

2. ECS services stuck in "PENDING"

# Check ECS task logs
aws ecs describe-tasks --cluster cloudretail-cluster --tasks <task-id>

# Common causes: Docker image pull failures, port conflicts

3. Lambda function timeouts

# Increase timeout in function configuration
# Check CloudWatch Logs for errors
# Verify VPC configuration if using VPC

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Code Style

  • Use ESLint configuration (.eslintrc.js)
  • Follow JavaScript Standard Style
  • Write meaningful commit messages
  • Add tests for new features

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘¨β€πŸ’» Author

Nimsha Fernando


πŸ™ Acknowledgments

  • AWS Documentation and Best Practices
  • Node.js and Express.js communities
  • Vue.js ecosystem
  • Open source contributors

πŸ“ž Support

For support and questions:


⭐ Star this repository if you find it helpful!

Made with ❀️ by [Nimsha Fernando]

AWS Status Version

About

πŸ›’ Enterprise-grade e-commerce platform built with Vue.js and Node.js microservices. Features event-driven architecture, AWS cloud deployment (ECS, RDS, Lambda, EventBridge), Saga pattern for distributed transactions, and production-ready monitoring with CloudWatch.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors