Skip to content

obliquee/CloudKitchen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CloudKitchens Take-Home Assessment

A real-time food order fulfillment system for a delivery-only kitchen, built with Java 17 and Spring Boot.

How to Build

Local Build

mvn clean package -DskipTests

Docker Build

docker build -t cloudkitchens-solution

How to Run

Using Docker

docker run --rm cloudkitchens-solution --challenge.auth=YOUR_AUTH_TOKEN

With Custom Settings

docker run --rm cloudkitchens-solution
--challenge.auth=YOUR_AUTH_TOKEN
--rate=500000
--min=4000000
--max=8000000
--seed=12345

How the System Works

When an order comes in, the system cooks it instantly and tries to store it in the best place. Hot food goes to heater it holds 6 orders. Cold food goes to the cooler it holds 6 orders. If those are full, food goes to the shelf it holds 12 orders

Well the food stored at the wrong temperature goes bad twice as fast. So a hot pizza sitting on the room temperature shelf will spoil in half the time compared to being in the heater.

When a courier arrives to pick up an order, check if it's still fresh. If it has gone bad, throw it away. If it's still good,hand it over.

How I Pick Which Order to Throw Away

When the shelf is full and we need to make room for a new order, we have to throw something away. I chose to discard the order with the least freshness remaining - basically, the one closest to going bad anyway.

A Note on Efficiency

The challenge asks for better than O(n) time complexity for the discard logic. I use a min-heap to track orders by their expiration time, which gives O(log n) for adding, removing, and finding the order to discard.

Thread Safety

The system is built to handle orders and pickups happening at the same time. All the storage areas use read-write locks so multiple threads can read safly, but only one can write at a time. Action log uses thread safe list that handles concurrent reads and writes. And countdown latch makes sure wait for all orders to finish before submitting results.

Other Details

  • Timestamps are in microseconds as the challenge server expects
  • All actions print to the console so you can follow along in real time
  • Everything runs in a single process with multiple threads

About

A real-time food order fulfillment system for a delivery-only kitchen, built with Java 17 and Spring Boot.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages