Chapter 14: Data and failure

Start with why the data lives in a separate program at all.

Database

A program whose job is to keep data safe and find it again quickly, while many other programs read and change it at once. Your app asks it questions over a connection. If your app crashes, or the database itself does, what it said it saved is still there.

Agents reach for the nearest thing that works: a JSON file, an array, a local SQLite file. All of those pass a demo with one user. The difference only appears with two copies of your server, two requests at once, or a crash. So choosing the store is your decision, not a detail to leave to the agent.

Say it to your agent

“Don't store orders in a JSON file or in memory. Use Postgres with the connection string from DATABASE_URL. Then prove it survives: create an order, kill the server with kill -9, restart it, and show me the row.”

The workshop

Name a word, or describe what you mean in everyday language.