Node Depot — Node.js

Build Mas Wisnu's water depot Node server: event loop, Promise, stream, worker, cluster, SIGTERM. 16 levels, right in the browser.

What the levels ask

  1. Monday morning, Mr. Wisnu's first day running Depot Air Bening. server.cjs on his laptop switches the depot on through a relay board. His father's SOP on the wall: lights, porch swept, RO pump, tank full, OPEN sign. Choose how to schedule pompa so Node runs all five steps exactly as the SOP says.
  2. Tuesday. The opening script is now an ES module, server.mjs, with the same contents as yesterday. But this morning the tank is declared full before its pump starts. The SOP is unchanged: lights, porch swept, RO pump, tank full, OPEN sign. Choose the two scheduling lines that make Node follow the SOP again.
  3. Wednesday. The morning report for the neighbourhood head reads the tank meter, so the meter must be logged first. On Mr. Wisnu's laptop the order was always right, but Node will run this server 300 times. Choose where to call jadwalkan() so the meter is logged before the report on every run.
  4. Thursday. Mr. Wisnu recounts 2000 gallon records, one gallon per step, then schedules the next step. But Mrs. Sari, Mr. Tono and Mrs. Ijah wait at the counter until the count is finished. Choose how to schedule the next langkah so their orders are served in between the steps.
  5. Friday. Every order asks three services, the warehouse, the courier and the price, each answering in 150 ms. Mrs. Lastri, Mr. Karim and Mr. Jaya complain their orders are slow. Choose how to ask so all three answers reach the buyer whole, and the three services are asked at the same time.
  6. Saturday. The cooperative's price service is down and answers 503; the warehouse and the courier are fine. Mr. Wisnu wants the orders from Mrs. Yanti, Ms. Wulan and Mr. Dodi still accepted, with the price logged as failed so he can use yesterday's. Choose the promise combinator.
  7. Sunday. After logging an order, the server sends the buyer a WhatsApp message, but this morning the gateway's quota is used up and every message is refused. Five villagers order. Choose how to call kirimWA so a failed message is only logged, and the depot still serves all five buyers.
  8. Monday of the second week. Five people download the 36 MB order report for 2025 at once, and Mr. Wisnu's laptop has little memory. Choose how to send rekap-2025.csv so all five receive the whole file and the server's memory does not flood.
  9. Tuesday. Grandma Marni downloads her order history, 200,000 lines, on a phone with one bar of signal. The server writes line after line far faster than her phone can take them. Choose how to write each line so Grandma Marni's phone receives all of them and the server's memory does not flood as well.
  10. Wednesday. Six young people download the 2025 report, then the signal at the end of the lane drops and all of them are cut off. That night lsof shows files the server still has open. Choose how to stream the file so a dropped download closes its file, and the neighbourhood head's download after them still arrives whole.
  11. Thursday. Mrs. Harti from the cooperative asks for the monthly report, about half a second of CPU over tens of millions of records. Meanwhile five villagers come to order. Choose how to compute the report so their orders are still served while it is being computed.
  12. A blessed Friday: twenty four orders come in at once, and every receipt needs a hash computation. One Node process uses one CPU core, and the laptop has ten. Mr. Wisnu wants four counters listening on the same port. Choose what goes in the primary process's branch.

And more, 16 levels in all.