Uber Simulation Project

This project simulates the core functionalities of a ride-sharing platform, including modules for driver, customer, billing, ride management, and administration. The backend is built with Django, and the frontend uses React.js. The application is designed to handle operations such as ride booking, driver registration, and billing.


Table of Contents

  1. Features
  2. Technology Stack
  3. Setup Instructions
  4. Docker Setup
  5. Kubernetes Deployment
  6. Minikube Setup
  7. Testing
  8. Contributing

Features

  • Customer Management: Customer registration, login, and profile updates.
  • Driver Management: Driver registration, login, profile updates, and ride management.
  • Ride Booking: Real-time ride booking, ride status updates, and notifications.
  • Billing: Automatic fare calculation and billing generation.
  • Websocket Notifications: Real-time ride updates for drivers and customers.
  • Redis Caching: Improves system performance and handles session storage.

Technology Stack

  • Backend: Django, Django REST Framework
  • Frontend: React.js
  • Database: MySQL
  • Caching: Redis
  • Containerization: Docker
  • Orchestration: Kubernetes
  • Testing: Postman, JMeter

Setup Instructions

Prerequisites

  1. Install Docker.
  2. Install Kubernetes CLI (kubectl).
  3. Install Minikube.
  4. Install Python 3.9+.
  5. Install Node.js and npm.
  6. Clone this repository:
    git clone https://github.com/your-repo/uber-simulation.git
    cd uber-simulation

Backend Setup

cd backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py runserver

Frontend Setup

cd frontend
npm install
npm start

Docker Setup

Build Docker Images

  1. Build the backend image:
    cd backend
    docker build -t uber-backend .
  2. Build the frontend image:
    cd frontend
    docker build -t uber-frontend .

Run Docker Containers

  1. Start the MySQL and Redis containers:
    docker run --name mysql-container -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=uber_db -p 3306:3306 -d mysql:latest
    docker run --name redis-container -p 6379:6379 -d redis:latest
  2. Run the backend container:
    docker run --name backend-container --link mysql-container --link redis-container -p 8000:8000 uber-backend
  3. Run the frontend container:
    docker run --name frontend-container -p 3000:3000 uber-frontend

Kubernetes Deployment

Prerequisites

  • Ensure kubectl is configured.
  • Ensure a Kubernetes cluster is running.

Create Kubernetes Manifests

  1. Create a namespace:
    kubectl create namespace uber
  2. Apply MySQL and Redis manifests:
    kubectl apply -f k8s/mysql-pv.yaml
    kubectl apply -f k8s/redis-deployment.yaml
  3. Apply backend and frontend deployments:
    kubectl apply -f k8s/backend-deployment.yaml
    kubectl apply -f k8s/frontend-deployment.yaml

Verify Deployment

kubectl get pods -n uber
kubectl get services -n uber

Minikube Setup

Start Minikube

minikube start

Deploy Application

  1. Use Minikube to deploy the application:
    kubectl apply -f k8s/mysql-pv.yaml
    kubectl apply -f k8s/redis-deployment.yaml
    kubectl apply -f k8s/backend-deployment.yaml
    kubectl apply -f k8s/frontend-deployment.yaml
  2. Expose services using Minikube:
    minikube service backend-service -n uber
    minikube service frontend-service -n uber

Testing

  1. Use Postman for testing API endpoints.
  2. Use JMeter for load testing (e.g., simulate 100 users booking rides simultaneously).

Contributing

Feel free to contribute by creating issues or submitting pull requests. For major changes, please discuss with the project maintainers first.


License

This project is licensed under the MIT License. See the LICENSE file for more details.