Skip to content

Latest commit

 

History

73 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Airbnb Clone — Distributed Booking Platform

A distributed Airbnb-style booking platform built for a Distributed Systems course project, covering containerization, event-driven architecture, polyglot persistence, state management, and load testing.

Co-built with Savitha Vijayarangan — both contributors worked across the full stack. Commit history below reflects collaborative development on Kafka integration, MongoDB sessions, Redux state management, Docker/Kubernetes deployment, and JMeter performance testing.


Quick Start

Option 1: Docker Compose (Recommended)

docker-compose up -d
docker-compose ps
docker-compose logs -f backend

Access Points:

Service URL
Frontend http://localhost:3000
Backend API http://localhost:4000
Backend Health http://localhost:4000/health
API Docs http://localhost:4000/api/docs
Kafka UI http://localhost:8080
MongoDB localhost:27017
MySQL localhost:3306

Option 2: Kubernetes (Production-Ready)

kubectl apply -f k8s/
kubectl get all -n airbnb
kubectl wait --for=condition=ready pod --all -n airbnb --timeout=300s

kubectl port-forward service/frontend-service 3000:80 -n airbnb &
kubectl port-forward service/backend-service 4000:4000 -n airbnb &

Option 3: Kafka Only

docker-compose -f docker-compose.kafka.yml up -d
cd backend && npm start

Architecture

┌─────────────────────────────────────────────────────────┐
│                  Kubernetes Cluster                      │
│                                                           │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌─────────┐  │
│  │ Frontend │  │ Backend  │  │  MySQL   │  │ MongoDB │  │
│  │  (2-5)   │  │  (2-5)   │  │   (1)    │  │  (1)    │  │
│  └────┬─────┘  └────┬─────┘  └────┬─────┘  └────┬────┘  │
│       │             │             │             │       │
│       └─────────────┴─────────────┴─────────────┘       │
│                     │                                    │
│       ┌─────────────┴──────────────┐                     │
│       │                            │                     │
│  ┌────┴─────┐              ┌───────┴────┐                │
│  │Zookeeper │              │   Kafka    │                │
│  │   (1)    │              │    (1)     │                │
│  └──────────┘              └────────────┘                │
└─────────────────────────────────────────────────────────┘
         │                          │
         ▼                          ▼
   LoadBalancer              Kafka Producer/Consumer

Part 1: Docker & Kubernetes

  • All services containerized (Backend, Frontend, MySQL, MongoDB, Kafka, Zookeeper)
  • Production-ready Dockerfiles with multi-stage builds
  • Complete docker-compose.yml with 7 services
  • 8 Kubernetes deployments with proper configurations
  • Horizontal Pod Autoscaler (2–5 replicas, CPU/Memory based)
  • Persistent Volumes for databases
  • Health checks and resource limits
  • Service discovery and networking

