Engineering Review Dossier · Confidential · Pre-Launch

The Awesome Link OS — Technical Handoff & Final-Review Brief

A complete, verified map of the OS stack — generated frontend, DINA backend, data spine, security posture, AI brain, and QA harness — plus the prioritized set of tasks that must close before launch. Every fact below was read out of the live codebase, not assumed.

Prepared for: incoming software engineer Product owner: Mostafa Bastami As of: 2026-07-15 Backend status: live (HTTP 200)
Frontend source
12.8k
lines · build.py
Built artifact
~860 KB
index.html, one file
Backend routes
51
Next.js API handlers
OS modules
18
tabs / views
QA checks
19
headless, must exit 0
Datastore
Files
no DB — JSON + FS

Two non-obvious rules cause silent lost work if ignored. Read §1 before touching anything.

01

Read this first — the two build rules

This repo has an unusual architecture. Two facts break naïve edits, and both fail silently — the app looks fine, your change just vanishes or never activates.

Rule 1 · Frontend

The UI is generated. Never edit index.html.

The entire OS UI (HTML, CSS, and ~all JS) is emitted by awesome-link-os/build.py — a single Python file that holds the markup/CSS/JS as strings. Running it writes index.html and deploys a copy to dina/public/os/index.html.

  • Edit build.py, never the generated index.html or the deployed copy — the next build overwrites them.
  • Rebuild + deploy: python3 build.py · local-only: AL_OS_NO_DEPLOY=1 python3 build.py
  • Sanity-check the emitted JS with node --check on the largest inline <script>.
Rule 2 · Backend

DINA runs prebuilt. Rebuild + restart after edits.

DINA (Next.js, port 3737) runs via next start over a compiled .next. Editing a .ts/route does nothing to the running server until you rebuild and restart. tsc --noEmit does not activate code.

  • pnpm build then bash scripts/dina-restart.sh (never launchctl kickstart directly).
  • The restart script defers when run under the Operator (env OPERATOR_RUN_ID) to avoid killing an in-flight run.
  • Verify live: curl -s -o /dev/null -w "%{http_code}" .../os/index.html200.
Non-negotiable gate

Every OS change must pass the headless self-check verify/verify-os.mjs (exit 0) before it is considered done. It loads the live OS in real Chrome and fails on any JS error, thrown view, or stale deploy. node --check alone will not catch a runtime/render break. See §7.

02

System map — the request path

One machine, two codebases. A vanilla-JS single-page frontend served as a static file, talking to a Next.js backend that holds all auth, data, and AI. There is no separate database or web framework on the frontend.

Client
Browser / iPhone PWA. Holds session token in memory.
index.html · vanilla JS · service worker
Edge (public)
Cloudflare named tunnel + Access, email-gated.
os.awesomelinkfilms.com
DINA server
Next.js 15, loopback-bound, serves OS + API.
127.0.0.1:3737 · next start
Data + AI
Flat-file store on disk + Anthropic API.
~/.awesome-link-work · Claude API
Serving path: DINA serves the OS at /os/index.html — a bare /os/ 404s (the redirect handles /os). Phone reaches it via the Cloudflare tunnel (backup: Tailscale bridge, port 3838).
03

Frontend — the generated OS

Stack & build
Source
build.py · 12,801 lines Python (~963 KB)
Output
index.html · ~860 KB, single self-contained file
Framework
None — vanilla JS/DOM (no React/Vue/Angular)
State
In-memory JS object D{}, hydrated after login
Install
PWA: manifest.webmanifest + service worker + icons
Perf
Cache-first SW; immutable image headers

The ~860 KB is dominated by inline JS. Boot cost on the 2017 dev laptop is the known frontend perf bottleneck (see §8 risks).

Modules (18 views)

Tab views registered in build.py via data-view:

  • home
  • welcome
  • mission
  • pulse
  • database
  • market
  • pipeline
  • bids
  • locations
  • inventory
  • outreach
  • messages
  • activities
  • thoughts
  • library
  • todo
  • studio
  • settings

Phase-2 SKU plan mothballs several of these into a curated 6-tab sellable edition (Bids · Network · Locations · Rebate Calc · Pipeline · Studio Brain).

Notable frontend subsystems

  • Bid Engine — Rebate Calculator (15 rebate schemes, budget+country → cash-back/net cost) → "Draft this bid" prefills the Bid Generator; tri-currency (EGP/USD/EUR) via a single FX engine; AES-GCM-encrypted budget block in generated proposals.
  • Locations — per-venue cards + reel stills extracted from footage; ~438 stills. ⚠ ~464/836 scout photos are undownloaded cloud stubs, so some premium venues silently vanish until downloaded.
  • Studio Core / OS control — the AI brain drives navigation/filter/spotlight via a ⟦OS⟧[…]⟦/OS⟧ action protocol; requires DINA online.
  • Voice — browser-local wake word; ElevenLabs flash TTS + Scribe STT via backend; local intents with Studio Core AI fallback.
  • Camera command-deck — Tapo camera gesture/follow-me control (hands-on tested).
