Skip to content

Thanos-png/food-delivery-system

Repository files navigation

Food Delivery System

Overview

The Food Delivery System is a comprehensive distributed application designed to facilitate online food ordering and delivery. It features a MapReduce-based backend architecture with multiple deployment options, including Docker containers and local services. The system allows managers to manage stores and products, while customers can browse stores, filter products, and place orders.

Project Structure

The project is organized into several modules:

  • backend: Contains the server-side implementation, including Master, Worker, and Reducer components with MapReduce framework
  • manager-console: A console application for managers to manage stores and generate reports
  • android-client: An Android application that serves as the user interface for customers
  • common: Contains protocol definitions for communication between clients and servers
  • dummy-client: A simple client application for testing purposes
  • docker: Contains all Docker-related files for containerized deployment
  • sample-data: Contains sample store data and images for testing the application

Architecture

The system uses a distributed MapReduce architecture:

  • Master Server (port 8080): Coordinates operations and manages worker/reducer nodes
  • Worker Nodes (ports 8090-8092): Process data and handle client requests
  • Reducer Nodes (ports 8095-8096): Aggregate results from worker nodes

Features

Manager Features

  • Add and manage stores
  • Add, remove, and update products
  • View total sales by product and store category
  • Console-based interface for management operations

Customer Features

  • Browse stores within a 5 km radius
  • Filter stores by food category, ratings, and price range
  • Place orders for selected products
  • Rate stores based on customer experience

Quick Start

Prerequisites

  • Java 11 or later
  • Maven 3.6+
  • tmux (for session management)
  • Docker & Docker Compose (for Docker deployment mode)

Using the Automated Setup Script

The project includes a comprehensive setup script that supports both Docker and local deployment modes:

# Docker deployment (recommended)
./start-distributed.sh docker setup

# Local deployment
./start-distributed.sh local setup

This will:

  1. Check all prerequisites
  2. Build all modules (if changed)
  3. Start all services
  4. Create a tmux session with organized windows for services and clients

Deployment Modes

Docker Mode (Recommended)

Runs all services in Docker containers with proper networking:

# Setup and start all services
./start-distributed.sh docker setup

# Check status
./start-distributed.sh docker status

# View logs
./start-distributed.sh docker logs

# Stop services
./start-distributed.sh docker stop

# Clean up everything
./start-distributed.sh docker clean

Local Mode

Runs services directly on the host machine:

# Setup and start all services
./start-distributed.sh local setup

# Check status
./start-distributed.sh local status

# Stop services
./start-distributed.sh local stop

Available Commands

Command Description
setup Build projects (if changed), start services, and attach to tmux session
rebuild-setup Force rebuild all projects, start services, and attach to tmux session
start Start existing services (no tmux session created automatically)
stop Stop services (and kill tmux session if running)
restart Restart services
clean Stop and remove services/containers (and kill tmux session)
status Show status of services
logs [service] Show logs from a specific service or all
shell [service] Open shell in a specific container (Docker mode only)
test Run a quick connectivity test
monitor Monitor resource usage

Manual Setup (Alternative)

If you prefer manual setup:

1. Build the Project

# Build all modules
mvn clean install -f common/pom.xml
mvn clean install -f backend/pom.xml
mvn clean install -f manager-console/pom.xml
mvn clean install -f dummy-client/pom.xml

# Copy dependencies for backend
mvn dependency:copy-dependencies -DoutputDirectory=backend/target/dependency -f backend/pom.xml

2. Start Services Manually

For Docker:

cd docker
docker-compose up -d

For Local:

# Terminal 1 - Master Server
java -cp backend/target/backend-1.0-SNAPSHOT.jar:backend/target/dependency/*:common/target/common-1.0-SNAPSHOT.jar master.MasterServer

# Terminal 2-4 - Worker Servers
java -cp backend/target/backend-1.0-SNAPSHOT.jar:backend/target/dependency/*:common/target/common-1.0-SNAPSHOT.jar worker.WorkerServer 0
java -cp backend/target/backend-1.0-SNAPSHOT.jar:backend/target/dependency/*:common/target/common-1.0-SNAPSHOT.jar worker.WorkerServer 1
java -cp backend/target/backend-1.0-SNAPSHOT.jar:backend/target/dependency/*:common/target/common-1.0-SNAPSHOT.jar worker.WorkerServer 2

# Terminal 5-6 - Reducer Servers
java -cp backend/target/backend-1.0-SNAPSHOT.jar:backend/target/dependency/*:common/target/common-1.0-SNAPSHOT.jar reducer.ReducerServer 0
java -cp backend/target/backend-1.0-SNAPSHOT.jar:backend/target/dependency/*:common/target/common-1.0-SNAPSHOT.jar reducer.ReducerServer 1

3. Run Client Applications

# Manager Console
java -cp backend/target/backend-1.0-SNAPSHOT.jar:backend/target/dependency/*:common/target/common-1.0-SNAPSHOT.jar:manager-console/target/manager-console-1.0-SNAPSHOT.jar ManagerConsole

# Dummy Client (for testing)
java -cp backend/target/backend-1.0-SNAPSHOT.jar:backend/target/dependency/*:common/target/common-1.0-SNAPSHOT.jar:dummy-client/target/dummy-client-1.0-SNAPSHOT.jar DummyClient

Tmux Session Layout

The setup script creates organized tmux sessions:

Docker Mode:

  • Clients window: Dummy Client and Manager Console
  • ServiceLogs window: Live logs from all containers (Master, Workers, Reducers)

Local Mode:

  • Services window: All service processes (Master, Workers, Reducers)
  • Clients window: Dummy Client and Manager Console

Navigate between windows with Ctrl+b then n (next) or p (previous).

Configuration

Configuration files are located in:

  • Docker mode: docker/config-docker.properties
  • Local mode: backend/config-local.properties

Troubleshooting

Common Issues

  1. Port already in use:

    # Check what's using the port
    lsof -i :8080
    
    # Kill the process
    kill -9 <PID>
  2. Docker not running:

    # For Docker Desktop
    # Start Docker Desktop application
    
    # For colima (macOS)
    colima start
  3. Services not starting:

    # Check connectivity
    ./start-distributed.sh docker test
    
    # View detailed logs
    ./start-distributed.sh docker logs
  4. Build issues:

    # Force rebuild everything
    ./start-distributed.sh docker rebuild-setup

Monitoring

Monitor system resources:

./start-distributed.sh docker monitor

Development

For development, you can:

  1. Use the local mode for faster iteration
  2. Use Docker mode for production-like testing
  3. Access individual container shells: ./start-distributed.sh docker shell worker1
  4. View specific service logs: ./start-distributed.sh docker logs master

Android Client

Open the android-client project in Android Studio and run the application on an emulator or physical device. Make sure the backend services are running and accessible from your Android device/emulator.

Contributing

Contributions are welcome! Please feel free to fork the repository and submit a pull request.

About

A comprehensive Android application designed to facilitate online food ordering and delivery.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •