Three Layers, Three Jobs
Once Sprout has to remember plants, it stops being one program and becomes three, running on different machines. Many full-stack bugs, and most security holes, come from doing a job in the wrong layer: checking a rule only in the browser, or asking the database to worry about what a button looks like.
The rule
The browser shows, the server decides, the database remembers.
| Layer | Runs on | Owns | In Sprout |
|---|---|---|---|
| Client | the user's device | showing data, collecting input, instant feedback | the plant list, the "Add plant" form |
| Server | a machine you control | who is asking, what they may do, the rules | "only the owner may delete this plant" |
| Database | a machine you control, kept private | durable data and its basic rules | the plants table |
The client is the HTML, CSS and JavaScript running in the browser. It is fast and close to the user, but it sits on their machine. Anyone can open the developer tools, change the code, or skip the page entirely and send requests by hand. Treat everything that arrives from a client as a claim, not a fact.
The server is your code (Sprout uses Node.js) on a machine the user cannot touch. It receives requests, works out who is asking, checks whether they are allowed, validates the input, applies the rules and talks to the database. It is the only layer where a rule truly holds.
The database (Sprout uses PostgreSQL) stores data so it survives restarts, answers queries, and enforces structural rules such as "every plant has a name". Only the server talks to it. The browser never sees its address or password.
The most important line in the picture is the one between client and server. Everything on the browser's side of it can be changed by the user.