04

Backend — DINA (Next.js)

Runtime
Framework
Next.js 15.1.6 · React 19 · TypeScript 5.7
Serve
next start over prebuilt .next
Bind
127.0.0.1:3737 (loopback only)
Cloud script
start:cloud0.0.0.0:$PORT (Railway-ready)
Deps
@anthropic-ai/sdk, stripe, pptxgenjs, jszip, picovoice
lib/ — the logic core
  • alOsData.ts (30 KB) — data spine, tenant-scoped reads
  • auth.ts (16 KB) — multi-tenant scrypt + HMAC sessions
  • studioAgent.ts (47 KB) — sandboxed Studio / Edit-OS agent
  • operator.ts — the phone agent runner + deferred restart
  • alOsIngest / Enrich / Match / Tags / Knowledge / ThoughtScan
  • anthropicClient.ts · dinaPrompt.ts · plans.ts

API surface — 51 routes

GroupRepresentative routesPurpose
/api/auth/*login · me · refresh · signup · admin · team · change-passPassphrase login → HMAC token; 1h TTL with background refresh; multi-tenant.
/api/al-os/*bootstrap · roster · contacts · crm · locations · match · bid-extract · bid-template · bid-pptx · bid-deploy · enrich · tags · knowledge · outreach-draft · operator · camera · thoughts · export · healthThe OS data + feature spine. bootstrap hydrates sensitive data post-login; the rest power each module.
/api/billing/*checkout · status · webhookStripe subscription plumbing (harvested for the productized SKU).
/api/voice/*route · list · sttTTS voice list + speech-to-text (ElevenLabs).
/api/chatrouteStudio Core conversational brain. auth-gated (401)
/api/body/*ingest · live · summaryHealth/telemetry ingest (Whoop bridge experiment).
05

Data store & the AI brain

Persistence — no database

All runtime data is flat files under ~/.awesome-link-work/, plus build-time JSON committed alongside build.py.

  • Runtime FS: messages.json, tags.json, knowledge/, bid-templates/, loc-uploads/, operator/, studio/
  • Build-time JSON: data.json (122 KB), mena.json (327 KB, 1,746 contacts), brain.json
  • Auth store: dina/credentials.json (scrypt hashes, chmod 600)

Implication: state is single-node and local by design. Off-laptop / multi-tenant scale means moving this to a persistent-disk host (Railway pivot) — see §8.

Models in use

Anthropic API, tiered by task weight:

Opus 4.8
bid-extract · enrich · ingest · thought-scan (heavy reasoning)
Sonnet 4.6
chat · inv-tag · loc-extract · outreach (lighter)

The Sonnet calls pin claude-sonnet-4-6; the current family is Sonnet 5 — worth a deliberate model-refresh pass at review (see checklist P3).

06

Security posture — verified

The threat model is "a static file can't be secured by a login — so stop shipping the data in the file." That principle is largely executed. Findings below are from a live probe of the shipped index.html, not the plan docs (which disagree with each other on this point — trust the probe).

ControlStateEvidence / note
Backend authDonescrypt passphrase + HMAC-signed stateless tokens, 1h TTL + background refresh loop.
Multi-tenant isolationDoneToken carries {tenantId, role}; owner→global data, others→empty-by-default; verifySession() is fail-closed.
Token storageDoneHeld in memory in the OS, not localStorage.
CORS + network bindDoneOrigin-locked; all servers loopback-bound (LAN closed).
/api/chat gatedDoneReturns 401 without a valid session (verified in source).
De-embed MENA contactsDone1,746 contacts removed from index.html (MENA = []); hydrated post-login via bootstrap.
Public exposureGatedCloudflare named tunnel + Access (Mostafa's email only, 1-mo sessions).
Residual literals in built fileScrubPartner email marton@spacemediafilms.com + company Tax ID / CR numbers still literal in index.html (owner-gated in UI, but present in source). Low severity, real.
Tunnel boot-persistenceOpenQuick-tunnel replaced by named tunnel, but not yet service install'd — a Mac reboot drops public access.
Agent sandbox — worth understanding

The Studio agent (studioAgent.ts) spawns headless Claude Code with tools allow-listed to Read/Write/Edit only — no Bash, network, MCP, or secrets (env-stripped), under a single-run lock + timeout. Edit-OS mode edits OS source inside an isolated git worktree, runs a no-deploy verify build, shows a diff for human approval, and auto-rolls-back if the live build fails. Nothing reaches the live OS without an approved diff.

07

QA harness — how "done" is proven

verify/verify-os.mjs

Loads the live OS in installed Chrome (playwright-core), blocks the service worker + backend-sync endpoint for a deterministic test, and runs 19 feature checks: cards render/edit/delete, leads, venues, preview, thumbnails, search narrows/empties/resets, filter options, lightbox, library/vision/outreach content, and deploy freshness.

exit 0
PASS — only report done on this
exit 1
OS BUG — read errors/failedChecks, fix build.py, rebuild, re-run
exit 2
CAN'T RUN — Chrome/DINA/harness issue, not an OS bug; don't edit source
Also present
  • verify-tenant-gate.mjs — multi-tenant isolation checks (does tenant B ever see owner data).
  • Screenshot artifact at ~/.awesome-link-work/operator/verify-latest.png.
  • Output is JSON: {outcome, errors, failedChecks, checks, views}.

This harness is the Operator's only "eyes" — a "done" without a green verify is the #1 historical cause of "said done but it's broken."

08

Pre-launch checklist — what must close

Synthesized from TODO.md, BUILD_PLAN.md, and the live probe above. Ordered by severity. "Owner" = only Mostafa can do it; "Eng" = the engineer.

Blocker Security / hygiene Product / ship Legal / infra / later
B1
🏁 One real brief, end-to-end — the proof gate
Blocker
Push ONE real agency brief through brief → ✨ AI autofill → matched crew + locations + € wedge → generated proposal → passcode-gated pricing, and confirm a clean send-ready round-trip. This is the single open Bid Engine task; passing it once closes it for good. A headless dry-run passed; only a logged-in run can prove the AI-autofill leg.
Needs: Owner to send a brief · Eng to run + verify
B2
⭐ Path B architecture decision (explicit "before launch" instruction)
Blocker
Re-evaluate keeping the current static-frontend + separate-backend split (Path A) vs. rebuilding the OS UI as React components inside the Next.js app (one full-stack codebase, drop the "DINA" name). Weigh two-codebase maintenance burden against the cost of re-implementing 18 modules + voice + galleries. Mostafa's standing instruction is that this review is not skipped at launch. Recommendation to form: ship on Path A, schedule Path B as a post-launch migration — a rewrite on the eve of launch is the higher risk.
Needs: Eng recommendation → Owner sign-off
B3
Make the public tunnel boot-persistent
Blocker
sudo cloudflared service install <token> so a Mac reboot doesn't silently drop os.awesomelinkfilms.com. Until this lands, public access is one reboot from down.
Needs: Owner (sudo) · Eng to prepare
S1
Scrub residual literals from build.py
Hygiene
Remove/parameterize the hardcoded partner email (marton@spacemediafilms.com) and company Tax ID / CR numbers so a leaked index.html is genuinely empty. Then rebuild + verify-os exit 0.
Needs: Eng
S2
Anthropic spend cap + billing alert
Hygiene
Set a monthly cap in the Anthropic Console to bound damage if the API key leaks. ~1 min.
Needs: Owner
S3
FileVault recovery key stored off-laptop
Hygiene
Confirm the recovery key lives in a password manager / printed / off-device — not only on the machine it unlocks.
Needs: Owner
P1
Ship the multi-tenant pilot + CF-Pages bid deploy
Product
Auth v2, contacts/clients tabs, pulse widgets, PPTX round-trip and onboarding are done. Remaining: the Cloudflare-Pages bid deploy path (blocked on a CF API token) and the knowledge flip, then the Phase-C ship.
Needs: Owner CF token · Eng to wire
P2
WhatsApp integration for data harvest
Product
Flagged important in TODO.md and still open — harvesting contact/thread data into the OS. Scope + decide in/out of the launch cut.
Needs: Eng scope → Owner decision
P3
Deliberate model-refresh pass
Product
Review the pinned claude-sonnet-4-6 calls against the current Sonnet 5 family; upgrade where quality/latency/cost warrant, re-run the affected flows.
Needs: Eng
L1
Trademark + NDA
Legal
Trademark "The Awesome Link Films" / "Awesome Link"; have partners/contractors sign a mutual NDA before OS demos.
Needs: Owner
L2
Off-laptop always-on host (Railway pivot)
Infra
The OS is local-by-design and needs the Mac awake. The productized, always-on path is DINA on Railway (persistent disk) — start:cloud + Dockerfile/railway.json are already staged. Blocked on Mostafa creating a Railway account.
Needs: Owner account · Eng to deploy
L3
Dev-host thermal risk
Infra
The 2017 MacBook Pro (2-core, 8 GB) throttles under load and is the current single point of failure for the live OS. Not a code fix — hardware service or migration to L2's host retires it.
Needs: Owner
09

First 30 minutes for the engineer

  1. Read §1. Internalize: edit build.py (not index.html); after backend edits, pnpm build + dina-restart.sh.
  2. Confirm the server is live: curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:3737/os/index.html200.
  3. Open the OS, log in, and click through all 18 modules to build a mental model of the surface.
  4. Run node verify/verify-os.mjs and read the JSON — this is your ground truth for "healthy."
  5. Skim lib/auth.ts, lib/alOsData.ts, and one API route end-to-end to see the auth → data pattern.
  6. Start on B1 / B3 / S1 — the highest-leverage, lowest-ambiguity items.

Durable business facts, decisions, and standing rules live in the Obsidian vault at ~/claude/brain (start at Home.md). The build rules also live in ~/claude/CLAUDE.md.