Vefskólinn · Back-end · act one and act two
Your app works on one screen. Now make it real: shared, and safe.
press → to begin
Where we are
fetch() from the Web APIs guide
a terminal agent that writes code with you
you describe, the AI builds, you decide
A server exists for exactly two reasons: shared truth and trust. Act one is the first, act two is the second.
Who does what
The problem
localStorage is storage inside one browser on one device. Refresh survives. Sharing does not.
The vocabulary
One request, start to finish
// the request
// the response
Reading the response
The rule
Does more than one person, or more than one device, need to see the same thing?
the book list, the likes, the leaderboardMust it still exist when this browser is closed, cleared or lost?
anything you'd be sad to loseCould the browser lie about it, and would that matter?
prices, who owns what, who is logged inWould it be bad if a stranger read it in view-source?
API keys, passwords, database addressesFour times no? Leave it in the browser. It's faster, free, and works on the bus. Write the answer down for every piece of data in your app: that list is your boundary map, and it is the first thing you make in act one.
The game
Round 1 of 10
…
Ask the four questions. Shared? Survives? Trusted? Secret?
The database
Act one
the prompt, roughly
“Move my book list out of localStorage and onto a server with a real database, so that my laptop and my phone show the same list. Keep the front end in Vue. Put the database address in an environment variable, and deploy it so I can open it from my phone. Explain every file you create.”
the laptop-and-phone test
Add on one. See it on the other. That is the pass mark.
The evidence
Click a row.
Every row is one request and its response.
In your report: one request, annotated. What went out, what came back, and why the status is what it is. If it isn't in the network tab, it didn't happen.
Act two
what the network tab shows to anyone who opens your site
Secrets
.env server only · never committed
MODEL_API_KEY=sk-live-8f3…d21 DATABASE_URL=postgres://…@host/books
.gitignore
node_modules .env .env.* !.env.example
server.ts
const key = process.env.MODEL_API_KEY
if (!key) throw new Error("no key set").env.example this one IS committed
MODEL_API_KEY=put-your-key-here DATABASE_URL=put-your-db-url-here
VITE_ and NEXT_PUBLIC_ mean “copy this into the browser”. An agent will use them to silence an error. Say no.Trust
The browser can say anything. The server decides what is true. Identity, ownership, shape, and how often. Every check is one line the agent will happily write, once you ask.
Day two, after lunch, one hour
Rules
Every point you score is a fix you owe your own app. Then the incident note: what was found, how, what you changed.
When, not if
.env, check .gitignore, set it in the host's dashboard.Hosting
the server
the database
.env.you decide with three questions
the agent picks, you approve
The server has no screen
Something went wrong once.
Click the line that tells you what.
Your report
.env.example, and proof the network tab shows no key.Hand-in
.env.example and no real key anywhere in gitreport/index.html in the repo and published: boundary map, one annotated request, where the key lives, what was found and fixedAct one. Boundary map, then the prompt. Server, database, one env var, deployed. Laptop-and-phone test passes before you leave.
Act two. The AI feature, the key in .env, the trust checks. Attack hour after lunch. Score points, owe fixes.
Fix, write, review. Close what was found. Report with evidence. Two reviews, then your reply. Group project starts Monday.
that's why there's a server
Speaker notes · N to hide
| → space | next step |
| ← | previous |
| Home End | first / last slide |
| N | speaker notes |
| F | fullscreen |
| B S | on the game: answer Browser / Server |
| ? | this help |