Dinner Service · Lesson 04 of 10
The Pantry
Lesson 4 of Dinner Service: 'database' is the scariest word in this course and it turns out to mean shelves. Give your comment card box a real memory — cards that survive restarts — and look inside the pantry with your own eyes.
Last lesson ended with a small cruelty on purpose: two cards, heard and warmly answered, gone on restart. Your app listens but keeps nothing — a host with no notebook.
The fix has the most intimidating name in this whole course: a database. Here's the entire concept, demystified in one move: a database is a pantry. Shelves, with labels, where things keep until you come back for them. "Put this card on the cards shelf." "Show me everything on the cards shelf." That's the whole job. You've been near one this entire journey without being told — every First Kitchen graduate reading these lessons is reading them out of our pantry.
What you'll plate today
A comment card box with a memory: submit a card, see it appear on the wall, restart everything, and find it still there. Plus one look inside the raw pantry, so the word never scares you again.
Ingredients
- Your
dinner-servicefolder, PLAN.md pointing at step 3 - About 30 minutes
Cook
1. Order the shelves
Cook step 3 of PLAN.md — give the card box a real memory:
1. Set up a database for this project — Cloudflare's built-in one
(D1), LOCAL on my machine for now, matching how the project
already runs.
2. Make one shelf for the cards: name, note, and when it arrived.
3. When a guest submits a card, put it on the shelf before showing
the thank-you page.
4. On the main page, show the wall: every card so far, newest
first, in my site's style.
5. Then explain to me in three plain lines: where does this
database physically live right now, and what happens to it
when I restart?
Approve what it asks — it'll create the database and the shelf (the technical word is table; a table is a shelf with a label). Read its three-line answer: the pantry lives in a folder inside your project, on your machine, and restarting the stove doesn't empty it. Today, that claim is ours to break.
2. Stock the pantry, then try to lose it
Start the stove, open the address, and submit two or three cards — real ones. What you'd want a friend to write. Watch each one appear on the wall.
Now the test that failed last lesson. Stop the server. Start it again. Refresh.
Still there. Every card. That difference — between Lesson 3's vanishing and this — is the difference between an ear and a memory, and you now own both. This is also the moment your project quietly became the real thing this course promised: an app that remembers what people tell it.
3. Look inside the pantry (demystification)
Don't let the database stay a black box — black boxes grow scary in the dark:
Show me the raw contents of the cards shelf, straight from the
database — every row, exactly as stored. Then tell me the exact
question you asked the database to get it, in one line, and
translate that line to plain English word by word.
You'll see your cards as neat rows, and a one-line question that reads almost like English — select everything from cards, newest first. That language is called SQL, it's older than the web, and your agent speaks it fluently so you never have to. You just need to know what it looks like, so that the day something's weird in the pantry, you can ask to see the shelves instead of guessing.
4. Close the menu
Mark step 3 done in PLAN.md — the plan we wrote in Lesson 2 is
now fully cooked. Add one honest line about anything we changed
along the way. Make a save point: "the pantry — plan v1 complete".
Three steps, planned in plain words, cooked one at a time, each tasted before the next. That's not a beginner workflow with training wheels — that is the workflow. It just has friendlier names here.
When it burns
- "Do you want a local or remote database?" — local today: "Local on my machine. Going public is next lesson's dish." The remote pantry gets set up when we serve.
- The wall shows nothing after submitting — split the taste, like the data lesson taught you: "Is the card reaching the shelf? Show me the raw rows first. Then check the wall separately." One of the two is broken; make it say which.
- Cards vanished anyway after restart — most likely the agent rebuilt the database along the way. Ask: "did anything we ran tonight wipe and recreate the shelves? Set it up so restarts never touch existing cards."
- You spot a hidden folder with cryptic names in your project — that's the pantry's physical shelf space (the agent will name it if you ask). Don't tidy it, don't fear it. Hidden folders doing quiet work is normal kitchen plumbing — you met one in First Kitchen when save points arrived.
- Korean (or any non-English) cards look garbled — you've seen this dragon before, in Cook Your Own Data: "make sure the whole path — form, worker, database — treats text as UTF-8."
Order up
□ Cards land on the wall, newest first, in your style
□ Stop, restart, refresh — every card survived
□ You saw the raw rows and the one-line question that fetched them
□ PLAN.md v1: all three steps done and dated
□ Save point made — and mirrored to GitHub without asking
Next up — Lesson 05: Open for Guests. A card box on localhost is a suggestion box bolted inside your own house. Next lesson it goes to a real URL, and someone who isn't you drops a card in — the wow moment this whole course is built around.
Stuck on a step? Question box below.