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.
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
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
- Add and manage stores
- Add, remove, and update products
- View total sales by product and store category
- Console-based interface for management operations
- 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
- Java 11 or later
- Maven 3.6+
- tmux (for session management)
- Docker & Docker Compose (for Docker deployment mode)
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:
- Check all prerequisites
- Build all modules (if changed)
- Start all services
- Create a tmux session with organized windows for services and clients
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
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
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 |
If you prefer manual setup:
# 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
cd docker
docker-compose up -d
# 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
# 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
The setup script creates organized tmux sessions:
- Clients window: Dummy Client and Manager Console
- ServiceLogs window: Live logs from all containers (Master, Workers, Reducers)
- 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 files are located in:
- Docker mode:
docker/config-docker.properties
- Local mode:
backend/config-local.properties
-
Port already in use:
# Check what's using the port lsof -i :8080 # Kill the process kill -9 <PID>
-
Docker not running:
# For Docker Desktop # Start Docker Desktop application # For colima (macOS) colima start
-
Services not starting:
# Check connectivity ./start-distributed.sh docker test # View detailed logs ./start-distributed.sh docker logs
-
Build issues:
# Force rebuild everything ./start-distributed.sh docker rebuild-setup
Monitor system resources:
./start-distributed.sh docker monitor
For development, you can:
- Use the local mode for faster iteration
- Use Docker mode for production-like testing
- Access individual container shells:
./start-distributed.sh docker shell worker1
- View specific service logs:
./start-distributed.sh docker logs master
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.
Contributions are welcome! Please feel free to fork the repository and submit a pull request.