Key files: backend/Dockerfile, frontend/Dockerfile, docker-compose.yml, k8s/*.yaml (8 configs)


Part 2: Kafka Integration

  • Kafka producer for booking events
  • Two Kafka consumers (Owner & Traveler services)
  • Topics: booking-request, booking-status-update
  • Asynchronous message flow:
    • Traveler creates booking → Kafka → Owner receives
    • Owner accepts/cancels → Kafka → Traveler receives
  • Graceful error handling
  • Kafka UI for monitoring

Key files: backend/config/kafka.js, backend/kafka/consumers.js, backend/controllers/bookingController.js

Test it:

docker-compose up -d kafka zookeeper
curl -X POST http://localhost:4000/api/bookings/request \
  -H "Content-Type: application/json" \
  -d '{"propertyId":1,"startDate":"2025-12-01","endDate":"2025-12-05","guests":2}'
# Check http://localhost:8080 for the message

Part 3: MongoDB

  • MongoDB 7.0 for session storage
  • Sessions persist in MongoDB, not in memory
  • Password encryption with bcrypt (salt rounds: 10)
  • Hybrid database architecture:
    • MySQL — application data (users, properties, bookings)
    • MongoDB — session storage
  • Deployed in both Docker and Kubernetes

Key files: backend/server.js, k8s/07-mongodb-deployment.yaml

Test it:

docker exec -it airbnb-mongodb mongosh
use airbnb_sessions
db.sessions.find().pretty()

Part 4: Redux State Management

  • Redux Toolkit (@reduxjs/toolkit@^2.9.0)
  • React-Redux (react-redux@^9.2.0)
  • Redux Persist for state persistence
  • 4 Redux slices:
Slice Purpose
travelerSlice Traveler authentication & profile
OwnerSlice Owner authentication & profile
propertySlice Property search, fetch, details
bookingSlice Booking creation, status, favorites
  • Async thunks for API calls, with loading and error states

Key files: frontend/src/app/store.js, frontend/src/features/{traveler,owner,property,booking}/*Slice.js


Part 5: JMeter Performance Testing

  • 3 comprehensive test plans (.jmx)
  • Tests at 100, 200, 300, 400, 500 concurrent users
  • Automated test execution script
  • Metrics collected: response times (avg, median, percentiles), throughput, error rates
  • HTML reports with graphs, CSV data for analysis

Key files: jmeter/test-plans/01-authentication-test.jmx, 02-property-search-test.jmx, 03-booking-process-test.jmx, jmeter/run-all-tests.sh

curl http://localhost:4000/health
cd jmeter && ./run-all-tests.sh
open results/authentication-100-users-report/index.html

Tech Stack

Layer Technology
Frontend React + Redux Toolkit + Redux Persist
Backend Node.js / Express
Relational DB MySQL 8.0 (users, properties, bookings)
Document DB MongoDB 7.0 (session storage)
Message queue Apache Kafka + Zookeeper
Session security bcrypt (10 salt rounds)
Containerization Docker, Docker Compose
Orchestration Kubernetes — Deployments, HPA (2–5 replicas), PVCs
Load testing Apache JMeter

Project Structure

Lab1_DistributedSystem/
├── backend/                    # Node.js Backend
│   ├── config/
│   │   ├── kafka.js             # Kafka configuration
│   │   └── database.js
│   ├── kafka/
│   │   └── consumers.js         # Kafka consumers
│   ├── controllers/             # Kafka producers
│   ├── Dockerfile
│   └── server.js                # MongoDB sessions
│
├── frontend/                   # React Frontend
│   ├── src/
│   │   ├── app/
│   │   │   └── store.js         # Redux store
│   │   └── features/            # Redux slices
│   └── Dockerfile
│
├── k8s/                        # Kubernetes configs (8 files)
│   ├── 00-namespace.yaml
│   ├── 01-configmap.yaml
│   ├── 02-secrets.yaml
│   ├── 03-mysql-deployment.yaml
│   ├── 04-kafka-deployment.yaml
│   ├── 05-backend-deployment.yaml
│   ├── 06-frontend-deployment.yaml
│   └── 07-mongodb-deployment.yaml
│
├── jmeter/                     # Performance testing
│   ├── test-plans/              # 3 JMeter test plans
│   ├── run-all-tests.sh
│   └── results/
│
├── docker-compose.yml
├── docker-compose.kafka.yml
│
└── Documentation
    ├── DOCKER_KUBERNETES_SETUP.md
    ├── KAFKA_SETUP.md
    ├── JMETER_SETUP.md
    └── LAB2_FINAL_STATUS.md

Configuration

# MySQL
DB_HOST=mysql
DB_USER=airbnb_user
DB_PASSWORD=password123
DB_NAME=airbnb_db

# MongoDB
MONGO_USER=admin
MONGO_PASSWORD=mongopassword
MONGO_DB=airbnb_sessions

# Kafka
KAFKA_BROKER=kafka:9093

# Session
SESSION_SECRET=your-secret-key-change-in-production

Troubleshooting

Backend won't start:

lsof -ti:4000
lsof -ti:3306
lsof -ti:27017
docker-compose logs backend

Kafka issues:

docker-compose restart zookeeper kafka
docker-compose logs kafka

Database connection failed:

docker exec -it airbnb-mysql mysql -u root -p
docker exec -it airbnb-mongodb mongosh

Related

Co-authors: Savitha Vijayarangan, Jane Heng

About

Distributed Airbnb booking platform: React + Redux frontend, Node.js backend, Kafka event-driven booking flow, MongoDB session storage, Kubernetes with HPA (2-5 replicas), JMeter load tested up to 500 concurrent users

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages