Development
Repository layout
AI_Marketing_Studio/
├── web/ # ★ the v2 app (Next.js 14) — studio, Director, renderer
│ ├── src/
│ │ ├── app/ # App Router: page.tsx (editor), (shell)/{email,svg,settings},
│ │ │ │ # login/, and api/ route handlers
│ │ │ └── api/ # director/* · media/[...path] · assets · assets/upload
│ │ ├── components/ # StudioV2, DirectorPanel, ReviewPanel, DeliverPanel,
│ │ │ │ # ChatPanel, TimelineV2, inspector/, intake/
│ │ ├── director/ # the AI engine: orchestrator, roles, runner, llm/, store/,
│ │ │ │ # assemble, catalog, voiceover, docextract
│ │ ├── document/ # irStore.ts (Zustand IR + undo/redo), chatStore.ts
│ │ ├── lib/ # storage.ts (STORAGE_ROOT map), remotion bundle helpers
│ │ ├── legacy/ # ported v1 pages (EmailFlyer, SvgGen, Settings, Login)
│ │ └── middleware.ts # auth gate (validates via Express /api/auth/me)
│ └── remotion/
│ ├── Root.tsx # registers StudioDoc + every blueprint as a Composition
│ ├── index.ts # render-bundler entry
│ ├── document/ # ir.ts, blueprint.ts, registry.ts, VideoDocument.tsx,
│ │ │ # SceneShell.tsx, timing.ts, assets.tsx, blueprints/
│ └── templates/modules # 216 template modules (X.tsx + X.module.ts)
├── server/ # Express API (auth, email, svg, settings, brand) — v1 kept
│ └── src/{routes,pipeline,middleware} # paths.ts derives dirs from STORAGE_ROOT
├── packages/ # @dexian/* workspace libs (back the Express features)
├── storage/ # file-backed data (projects, media, renders) — dev
├── docs/ # design docs + plans
├── Wikki/ # this wiki (mkdocs-material)
├── Dockerfile · docker-compose.yml · docker-start.sh
└── .github/workflows/ # deploy-acr.yml
Local dev loop
npm install # root workspaces (server + packages/*)
cd web && npm install # the Next.js app (separate node_modules)
cd ..
# put Azure keys + JWT_SECRET/ALLOWED_USERS in a repo-root .env
npm run dev # Express :3001 + Next.js :3000
npm run dev frees stale ports, then runs dev:server (builds @dexian/*, then ts-node-dev for Express) and dev:web (next dev with EXPRESS_ORIGIN=http://localhost:3001) concurrently. Open http://localhost:3000.
WSL note: npm isn't available in some WSL setups —
web/node_modulesmay be a local copy andnode/tscrun from Git Bash. See the team's WSL gotchas memo if a build step can't find npm.
Common tasks
Add a template module
- Create
web/remotion/templates/modules/MyScene.tsx(the view) +MyScene.module.ts(Zod schema + metadata) - Hand-edit the barrel
templates/modules/index.ts(one import + oneALL_MODULESentry — no generator script) - Add
presets/MyScene.jsonwith demo props (validated against the schema) cd web && npm run typecheck
Add a blueprint (whole-video starter)
- Create
web/remotion/document/blueprints/myThing.ts, modeled onsaasLaunch.ts - Export a
VideoBlueprint+ a resolvedir - Register it in
blueprints/index.tsBLUEPRINTS[]—Root.tsxauto-maps it to a Composition
Add an app page
- Add a route under
web/src/app/(App Router). Authenticated pages go under(shell)/or useAuthGuard. - Add a nav entry in
web/src/components/NavLinks.tsx - If it needs a backend, add a handler under
web/src/app/api/(or proxy to Express vianext.configrewrites)
Add a Director capability
The engine is web/src/director/. The two LLM roles (Analyst, Copywriter) sit behind roles.ts with llmRoleRunner and stubRoleRunner implementations; runner.ts picks based on Azure config. Keep new behavior working under the stub path so the system runs offline.
Work on the legacy Express features
Email/SVG/brand pipelines live in server/src/. Build the @dexian/* packages first (npm run build:workspace-libs). These are reached through the Next.js proxy in dev and prod.
Type checking
Style & conventions
- TypeScript strict mode across
web/,server/, andpackages/ - The
ResolvedIRis the single source of truth — mutate it through theirStoreactions, never out of band - Template modules are pure, data-driven views validated by Zod — no side effects, no AI at render time
- New AI behavior must degrade gracefully to the stub runner
- Don't edit
packages/templates/src/video/— it's the retired v1 template system
Design docs
Significant changes get a doc under docs/ first. Relevant current ones:
migration-plan-design.md/v2-gaps-and-risks.md— the v1 → v2 merge and its open risksstorage-and-azure-mounts.md— the single-share storage modeldirector-agent-design.md— the Director enginerender-unification-plan.md— preview = render parity (the principle the v2 system inherits)
Editing this wiki
npm run wiki:dev # live-reload mkdocs at http://localhost:8000
npm run wiki:build # static build to Wikki/site/
Pages live under Wikki/docs/; nav is configured in Wikki/mkdocs.yml.