Skip to content

Cloud API and Job Management

tonythethompson edited this page Jul 28, 2026 · 3 revisions

Portal API (api.trackdub)

The portal API is a Cloudflare Worker (Hono + Better Auth + D1 + Drizzle). It owns authentication, authorization, and HTTP routing for the portal SPA. It does not run the .NET dubbing pipeline.

Current scope (PR1): auth, health, version, languages, and cross-cutting middleware. Dubs, billing, API keys, and webhooks are not implemented yet.

There is no current Trackdub.Api C# project, SQS job queue, DynamoDB job store, or Fargate worker in the shipping product. Those designs lived in the monorepo archive only.

Architecture

flowchart LR
    Portal[portal.trackdub.com SPA] -->|credentials include| Worker[api.trackdub Worker]
    Worker --> Auth[Better Auth]
    Worker --> D1[(Cloudflare D1)]
    Worker -.->|reserved| R2[(R2 MEDIA)]
Loading
Piece Role
Hono Worker (src/index.ts) Middleware chain + route mounting
Better Auth Email/password, invite-only signup, host-only session cookies
D1 + Drizzle SQLite-backed auth/schema; migrations via Drizzle Kit / Wrangler
R2 MEDIA binding Reserved for later media work (unused in PR1)
Zod Config and request validation

Portal calls the Worker with credentials: "include". The Worker remains the authorization boundary; portal route guards are UX only.

Shipped routes (PR1)

Area Notes
/api/health Liveness
/api/version Build metadata
Languages Static language list
Better Auth endpoints Sign-in / session / password flows
/api/admin/invite Invite-only user bootstrap (ADMIN_API_TOKEN)

Local development

git clone https://github.com/trackdubllc/api.trackdub.git
cd api.trackdub
npm install
cp .dev.vars.example .dev.vars
npm run db:migrate:local
npm run dev
npm test

Config is validated on first request (src/config/env.ts). Missing secrets fail fast without leaking values.

Deploy (summary)

  1. Create D1 + R2; paste ids into wrangler.jsonc
  2. wrangler secret put BETTER_AUTH_SECRET and ADMIN_API_TOKEN
  3. npm run db:migrate:remote
  4. npm run deploy
  5. Verify GET https://api.trackdub.com/api/health

Full procedure: README · Cloud-Infrastructure-Deployment.

Job / dub pipeline status

Not shipped. When cloud dubs land, document them here against the Worker contract. Local/headless dubbing today is Pipeline-Orchestration via Sdk, Cli, or the desktop app.

Related

Clone this wiki locally