MIVORA Start learning free

The Builder's Stack

Frontend, backend, database — three jobs. Knowing which does what is how you ship without getting lost.

Building with AI · Lesson 25 · 10 min read

You can prompt, evaluate, do RAG, and build an agent — but “turn it into a real app people can use” still feels like a fog. Where does the AI call happen? Where does the key live? Where does data persist? Without a mental model of the stack, you wire things into the wrong place — usually the dangerous one. Let’s clear the fog.

Three jobs: frontend, backend, database

The model call belongs in the backend (behind a proxy), exactly like the one this very platform uses for grading. The frontend asks the backend; the backend holds the key and talks to the model.

Worked example
This app’s own stack: the React frontend (public) calls /api/ai (backend), which injects the secret key and calls the model. The key never touches the browser. That’s the pattern you’ll reuse for any AI app.

Data flows in a loop

A request flows: frontend → backend (auth, key, model call, business logic) → database (read/write) → back to the frontend to render. Each layer has one responsibility, which is what keeps an app understandable as it grows. When something breaks, you ask “which layer owns this?” — the same triage instinct from prompt debugging, applied to architecture.

An everyday analogy

A restaurant. The dining room (frontend) is where guests interact — nothing secret happens in view. The kitchen (backend) holds the recipes and the safe, does the real cooking, and is off-limits to guests. The pantry (database) stores ingredients between services. Put the safe in the dining room and you’ll get robbed — which is exactly what shipping an API key to the browser is.

Worked example
Tracing one feature — “summarize my notes”:
1. Frontend: user clicks Summarize, sends their notes to the backend.
2. Backend: checks the user, injects the API key, calls the model, applies limits.
3. Database: saves the summary to the user’s record.
4. Frontend: renders the saved summary. Each layer did exactly its one job.

This is the reading. The interactive version — active-recall quiz, a hands-on experiment you run in your own AI, and an earned mastery check — is free in the app.

Start this lesson free →