Engineering Partner Onboarding
Artifacts for bringing an engineering partner up to speed on Timed Trading. Prefer accuracy over polish; unknowns are marked.
Repo sources of truth (do not duplicate wholesale):
| Doc | Why |
|---|---|
AGENTS.md | Onboarding contract, house rules, local Cloud tips |
CONTEXT.md | Stack, journey pages, condensed lessons |
skills/README.md | How-to index |
skills/worker-topology.md | Cron / role ownership |
skills/deploy.md | Deploy decision tree; merge ≠ deploy |
skills/security-auth-patterns.md | Route / WS / tier gating |
skills/partner-onboarding.md | Broker partner isolation (product partners) |
skills/user-state-matrix.md | Pro / VIP / Member / Admin states |
.cursor/rules/price-data-pipeline.mdc | Price KV + freshness invariants |
1. System architecture
Rendered diagram
Flow (text)
Clients (Browser → CF Access → Stripe)
│
▼
Cloudflare Pages (react-app-dist/ + _worker.js)
│ proxy /timed/*
▼
timed-trading-ingest (worker/) — ALL /timed/* · DOs · fallback crons
│
┌────┼────────────────────┐
▼ ▼ ▼
tt-feed tt-engine tt-research (same bundle, role-gated)
│ │ │
└────┬────┴────────────────┘
▼
D1 + KV (+ PriceStream WS → TwelveData; PriceHub → Browser)
tt-broker-bridge (worker-bridge/) ← /timed/broker/* session owner
│
Alpaca / IBKR / Webull / Robinhood / E*TRADE scaffold
External: TwelveData · Discord · SendGrid / OpenAI · Stripe
Component cheat sheet
| Piece | Script / path | Notes |
|---|---|---|
| Main API | timed-trading-ingest ← worker/ | Only place that owns DO classes/migrations |
| Feed | tt-feed ← worker-feed/ | After cutover: price feed + keep-alive |
| Engine | tt-engine ← worker-engine/ | */5 scoring + trade lanes |
| Research | tt-research ← worker-research/ | Hourly arms + 22:00 UTC batch |
| Bridge | tt-broker-bridge ← worker-bridge/ | Sidecar; no end-user CF Access auth |
| Frontend | Pages ← react-app-dist/ | Independent deploy from workers |
| Quotes | TwelveData (+ Alpaca fallback/exec) | Native change fields preferred |
| Alerts | Discord | See skills/discord-alerts.md |
| Billing / SSO | Stripe + CF Access | See user-state-matrix + billing skill |
Unknown until checked in dashboard/prod: which *_EXTERNAL / *_ENABLED flag pairs are currently live. Do not assume cutover state from docs alone — probe health / Cloudflare vars.
2. Newcomer material (summary)
The full day-1 / first-week guide lives in the newcomer guide. It covers:
- Repo map (
worker/, role dirs,react-app,skills,tasks) - Topology table and cutover / binding-parity rules
- Local run,
.dev.vars, Pages vs worker proxy - Auth tiers in brief
- Price invariants in brief
- Skills index pointers + house rules + first-week checklist
Reading path for a new senior engineer:
AGENTS.md → CONTEXT.md (Stack/Deploy) → skills/README.md → skills/worker-topology.md → skills/deploy.md → this pack’s architecture section.
3. Deploy topology (partner-facing)
| Change | Deploy |
|---|---|
worker/** (shared logic) | Monolith both envs and tt-engine + tt-research |
worker/feed/** | tt-feed as well |
worker-bridge/** | Bridge worker only |
react-app/** | npm run build:frontend, commit dist, push main (Pages) |
CI workflows (path-filtered): deploy-worker.yml, deploy-feed.yml, deploy-engine.yml, deploy-research.yml.
A merge is not a deploy. Verify Cloudflare version dates or /timed/health deployedSha. Stamp ENGINE_GIT_SHA on hand deploys. Details: skills/deploy.md.
4. Auth, tiers, security boundaries
Entitlements
| Who | Live prices + scores |
|---|---|
| Pro / VIP / Admin | Yes |
Member (free) / anon | No — redacted |
Server gate: canAccessLivePrices() / redactTickerMapForTier(). UI: window._ttIsPro. Canonical states: skills/user-state-matrix.md.
Route / trust boundaries
| Boundary | Rule |
|---|---|
| Mutating admin routes | requireKeyOrAdmin (+ destructive confirm when irreversible) |
| Licensed market data | Server-side tier redact; cache keys include tier bucket |
| CF Access JWT | Fail closed (verifyAccessJWT); no “degrade gracefully” on assertion headers |
| API key | Prefer X-API-Key; ?key= deprecated |
| WebSockets | Ticket flow: /timed/ws-ticket then ?ticket= (browsers can’t set upgrade headers) |
| Broker bridge | Browser never hits bridge directly; /timed/broker/* stamps owner from session email |
| LLM HTML | Sanitize (DOMPurify); treat model output as untrusted |
Full patterns: skills/security-auth-patterns.md. Broker tenant isolation: skills/partner-onboarding.md.
Discord / Stripe / Access (placement)
- Discord: outbound alerts from the main worker (and related crons); debug via
skills/discord-alerts.md. - Stripe: Checkout + webhooks on the main worker; VIP code grants and billing reconciliation have dedicated helpers — see
skills/billing-and-sales-tax.md. - CF Access: gates authenticated HTML; User Pages policy regex must list every authenticated page (CONTEXT notes this).
5. Price pipeline invariants (pointer sheet)
Do not re-implement. Read .cursor/rules/price-data-pipeline.mdc and CONTEXT lessons tagged PriceStream / q_ts.
Non-negotiables for a partner touching feed or UI prices:
- TwelveData primary; parse native quote change fields (
parseTdQuote). - Client daily change only via
getDailyChange(t)inshared-price-utils.js. - Every
timed:priceswriter stampsq_ts+p_tsand never regresses them. - Freshness / health use value stamps, not blob
t. - PriceStream DO ownership of symbols in
timed:prices(orphan clobber risk under KV lag). - Session-aware EXT fields: no AH writes during RTH; preserve closed-session day/EXT appropriately.
- Licensing footer: “Market data powered by Twelve Data”.
6. Skills index (common tasks)
| Situation | Skill |
|---|---|
| Deploy / verify live | skills/deploy.md |
| Which worker / cron | skills/worker-topology.md |
| Rescore one ticker | skills/rescore-ticker.md |
| Snapshot / universe | skills/all-snapshot.md |
| D1 / KV | skills/d1-debugging.md, skills/kv-inspection.md |
| HTTP codes | skills/debug-http-codes.md |
| New route / WS | skills/security-auth-patterns.md |
| Broker automation | skills/broker-bridge.md |
| Onboard a trading partner (Webull mirror) | skills/partner-onboarding.md |
| Frontend build | skills/frontend-build.md |
| Holistic smoke | skills/mc-holistic-smoke-test.md |
Complete list: skills/README.md.
7. Partner onboarding checklist
Use this when an engineering partner joins (code access). For a broker-mirror product partner, use skills/partner-onboarding.md instead (different isolation model).
Access & tooling
- Repo read/write (or PR) access; Cloudflare visibility as needed (Workers, Pages, D1, KV) — operator grants; do not invent IAM
- Local Node 22 +
npm install; wrangler via./node_modules/.bin/wrangler - Understanding that Cloud VMs may lack CF Access browser login — API key path for local API work
- Secrets never committed:
worker/.dev.vars, bridge secrets, Stripe / TwelveData / Discord tokens
Engineering ramp
- Completed newcomer guide Day 1–5 checklist
- Can name the five Worker scripts and what Pages serves
- Can explain Pages vs Worker deploy independence
- Can explain Member vs Pro vs VIP vs Admin for price/score gating
- Knows where to find skills before inventing a procedure
First production-adjacent change
- Touches the correct deploy surface(s) per
skills/deploy.md - Runs
bash scripts/check-branch-merge-state.shbefore pushing an existing branch - Verifies live behavior (health / route string / UI), not only green CI
- Updates lessons/CONTEXT if the operator corrects an assumption
Security review before self-serve prod writes
- No unguarded mutating
/timed/*routes - No browser→bridge shortcuts; no
ownertaken from client input on broker routes - No licensed data leaked to Member/anon caches
- No emoji in commits/PRs; no “you/your” in user-facing product copy
8. Files in this pack
| File | Role |
|---|---|
newcomer.html (from docs/newcomer-repo-workers-guide.md) | Primary day-1 / first-week guide |
This page (from docs/engineering-partner-onboarding.md) | Architecture + partner checklist |
assets/system-architecture.svg | Architecture visual |
Changelog
- 2026-09-29 — Initial pack; newcomer guide split out as front door per founder priority.
- 2026-09-29 — Responsive HTML conversion under
docs/web/.