JomMula

Gallery Blog · Lesson 03

The Master Plan

Before the first line of code, meet the blueprint we'll follow for the whole build — one app, eight phases, and one rule: no phase is done until you've verified it.

7 min readExplanationthe planno codeUpdated October 2026

The mockup is done. We know what the gallery looks like. Now — before any real code — we meet the document that runs this entire build.

It’s called the master plan. It’s not a tutorial; it’s a blueprint, written for exactly one situation: someone (or something) starting this app from an empty folder. Every remaining lesson in this project maps to a phase inside it.

You’re the builder. opencode is your assistant. The plan keeps you both honest.

The plan itself

Keep it open in a tab. It’s the source of truth — when a lesson and the plan disagree, the plan wins.

Download master-plan.md

One app, not a pile of apps

The stack from lesson 1 — Express, EJS, Neon, R2 — is exactly this plan’s stack. But there’s a detail a stack list can’t show you: it’s one Express app that does everything.

It renders its own pages (EJS), handles its own forms (plain HTML), talks to Neon for data, and to R2 for photo files. There is no separate client project, no build step for the browser, no CORS, no API contract to keep in sync.

The plan calls the app’s own features — photo folders, likes, comments — extensions. They plug into fixed seams; they never rewrite the core. That’s why we can build the whole thing in one course and still have room to grow it after.

The eight phases

This is the shape of everything to come. Tap through it — each phase is a lesson, and each lesson ends with a mission:

The build order — 8 phases, no skipping

Tap a phase to see what you get

  1. package.json, tsconfig, .gitignore, .env + .env.example. Nothing runs yet — but every tool is in place.

    Lesson 04Jump to it

Every phase ends with a mission — the plan's own Verify: line. Pass it before you move on. That's the whole discipline.

Read that order like a sentence: get it to boot, then let yourself in, then show pages, then store data, then store files, then prove it, then ship it.

What the plan is strict about

The plan has a section called hard invariants — rules it will not bend. You’ll meet them one by one, but here’s the flavor:

  • Auth is one owner. Your email and password live in environment variables, never in the database. There’s no users table, no signup, no password reset. Nothing to attack because nothing is stored.
  • The database changes slowly, on purpose. Migrations are generated, then read by a human (you), then applied by hand. Deploys never run them.
  • Images never touch our server. The browser uploads straight to R2 with a short-lived signed URL. The database stores the key, not the file.

Don’t memorize these yet. Just notice the pattern: every invariant is a decision that trades a little convenience for a lot of safety.

How we’ll drive it

  1. 1

    Read the plan once

    Not memorize — just know its shape. Download it above and skim it. You'll come back to sections constantly.

                  master-plan.md
                

    It's written for a coding agent, so you can also just... give it to opencode. But you should still know what's in it.

  2. 2

    Collect the facts

    The plan refuses to let anyone invent values — §0.2 is a list of facts only you can supply (app name, domain, credentials, database and R2 details). We'll gather them as each phase needs them.

                  §0.2 — Facts to collect from the user
                
  3. 3

    Build in order, one lesson per phase

    Each lesson teaches the concept first — graphics and all — then the files, then you brief opencode or write them yourself. Understanding is what lets you review what the agent produces.

  4. 4

    Run the mission

    Every lesson ends with a mission box — the plan's own Verify step. Run it for real. The app either does the thing or it doesn't; there's no partial credit.

The facts you’ll be asked for

Some phases pause and need real values from you. Nothing secret ever goes into the plan document itself — secrets live in a .env file that never gets committed:

Fact Where it ends up
App name + one-line purpose APP_NAME, page titles
Production domain PUBLIC_BASE_URL, R2’s CORS list
Your login email + a 12+ character password ADMIN_EMAIL, ADMIN_PASSWORD
Neon connection string (pooled host) + a second branch for tests DATABASE_URL, TEST_DATABASE_URL
Cloudflare account id, bucket name, R2 API token R2_*
Public or private images? R2_PUBLIC_BASE_URL

You don’t need all of these today. You’ll need each one exactly when its phase arrives — and the lesson will tell you.

Your mission

the plan's verify step

Your mission for this lesson is a reading one — but do it properly. Download the plan, skim the table of contents, and find three things: the phases list, the invariants list, and the footguns table.

No code yet. If you can point to where 'footguns' lives, you're ready for the next lesson.

Recap

The master plan is the blueprint — one Express app, eight phases, verified one at a time.

One app renders its own pages, its own forms, and talks to Neon + R2 directly.

Boring choices are deliberate: fewer moving parts, fewer ways to break.

Invariants are the rules the plan won't bend — safety traded for small conveniences.

You drive, opencode assists — and the mission boxes are non-negotiable.

Next: phase 1 — scaffolding the project. An empty folder that installs, typechecks, and knows where everything is going to live.

Previous: Mockup with opencode
04

Up next

Scaffold: an empty project that boots

Phase 1 — package.json, tsconfig, env files, and the folder map the whole app will live in. Nothing runs yet; everything has a place.

Read now