CloudKitchen is a simulation of a kitchen management system, handling order processing, courier management, and statistical reporting. This project demonstrates how different components of a cloud kitchen interact to ensure efficient order fulfillment and delivery.
- Order Preparation and Management
- Courier Creation and Dispatch
- Statistical Reporting of Orders and Couriers
- Graceful Shutdown
To install and run the project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/jai1/CloudKitchen.git cd CloudKitchen
-
Build the project using Maven:
mvn clean install
-
Run the application:
mvn exec:java -Dexec.mainClass="org.interview.cloud.kitchen.Main"
The application simulates a cloud kitchen where orders are prepared and dispatched by couriers. Key classes include:
OrderManager
: Manages orders from creation to dispatch.KitchenManager
: Handles order preparation.CourierManager
: Manages courier creation and dispatch.StatsManager
: Collects and reports statistics on orders and couriers.Dispatcher
: Manages the dispatch strategy.MatchedDispatcher
: A courier is dispatched for a specific order and may only pick up that orderFirst-in-first-out
: A courier picks up the next available order upon arrival. If there are multiple orders available, pick up an arbitrary order. If there are no available orders, couriers wait for the next available one. When there are multiple couriers waiting, the next available order is assigned to the earliest arrived courier.
To change between the dispatch strategies, change the dispatchStrategyClassName
in application.properties
Configuration details can be customized in the application properties file. Update the properties as needed to fit your environment.
Unit tests are provided to ensure the functionality of the system. To run the tests:
mvn test
-
First-in-first-out
StatsManager - orderCount = 132, orderWaitTimeInMillis = 50665, courierCount = 132, courierWaitTimeInMillis = 53536 StatsManager - Average order waitTime in Millis = 383 StatsManager - Average courier waitTime in Millis = 405 -
MatchedDispatcher
StatsManager - orderCount = 132, orderWaitTimeInMillis = 33284, courierCount = 132, courierWaitTimeInMillis = 41295 StatsManager - Average order waitTime in Millis = 252 StatsManager - Average courier waitTime in Millis = 312