Skip to content

vissharm/ecommerce-app

Repository files navigation

E-Commerce Microservices Application

This is created for assignment and learning purpose [Scalable services - WILP , BITS PILANI]

FEATURE/SUBMODULES - This branch should be referred for evaluation. master is initial started approach with monolyth and then broken into microservices and containerization code under feature branch. Feature branch is final work achieving all objectives of assignment.

FOR COURSE STUDENTS: CAUTION: REPO IS MADE PUBLIC FOR EVALUATION, SO DO NOT COPY, ALREADY SUBMITTED AND SENT TO PROFESSOR. FEEL FREE TO LEARN FROM IT AND APPLY CONCEPTS. ALWAYS APPRECIATE KNOWLEDGE SHARING.

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB (v4.4 or higher)
  • Apache Kafka (v2.13-2.6.0 or higher)
  • Apache ZooKeeper (v3.4.6 or higher)
  • Windows Terminal (for running services)

Initial Setup

  1. Install Dependencies and Setup Database

    # Install dependencies and run database setup
    npm install
    npm run setup

    This will:

    • Install all required dependencies
    • Create necessary database schemas
    • Initialize default data including:
  2. Setup Kafka and ZooKeeper

    Option 1 - Using Docker:

    # Start Kafka and ZooKeeper using Docker Compose
    docker-compose up -d

    Option 2 - Manual Setup:

    • Download and extract Apache ZooKeeper:

      • Place in C:\apache-zookeeper-3.7.2-bin
      • Configure zoo.cfg in the conf directory
    • Download and extract Apache Kafka:

      • Place in C:\kafka_2.13-3.6.1
      • Configure server.properties in the config directory

Running the Application

Start All Services

Run the provided batch script to start all services in separate terminal windows:

start-services.bat

This script will start the following services in order:

  1. ZooKeeper (Port: 2181)
  2. Kafka (Port: 9092)
  3. Order Service (Port: 3002)
  4. Product Service (Port: 3004)
  5. User Service (Port: 3001)
  6. Notification Service (Port: 3003)
  7. Frontend Application
  8. API Gateway

Service URLs

Microservices Architecture

┌─────────────┐     ┌─────────────┐
│   Frontend  │ ←── │ API Gateway │
└─────────────┘     └─────────────┘
                          ↓
┌────────────────────────────────────────┐
│              Kafka Bus                 │
└────────────────────────────────────────┘
     ↓            ↓           ↓          ↓
┌─────────┐  ┌─────────┐ ┌─────────┐ ┌─────────┐
│  User   │  │  Order  │ │ Product │ │ Notif.  │
│ Service │  │ Service │ │ Service │ │ Service │
└─────────┘  └─────────┘ └─────────┘ └─────────┘
     ↓            ↓           ↓          ↓
┌────────────────────────────────────────┐
│              MongoDB                   │
└────────────────────────────────────────┘

Default Data

Troubleshooting

  1. Kafka Connection Issues

    • Ensure ZooKeeper is running before starting Kafka
    • Verify Kafka broker is running on localhost:9092
    • Check Kafka logs for connection errors
  2. MongoDB Connection Issues

    • Verify MongoDB is running on localhost:27017
    • Check if the service can connect to its respective database
  3. Service Start-up Issues

    • Ensure all required ports are available
    • Check if all dependencies are installed correctly
    • Verify environment variables in .env files

Additional Commands

# Stop Docker containers (if using Docker)
docker-compose down

# View Docker container logs
docker-compose logs -f

# Restart individual services
cd backend/<service-name>
npm run start

# Clean installation
npm run clean  # Removes node_modules and package-lock.json
npm install    # Fresh installation

Application screenshots

image image image image image image image image image image image image image image image image image image image

About

scalable services course assignment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published