Skip to content

Repository files navigation

Shoptiq

NestJS Kubernetes Terraform AWS License: MIT

A microservices e-commerce project built with NestJS, RabbitMQ, PostgreSQL, and Next.js, deployed on AWS using Terraform and Kubernetes.

Features

  • Microservices Architecture: API Gateway routing requests to auth-service, prod-service, cart-service, and order-service.
  • Event-Driven Messaging: Inter-service RPC communication via RabbitMQ message broker.
  • Authentication: JWT Access/Refresh tokens with bcrypt password hashing.
  • Payments: Razorpay order creation and HMAC SHA256 signature verification.
  • Infrastructure as Code: Terraform scripts to provision VPC subnets, EC2 nodes, RDS PostgreSQL, and S3.
  • Kubernetes Deployment: Declarative Kustomize manifests running on a 3-node kubeadm cluster with Flannel CNI.

Quick Start

Prerequisites

  • Node.js 20+
  • Docker and Docker Compose
  • PostgreSQL 15+ & RabbitMQ 3.x (if running without Docker)
  • Terraform 1.5+ (optional, for AWS infrastructure)

Local Setup

# 1. Clone repository
git clone https://github.com/Kusagra9308/Shoptiq.git
cd Shoptiq

# 2. Start PostgreSQL and RabbitMQ containers
docker-compose up -d

# 3. Install dependencies & push database schema
cd backend
npm install
npx prisma@5.22.0 db push --schema=./libs/database/prisma/schema.prisma

# 4. Start backend services
npm run start:all

Configuration

Create a .env file inside backend/:

DATABASE_URL="postgresql://postgres:shoptiq_password_123@localhost:5432/shoptiq"
RABBITMQ_URL="amqp://localhost:5672"
JWT_SECRET="your_jwt_access_secret"
RAZORPAY_ID_KEY="your_razorpay_id"
RAZORPAY_SECRET_KEY="your_razorpay_secret"

Architecture

flowchart TD
    Client([Client / Frontend]) -->|HTTP / REST| Gateway[API Gateway: Port 3000]
    Gateway -->|JWT Auth Guards| AuthCheck{Authorized?}
    AuthCheck -->|Yes| RabbitMQ[(RabbitMQ Event Broker)]
    
    RabbitMQ -->|RPC| AuthService[Auth Service]
    RabbitMQ -->|RPC| ProdService[Product Service]
    RabbitMQ -->|RPC| CartService[Cart Service]
    RabbitMQ -->|RPC| OrderService[Order Service]

    AuthService --> DB[(AWS RDS PostgreSQL)]
    ProdService --> DB
    CartService --> DB
    OrderService --> DB
    OrderService --> Razorpay[Razorpay API]
Loading

Usage

# Register User
curl -X POST http://localhost:3000/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"Password123!","mobileno":"9999999999","name":"John Doe"}'

# Browse Catalog
curl http://localhost:3000/products?page=1&limit=10

# Add to Cart
curl -X POST http://localhost:3000/cart \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{"productId":"prod-1","quantity":1}'
// Sample Response: POST /cart
{
  "id": "cart-item-123",
  "userId": "user-456",
  "productId": "prod-1",
  "quantity": 1,
  "createdAt": "2026-08-02T10:00:00.000Z"
}

Performance & Load Testing

Load tested on AWS (1 Master + 2 Worker EC2 t3.medium instances with RDS db.t3.micro) using Grafana k6:

  • Peak Load: Tested up to 500 concurrent Virtual Users (VUs).
  • Success Rate: 100% request success rate across 18,500+ iterations on read/cart paths.
  • Median Latency: 779 ms median HTTP response time under load.

Limitations & Roadmap

  • Add Redis caching layer for catalog queries.
  • Add Stripe and PayPal payment integrations alongside Razorpay.
  • Add Prometheus and Grafana container monitoring dashboards.

Contributing

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

License

Distributed under the MIT License.

About

High-performance microservices e-commerce platform built with NestJS, RabbitMQ, PostgreSQL (Prisma), Terraform IaC, and Kubernetes (kubeadm) benchmarked to 500 VUs on AWS.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages