Hookline
Sign in
ImplementationSystem architecture

How it was built.

A small number of files, each with one job. Content is data, screens are routes, the judgement that matters happens in one server function, and permission is written where the data lives rather than where it is shown.

12 pages33 components2 stored records12 scenarios26 codes
The stack
Framework

TanStack Start

UI

React 19

Styling

Tailwind · CSS tokens

Backend

Server functions + entities

Model

AI gateway, schema-bound

Module map

Six places hold everything.

src/routes

12 pages

One file per screen, and the URL is the file name. Public pages sit inside the site layout; the drill, inspector and dashboard sit inside the gated one.

src/components

33 components

Small, single-purpose pieces: the email frame, the flag list, the risk meter, the verdict badge, the code entry, and the architecture primitives.

src/data

4 datasets

The teaching material as plain arrays — scenarios, red flags, the A–Z codes, and the architecture copy. Adding an example is an object, not a component.

src/lib

server + auth

Server functions, the session middleware, the auth context and shared utilities. Anything that must not reach the browser lives behind these.

base44/entities

2 entities

Two schemas that each carry their own access rules, so permission travels with the data instead of depending on the screen that reads it.

src/index.css

tokens

The whole design system in one file: colour tokens for light and dark, type roles, the grain texture and the small mono label utility used everywhere.

Key modules

The code that does the work.

Six excerpts, one per job — the analysis call, the recorded answer, the session gate, the risk bands, the access rule and the colour tokens. Everything else follows from them.

The analysis call

js

One server function does the whole live half: check the caller, parse the input against fixed limits, send the frame prompt, and return a schema-bound verdict. The prompt and the schema never leave the server.

src/lib/phishing-fns.jsjs
export const analyzeEmail = createServerFn({ method: "POST" })
  .middleware([requireUser])
  .validator((data) => EmailInput.parse(data))
  .handler(async ({ data, context }) => {
    const result = await context.getBase44().asServiceRole
      .integrations.Core.InvokeLLM({
        prompt,
        response_json_schema: analysisSchema,
      });
    return result;
  });

requireUser runs before the handler, so an anonymous call is rejected before any credit is spent.

Recording an answer

jsx

The drill keeps its round in local state — deck, index, current choice — and writes to storage only when a decision is made. One record per email, with the time it took, so accuracy and speed are both measurable later.

src/routes/_authed/drill.jsxjsx
async function answer(guessedPhishing) {
  const correct = guessedPhishing === scenario.is_phishing;
  const seconds = Math.round((Date.now() - startedAt.current) / 1000);

  setChoice({ guessedPhishing, correct });

  await base44.entities.DrillAttempt.create({
    scenario_id: scenario.id,
    category: scenario.category,
    is_phishing: scenario.is_phishing,
    guessed_phishing: guessedPhishing,
    correct,
    seconds,
  });
}

setChoice runs before the write, so feedback appears instantly even on a slow connection.

The gate

jsx

A pathless layout resolves the session once, before any child page loads. Pages under it never render for a visitor who is not signed in, and never fetch a record that would be refused.

src/routes/_authed.jsxjsx
export const Route = createFileRoute("/_authed")({
  ssr: false,
  beforeLoad: requireSignedIn,
  errorComponent: AuthGateError,
  component: AppShell,
});

The gated layout renders the app shell: side navigation, account controls, and the page itself.

The risk meter

jsx

The score is clamped once, at the top, and a single band lookup drives the number, the bar and the label. Three values, one source of truth — the colour can never disagree with the number.

src/components/RiskMeter.jsxjsx
const bands = [
  { max: 25, label: "Low risk", bar: "bg-safe" },
  { max: 64, label: "Elevated risk", bar: "bg-caution" },
  { max: 100, label: "High risk", bar: "bg-signal" },
];

const value = Math.max(0, Math.min(100, Math.round(score)));
const band = bands.find((b) => value <= b.max) ?? bands[2];

The same three bands are what the analysis schema is told to stay inside.

Access written on the record

json

Both entities declare their rules in the schema, so the same rule applies whether the record is read by a page, a count or an aggregate. The interface never needs a permission check of its own.

base44/entities/DrillAttempt.jsoncjson
"read": {
  "$or": [
    { "created_by_id": "{{user.id}}" },
    { "user_condition": { "role": "admin" } }
  ]
}

Owner-or-admin on read, update and delete. Creation stamps the creator automatically.

Three colours that mean something

css

Signal red, safe teal and caution amber are the only colours that carry information, and they are declared once as tokens with a dark-mode twin. Type does the rest: a serif for statements, mono for evidence and labels.

src/index.csscss
:root {
  --signal: 8 68% 44%;     /* a red flag, a miss  */
  --safe: 172 48% 26%;     /* correct, benign     */
  --caution: 32 85% 36%;   /* elevated            */
  --font-heading: "Instrument Serif", serif;
  --font-mono: "JetBrains Mono", monospace;
}

Components use bg-signal or text-safe — never a raw hex — so the dark theme follows for free.

Design system

Type carries the tone. Colour carries the verdict.

Palette
Signal — a flag, a miss, the hook--signal
Safe — correct, benign--safe
Caution — elevated, uncertain--caution

Three tokens, each with a dark-mode twin. Nothing else in the interface is allowed to be coloured.

Type

Instrument Serif

headings · statements

Inter carries the running text at a comfortable reading size, so a long explanation stays readable next to a verdict.

body · ui

JetBrains Mono — evidence, labels, scores

mono · quotes

Decisions

Six choices that shaped the build.

Email as text, never HTML

A trainer that executes the payload it is teaching about is a bad teacher. Bodies are stored as paragraphs and links are printed as text, so nothing renders or fires.

The model call is server-side only

A client-side call would put the prompt, the schema and the credit spend in the browser. A named server function keeps all three behind the session check.

Content lives as data

Scenarios, flags and codes are arrays consumed by one renderer each. A new teaching example is a few lines of data — no new route, no new layout, no copy-paste.

Fixed output, free thinking

The analyser is free in how it reasons and fixed in what it returns. Six known fields mean the interface can never be broken by a chatty answer.

One accent per meaning

Colour is reserved for judgement. Everything else is ink, paper and rule lines, which keeps a red flag actually red when it appears.

Mobile from the same code

Nothing is designed twice. Layouts collapse with grid and flex, and the type scale steps down — the same page ships to a phone and a wide monitor.

Limits

What it does not do yet.

  • The scenario set is code, not records — changing it needs an edit and a deploy.
  • The analyser is a single pass; there is no second model call to re-check its own flags.
  • The Python predicates are the published reading of each code, not an engine running in the app.
  • History is personal only: there is no cohort or class view across learners yet.
  • The drill is untimed by design — seconds are recorded, but nothing is scored against the clock.

Read it in the order it runs.

The overall map shows how the parts sit together; the architecture page follows one request through them; the code list shows what each check is looking for.