Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
474 lines
38 KiB
Markdown
474 lines
38 KiB
Markdown
# ReelForge — Product Blueprint (Authoritative Full-Product File Plan)
|
||
|
||
> The single **authoritative, end-to-end directory + file plan** for ReelForge as it goes
|
||
> from shipped MVP to full enterprise product. This doc is the map of **what exists today**
|
||
> and **every planned file** across `app/`, `web/`, `mobile/`, `migrations/`, `docker/`,
|
||
> `resource/`, and `docs/` — grouped by the 10 enterprise epics, each forked from a
|
||
> verified MIT/Apache OSS foundation.
|
||
>
|
||
> Companions (cross-linked, each the deep-dive for its slice):
|
||
> - [`REPO_STRUCTURE.md`](./REPO_STRUCTURE.md) — the repo **as it is today** + the additive new-file convention (the rulebook this doc obeys).
|
||
> - [`ROADMAP_V2.md`](./ROADMAP_V2.md) — phased forward roadmap and honest current-state read.
|
||
> - [`RESEARCH_ENTERPRISE_OSS.md`](./RESEARCH_ENTERPRISE_OSS.md) — the epic → OSS-foundation mapping (licenses, why each pick).
|
||
> - [`ARCHITECTURE_NEXT.md`](./ARCHITECTURE_NEXT.md) — the runtime target the file plan lands into.
|
||
> - Data/ops companion (planned): `INFRA_DATA_OPS.md`; schema in [`DATA_MODEL.md`](./DATA_MODEL.md); config in [`CONFIG.md`](./CONFIG.md).
|
||
|
||
---
|
||
|
||
## 1. TL;DR — the full product at a glance
|
||
|
||
**Where we are.** ReelForge is a shipped fork of MoneyPrinterTurbo. The render DAG
|
||
(`script → tts → {avatar ∥ captions} → compose → upload`) is real, retryable code, not a demo.
|
||
Backend is Python/FastAPI + Celery/Redis (`app/`, ~131 `.py`), web is Next.js 15 (`web/`, ~246 `.ts/.tsx`),
|
||
mobile is Expo (`mobile/`), data is Neon Postgres via a single linear Alembic chain (head **`f1a2b3c4d5e6`**,
|
||
`identity_sso_scim`), assets on Cloudflare R2, auth via Clerk. **The suite is 1924 green.**
|
||
|
||
**What's shipped:** the render pipeline (script/tts/avatar/captions/compose), creator analytics,
|
||
template marketplace (+ remix trees + win-score ranking), the hook-performance loop feeding the
|
||
Spark idea engine, per-API-key quotas + rate limits, OAuth direct-publish, referrals, team
|
||
workspaces, scheduled + calendar publishing, music, covers, brand kits, public share pages,
|
||
creator profiles/leaderboards, editing polish (auto-tighten/zoom/motion/matting), and
|
||
**Epic 1 — Access & Governance** (pycasbin RBAC + refine admin console + append-only audit + `is_staff`).
|
||
**Epic 2 — Identity/SSO** (SAML/OIDC/SCIM/MFA) is in-flight: its tables are migrated; the
|
||
service + controllers are landing now.
|
||
|
||
**Where we're going — the 10-epic enterprise program**, each forked from a verified MIT/Apache OSS foundation:
|
||
|
||
| # | Epic | OSS foundation (license) | Status |
|
||
|---|------|--------------------------|--------|
|
||
| 1 | Access & Governance | pycasbin (Apache-2.0) + refine (MIT) | ✅ DONE |
|
||
| 2 | Identity / SSO / SCIM / MFA | Ory Polis / python3-saml (Apache-2.0) | 🔵 IN-FLIGHT |
|
||
| 3 | Billing platform | OpenMeter (Apache-2.0) + Kill Bill (Apache-2.0) | ⚪ planned |
|
||
| 4 | API platform + SDKs | Svix (MIT) + Scalar (MIT) + openapi-generator (Apache-2.0) | ⚪ planned |
|
||
| 5 | Compliance (GDPR/retention) | Neon append-only + Cerbos/OpenFGA decision logs (Apache-2.0) | ⚪ planned |
|
||
| 6 | Observability | OpenTelemetry (Apache-2.0) → VictoriaMetrics/SigNoz | ⚪ planned |
|
||
| 7 | Notifications | Novu (MIT) + apprise (BSD-2) fallback | ⚪ planned |
|
||
| 8 | Feature flags / experiments | OpenFeature (Apache-2.0) + Flagsmith (BSD-3) / flagd | ⚪ planned |
|
||
| 9 | Workflow orchestration | Hatchet (MIT) + Temporal (MIT) alt | ⚪ planned |
|
||
| 10 | BI / analytics pipeline | Cube (Apache-2.0) + PostHog (MIT) | ⚪ planned |
|
||
|
||
**Honest note on file counts.** The **~600 planned new files** tallied in this doc are a
|
||
**byproduct of real capabilities**, not a target. Each planned file maps to exactly one concrete
|
||
seam: a provider behind a Protocol, a DTO group, a table's repo, an endpoint group, a worker queue,
|
||
a screen, a config form, or a doc. Where an epic needs only one screen it gets one file; where it
|
||
needs an ops console + a tenant self-serve surface + a public surface it gets three trees. We
|
||
**keep every existing file in place** (the 1924-green suite must not move for structural reasons),
|
||
**add new work by the [`REPO_STRUCTURE.md`](./REPO_STRUCTURE.md) convention**, and **fork proven
|
||
MIT/Apache foundations** rather than hand-roll. The count follows the capability; the capability
|
||
never follows the count.
|
||
|
||
---
|
||
|
||
## 2. The complete annotated target tree
|
||
|
||
Legend: `[E]` exists today · `[+]` planned-new file · `[~]` existing **append-point** that grows
|
||
(never forked) · `[N]` planned, belongs to Epic N.
|
||
|
||
### 2.1 `app/` — backend (FastAPI + Celery)
|
||
|
||
```
|
||
app/
|
||
├── asgi.py [~] app factory — mount Scalar docs [4], instrument_app() [6]
|
||
├── router.py [~] APPEND-POINT: one include_router() per new controller
|
||
├── config/config.py [~] TOML/env loader — append [sso][openmeter][svix]… sections
|
||
│
|
||
├── core/
|
||
│ ├── clerk.py [E] Clerk JWT → User bridge
|
||
│ ├── authz.py [+1] request-scoped require_permission() dep + fastapi-authz bridge
|
||
│ └── flags.py [+8] request-scoped is_enabled()/get_variant() dep
|
||
│
|
||
├── controllers/v1/ # each: new_router() + x-api-key→User + utils.get_response
|
||
│ ├── base.py video.py llm.py jobs.py studio.py billing.py catalog.py me.py [E]
|
||
│ ├── voices.py ideas.py notifications.py schedule.py covers.py workspaces.py [E]
|
||
│ ├── brand.py social.py api_keys.py analytics.py marketplace.py performance.py [E]
|
||
│ ├── connections.py share.py creators.py calendar.py [E]
|
||
│ ├── rbac.py audit.py admin.py [E1] governance
|
||
│ ├── sso.py scim.py [+2]
|
||
│ ├── metering.py entitlements.py invoices.py [+3]
|
||
│ ├── webhooks.py apiplatform.py [+4]
|
||
│ ├── compliance.py privacy.py [+5]
|
||
│ ├── health.py slo.py [+6]
|
||
│ ├── notify.py notification_prefs.py [+7]
|
||
│ ├── flags.py experiments.py [+8]
|
||
│ ├── workflows.py [+9]
|
||
│ └── bi.py events.py [+10]
|
||
│
|
||
├── models/
|
||
│ ├── schema.py [~] APPEND-POINT: ALL Pydantic DTOs (per-epic DTO groups)
|
||
│ └── db/
|
||
│ ├── models.py [~] APPEND-POINT: ORM tables (per-epic, ~26 new)
|
||
│ └── repositories.py [~] APPEND-POINT: XRepository per new table
|
||
│
|
||
├── services/
|
||
│ ├── reelforge.py [~] APPEND-POINT: ReelForgeParams + pure stage transforms
|
||
│ ├── task.py video.py material.py subtitle.py preview.py templates.py … [E] core pipeline
|
||
│ ├── voice.py tts/ transcribe.py translate.py [E] voice/tts
|
||
│ ├── avatar/ base.py heygen.py latentsync_runpod.py [E] (Protocol seam)
|
||
│ │ + did.py runway.py kling.py veo.py [+] new providers
|
||
│ ├── captions/ compose/ editing/ broll.py bgm.py music.py cover.py … [E] media/edit
|
||
│ │ + editing/color_grade.py editing/beat_sync.py [+] new transforms
|
||
│ ├── billing/ __init__.py service.py plans.py stripe_client.py iyzico_client.py [E]
|
||
│ │ creem_client.py polar_client.py apikey_quota.py [E]
|
||
│ │ + paddle_client.py lemonsqueezy_client.py [+3] providers
|
||
│ │ + entitlements.py invoices.py dunning.py killbill_client.py [+3]
|
||
│ ├── publishing/ publish.py publishers/base.py publishers/tiktok.py … [E] (Protocol seam)
|
||
│ │ + publishers/{instagram,youtube,linkedin,x}.py [+] new publishers
|
||
│ ├── storage/ __init__.py r2.py [E]
|
||
│ │ + base.py s3.py gcs.py [+] storage Protocol
|
||
│ ├── rbac.py audit.py admin.py [E1]
|
||
│ ├── authz/ __init__.py casbin_engine.py cerbos_client.py openfga_client.py [+1] ReBAC graduation
|
||
│ ├── sso/ __init__.py base.py polis_client.py oidc.py saml.py scim.py [+2]
|
||
│ │ mfa.py keycloak_client.py
|
||
│ ├── metering/ __init__.py base.py openmeter_client.py events.py [+3]
|
||
│ ├── webhooks.py [E] completion hooks
|
||
│ ├── webhooks/ __init__.py base.py svix_client.py events.py signing.py [+4] (promote to subdir)
|
||
│ │ endpoints.py
|
||
│ ├── apiplatform/ scopes.py sdk_gen.py [+4]
|
||
│ ├── compliance/ __init__.py gdpr.py export_builder.py retention.py [+5]
|
||
│ │ consent.py decision_log.py legal_hold.py
|
||
│ ├── observability/ slo.py health.py [+6]
|
||
│ ├── notifications.py [E] in-app center
|
||
│ ├── notifications/ __init__.py base.py novu_client.py apprise_provider.py [+7] (promote to subdir)
|
||
│ │ preferences.py templates.py
|
||
│ │ channels/{email,sms,push,webhook,inapp}.py
|
||
│ ├── flags/ __init__.py base.py openfeature_client.py flagsmith_provider.py [+8]
|
||
│ │ flagd_provider.py
|
||
│ ├── experiments/ assignment.py [+8]
|
||
│ ├── workflows/ __init__.py base.py hatchet_client.py temporal_client.py [+9]
|
||
│ │ dags.py registry.py render_workflow.py
|
||
│ ├── bi/ __init__.py base.py cube_client.py posthog_client.py [+10]
|
||
│ │ event_pipeline.py warehouse.py
|
||
│ └── infra: cache_manager.py ratelimit.py version_checker.py crypto_tokens.py [E]
|
||
│
|
||
├── telemetry/
|
||
│ ├── cost.py events.py progress.py sentry.py [E]
|
||
│ └── otel.py tracing.py metrics.py instrumentation.py slo.py [+6]
|
||
│
|
||
├── utils/ file_security.py logging_utils.py utils.py [E]
|
||
│
|
||
└── workers/
|
||
├── celery_app.py [~] queues (celery,render,+ops,dispatch,billing) + beat grow
|
||
├── context.py pipeline.py [E]
|
||
├── tasks.py [~] APPEND-POINT: @celery_app.task stage/ops tasks per epic
|
||
├── metering.py [+3] webhooks.py [+4] compliance.py [+5]
|
||
├── notifications.py [+7] hatchet_bridge.py [+9] analytics.py [+10]
|
||
```
|
||
|
||
### 2.2 `web/` — Next.js 15 App Router (primary end-user + admin UI)
|
||
|
||
```
|
||
web/
|
||
├── middleware.ts [~] extend matchers: +/workflows /developer-portal /analytics
|
||
│ public: +/status /sso-login /(marketing)/{privacy,terms,dpa,security}
|
||
├── instrumentation.ts [+6] Next server OTel bootstrap
|
||
├── instrumentation-client.ts [+6] client OTel + web-vitals
|
||
├── next.config.mjs [~] instrumentationHook / OTel
|
||
├── public/sw.js [+7] web-push service worker
|
||
│
|
||
├── app/
|
||
│ ├── layout.tsx [~] mount TelemetryProvider[6] FeatureFlagProvider[8]
|
||
│ │ AnalyticsProvider[10] CookieConsentBanner[5] PushOptInBanner[7]
|
||
│ ├── (marketing)/ … pricing/ [E] + privacy/ terms/ dpa/ [5] security/ [6]
|
||
│ ├── status/page.tsx [+6] PUBLIC status/SLO/incidents
|
||
│ ├── sign-in/ sign-up/ [E] + sso-login/page.tsx [2] (SP domain entry)
|
||
│ ├── dashboard/ new/ jobs/[id]/ batch/[id]/ avatars/ voices/ presets/ ideas/ [E] core studio
|
||
│ │ brand/ marketplace/ performance/ insights/ calendar/ scheduled/ [E]
|
||
│ │ connections/ notifications/ referral/ usage/ team/ leaderboard/ [E]
|
||
│ │ creators/[handle]/ r/[token]/ [E] public surfaces
|
||
│ ├── billing/ page.tsx success/ cancel/ [E]
|
||
│ │ + plans/ invoices/ invoices/[id]/ usage/ payment-methods/ [+3]
|
||
│ ├── workflows/ page.tsx new/ [id]/ [+9]
|
||
│ ├── developer-portal/ layout.tsx page.tsx api-keys/ webhooks/ webhooks/[id]/ [+4]
|
||
│ │ api-reference/ sdks/ events/ logs/ playground/
|
||
│ ├── analytics/ page.tsx [E] + explore/ funnels/ retention/ events/ [+10]
|
||
│ │ dashboards/ dashboards/[id]/
|
||
│ ├── settings/ layout.tsx page.tsx general/ [core] enterprise shell
|
||
│ │ team/ audit/ api-keys/ [E] (RBAC/audit/keys)
|
||
│ │ sso/ scim/ domains/ security/ [+2]
|
||
│ │ billing/ [3] notifications/ [7] privacy/ compliance/ [5]
|
||
│ └── admin/ layout.tsx page.tsx users/ workspaces/ jobs/ [E] refine console
|
||
│ roles/ audit/ quotas/ marketplace/ [+1]
|
||
│ sso/ [2] billing/ subscriptions/ [3] webhooks/ api-usage/ [4]
|
||
│ data-requests/ retention/ [5] observability/ health/ slo/ [6]
|
||
│ notifications/ [7] flags/ flags/[key]/ experiments/ experiments/[id]/ [8]
|
||
│ workflows/ workflows/[runId]/ [9] events/ warehouse/ [10]
|
||
│
|
||
├── components/ # existing groups kept: admin analytics apikeys avatars batch
|
||
│ │ billing brand broll calendar connections cover creators dub ideas insights jobs
|
||
│ │ marketing marketplace notifications performance presets referral schedule settings
|
||
│ │ share social team ui usage voiceover voices wizard [E]
|
||
│ ├── sso/ security/ [+2] (SsoConfigForm, ScimTokenPanel, MfaEnrollment, …)
|
||
│ ├── billing/ (extend) [+3] (InvoiceTable, UsageMeterPanel, PlanComparison, …)
|
||
│ ├── developer/ webhooks/ [+4] (ApiReferenceEmbed, WebhookEndpointList, …)
|
||
│ ├── compliance/ [+5] (DataExportPanel, DsarRequestTable, ConsentManager, …)
|
||
│ ├── observability/ status/ [+6] (HealthDashboard, SloBurnChart, StatusHeader, …)
|
||
│ ├── notifications/ (extend) [+7] (NotificationPreferences, ChannelMatrix, TemplateEditor, …)
|
||
│ ├── flags/ experiments/ [+8] (FeatureFlagProvider, FlagRuleEditor, ExperimentResultsPanel, …)
|
||
│ ├── workflows/ [+9] (WorkflowBuilder, RunTimeline, RetryPanel, …)
|
||
│ ├── bi/ [+10] (QueryBuilder, DashboardGrid, FunnelBuilder, …)
|
||
│ ├── settings/ (extend) [core] (SettingsNav, OrgSwitcher)
|
||
│ ├── admin/ (extend) [+1] (PolicyEditor, RoleMatrix, QuotaOverrideForm, …)
|
||
│ └── ui/ (extend primitives) [core] (dialog, tabs, table, switch, slider, tooltip, toast, code-block)
|
||
│
|
||
└── lib/ api.ts types.ts utils.ts refine/data-provider.ts refine/access-control.ts [~] grow per epic
|
||
+ refine/resources.ts [1] sso.ts [2] billing.ts [3] webhooks.ts openapi.ts [4]
|
||
compliance.ts [5] observability.ts telemetry.ts [6] notifications.ts push.ts [7]
|
||
feature-flags.ts use-flag.ts experiments.ts [8] workflows.ts [9] bi.ts cube-client.ts analytics-track.ts [10]
|
||
```
|
||
|
||
### 2.3 `mobile/` — Expo Router (consumption + light management)
|
||
|
||
Mobile mirrors the highest-value self-serve surfaces; heavy authoring/ops (workflow builder,
|
||
BI query builder, refine console, SDK downloads, OpenAPI viewer) stay web-only.
|
||
|
||
```
|
||
mobile/
|
||
├── app/
|
||
│ ├── _layout.tsx index.tsx (tabs)/{create,jobs,me} [E] + mount providers [6][8][10]
|
||
│ ├── job/[id] avatars voices ideas brand marketplace performance analytics [E]
|
||
│ │ calendar scheduled connections notifications usage team team-roles [E]
|
||
│ │ leaderboard creator/[id] api-keys [E]
|
||
│ ├── settings.tsx [core] hub
|
||
│ ├── sso.tsx security.tsx [+2]
|
||
│ ├── billing.tsx invoices.tsx invoice/[id].tsx [+3]
|
||
│ ├── developer.tsx webhooks.tsx webhook/[id].tsx [+4]
|
||
│ ├── privacy.tsx [+5] status.tsx [+6]
|
||
│ ├── notification-preferences.tsx [+7]
|
||
│ ├── workflows.tsx workflow/[id].tsx [+9] dashboards.tsx dashboard/[id].tsx [+10]
|
||
│ └── admin.tsx [1] flags.tsx [8] (staff-on-mobile light ops)
|
||
│
|
||
├── components/ # existing groups kept (analytics apikeys avatars billing brand broll calendar
|
||
│ │ connections cover create creators dub ideas job marketplace me notifications performance
|
||
│ │ schedule share social team usage voiceover voices) [E]
|
||
│ ├── settings/ [core] sso/ security/ [+2] billing/(extend) [+3] developer/ [+4]
|
||
│ ├── compliance/ [+5] status/ observability/ [+6] notifications/(extend) [+7]
|
||
│ ├── flags/ [+8] workflows/ [+9] bi/ [+10] admin/ [+1]
|
||
│
|
||
└── lib/ api.ts types.ts session.ts calendar.ts job-media.ts job-status.ts pick-*.ts [~] grow per epic
|
||
+ sso.ts [2] billing.ts [3] webhooks.ts [4] compliance.ts [5] telemetry.ts [6]
|
||
notifications.ts [7] feature-flags.ts [8] workflows.ts [9] bi.ts analytics-track.ts [10]
|
||
```
|
||
|
||
### 2.4 `migrations/` — single linear Alembic chain (head `f1a2b3c4d5e6`)
|
||
|
||
```
|
||
migrations/versions/
|
||
├── … e5f2a9c74b13_access_governance_rbac_audit.py [E1]
|
||
├── … f1a2b3c4d5e6_identity_sso_scim.py [E2] ← current HEAD (down_revision anchor)
|
||
├── <ts>_<rev>_identity_scim_sync_mfa.py [+2]
|
||
├── <ts>_<rev>_billing_metering_entitlements.py [+3]
|
||
├── <ts>_<rev>_billing_invoices_dunning.py [+3]
|
||
├── <ts>_<rev>_api_platform_webhooks_scopes.py [+4]
|
||
├── <ts>_<rev>_compliance_gdpr_retention_consent.py [+5]
|
||
├── <ts>_<rev>_observability_slo_targets.py [+6]
|
||
├── <ts>_<rev>_notifications_multichannel_prefs.py [+7]
|
||
├── <ts>_<rev>_feature_flags_experiments.py [+8]
|
||
├── <ts>_<rev>_workflow_orchestration_runs.py [+9]
|
||
└── <ts>_<rev>_bi_analytics_event_pipeline.py [+10]
|
||
```
|
||
|
||
Chain rule preserved: each `down_revision` = prior head; **no branches/merges**. Every new column
|
||
carries a `server_default` (additive, zero autogenerate drift). Secrets stored **only** as Fernet
|
||
blobs (`*_enc`, keyed by `SOCIAL_TOKEN_KEY` via `crypto_tokens.py`) or SHA-256 digests (`*_hash`).
|
||
|
||
### 2.5 `docker/`, config, gate
|
||
|
||
```
|
||
docker/
|
||
├── worker-entrypoint.sh [E]
|
||
├── otel/otel-collector-config.yaml [+6] (collector in the BASE stack)
|
||
├── otel/victoriametrics|signoz/ [+6] store config
|
||
├── cube/schema/*.js cube.env [+10]
|
||
├── flagd/flags.json [+8] flags-as-code path
|
||
└── compose/ [+] per-epic overlays (profiles)
|
||
├── observability.yml [6] sso.yml [2] billing.yml [3] webhooks.yml [4]
|
||
└── notifications.yml [7] flags.yml [8] workflows.yml [9] analytics.yml [10]
|
||
|
||
docker-compose.reelforge.yml [~] core: redis+api+worker+beat (+otel-collector); add compose profiles
|
||
Dockerfile / Dockerfile.gpu [E] base + GPU (LatentSync/RunPod Tier-B) — KEEP
|
||
config.toml / config.example.toml [~] append [sso][scim][openmeter][killbill][svix][scalar]
|
||
[compliance][otel][slo][novu][flags][hatchet][cube][posthog]
|
||
.env.reelforge.example [~] append per-epic secret keys (SOCIAL_TOKEN_KEY = platform key)
|
||
Makefile.reelforge [~] add openapi/sdk/typecheck/security/coverage/migrate-check/otel-up/check
|
||
```
|
||
|
||
### 2.6 `resource/`, `tests/`, `docs/`
|
||
|
||
```
|
||
resource/ fonts/ songs/ hooks/ voices.yaml [E] KEEP — load-bearing
|
||
storage/ [E] runtime-only (gitignored)
|
||
tests/reelforge/ ~90 modules today [~] + ~55 planned test_<name>.py / test_<name>_api.py
|
||
tests/golden/ acceptance.py manifest.yaml [E] render-fidelity anchor
|
||
|
||
docs/reelforge/
|
||
├── PRODUCT_BLUEPRINT.md ← THIS doc (authoritative file plan)
|
||
├── REPO_STRUCTURE.md ROADMAP_V2.md RESEARCH_ENTERPRISE_OSS.md ARCHITECTURE_NEXT.md [E] (updated per epic)
|
||
├── DATA_MODEL.md CONFIG.md DEPLOYMENT.md PLAN_COVERAGE.md STATUS.md [~] grow per epic
|
||
└── planned per-epic deep-dives:
|
||
INFRA_DATA_OPS.md IDENTITY_SSO.md BILLING.md API_PLATFORM.md COMPLIANCE.md
|
||
OBSERVABILITY.md SLO.md NOTIFICATIONS.md FEATURE_FLAGS.md WORKFLOWS.md
|
||
BI_ANALYTICS.md OPERATIONS.md DATA_RETENTION.md [+]
|
||
```
|
||
|
||
**DEPRECATE (scoped later PR, not bundled into epic work):** `webui/` (Streamlit) + `webui.sh`/`webui.bat`
|
||
+ legacy `docker-compose.yml`/`.release.yml`/`.gpu.yml` + `test/services/test_webui_*.py` — retired together
|
||
so the suite stays green. The active stack is only `docker-compose.reelforge.yml`.
|
||
|
||
---
|
||
|
||
## 3. Per-epic file manifest
|
||
|
||
Every filename maps to one concrete seam. "Backend / Frontend" list the **new** module groups;
|
||
append-points (`schema.py`, `models.py`, `repositories.py`, `router.py`, `tasks.py`) grow, never fork.
|
||
|
||
### Epic 1 — Access & Governance ✅ DONE (+ ReBAC graduation seam)
|
||
- **OSS:** pycasbin (Apache-2.0) + refine (MIT).
|
||
- **Backend:** `services/{rbac,audit,admin}.py` [E]; `controllers/v1/{rbac,audit,admin}.py` [E]. Planned: `core/authz.py`, `services/authz/{__init__,casbin_engine,cerbos_client,openfga_client}.py`.
|
||
- **Frontend:** admin resources `admin/{roles,audit,quotas,marketplace}/page.tsx`; `components/admin/{PolicyEditor,RoleMatrix,QuotaOverrideForm,ModerationQueue,ImpersonationBanner}.tsx`; `lib/refine/resources.ts`. Mobile: `app/admin.tsx`, `components/admin/StaffHub.tsx`.
|
||
- **Tables/migration:** `audit_log`, `casbin_rule`, `users.is_staff` (landed `e5f2a9c74b13`); planned `role_bindings`.
|
||
- **Config:** — (uses existing). **Workers:** —.
|
||
|
||
### Epic 2 — Identity / SSO / SCIM / MFA 🔵 IN-FLIGHT
|
||
- **OSS:** Ory Polis / python3-saml (Apache-2.0).
|
||
- **Backend:** `services/sso/{__init__,base,polis_client,oidc,saml,scim,mfa,keycloak_client}.py`; `controllers/v1/{sso,scim}.py`. DTOs `Sso/Scim/SecurityPolicy/ExternalIdentity`; repos `Sso/Scim/SecurityPolicy/ExternalIdentity`.
|
||
- **Frontend:** web `app/sso-login/`, `settings/{sso,scim,domains,security}/`, `admin/sso/`; `components/sso/*` (~14) + `components/security/*` (~8); `lib/sso.ts`. Mobile `app/{sso,security}.tsx`, `components/{sso,security}/*`, `lib/sso.ts`.
|
||
- **Tables/migration:** landed `sso_connections`, `scim_tokens`, `security_policies`, `external_identities` (`f1a2b3c4d5e6`); planned `scim_sync_runs`, `mfa_enrollments`, `sso_login_events` → `identity_scim_sync_mfa`.
|
||
- **Config:** `[sso][scim]` — `POLIS_CLIENT_SECRET`, `SCIM_*` (as `token_hash`), `security.enforce_mfa`. **Workers:** `scim_reconcile_task`, `sso_cert_expiry_check_task` (ops).
|
||
|
||
### Epic 3 — Billing platform
|
||
- **OSS:** OpenMeter (Apache-2.0) + Kill Bill (Apache-2.0).
|
||
- **Backend:** `services/metering/{__init__,base,openmeter_client,events}.py`; `services/billing/{entitlements,invoices,dunning,killbill_client,paddle_client,lemonsqueezy_client}.py`; `controllers/v1/{metering,entitlements,invoices}.py` (+ extend `billing.py` webhooks).
|
||
- **Frontend:** web `billing/{plans,invoices,invoices/[id],usage,payment-methods}/`, `admin/{billing,subscriptions}/`, `settings/billing/`; `components/billing/*` (~24). Mobile `app/{billing,invoices,invoice/[id]}.tsx`, `components/billing/*`, `lib/billing.ts`.
|
||
- **Tables/migration:** `billing_accounts`, `subscriptions`, `entitlements`, `usage_meters`, `credit_ledger`, `invoices`, `invoice_line_items`, `payment_methods`, `dunning_attempts`, `plan_catalog` → `billing_metering_entitlements` + `billing_invoices_dunning`.
|
||
- **Config:** `[openmeter][killbill]` — `OPENMETER_API_TOKEN`, `KILLBILL_*`. **Workers:** `meter_flush_task`, `dunning_sweep_task`, `entitlement_reconcile_task`, `invoice_finalize_task` (billing) + `app/workers/metering.py`.
|
||
|
||
### Epic 4 — API platform + SDKs + webhooks
|
||
- **OSS:** Svix (MIT) + Scalar (MIT) + openapi-generator (Apache-2.0).
|
||
- **Backend:** `services/webhooks/{__init__,base,svix_client,events,signing,endpoints}.py`; `services/apiplatform/{scopes,sdk_gen}.py`; `controllers/v1/{webhooks,apiplatform}.py`; `asgi.py` mounts Scalar.
|
||
- **Frontend:** web `developer-portal/*` (10 routes), `admin/{webhooks,api-usage}/`; `components/developer/*` (~12) + `components/webhooks/*` (~15); `lib/{webhooks,openapi}.ts`. Mobile `app/{developer,webhooks,webhook/[id]}.tsx`, `components/developer/*`.
|
||
- **Tables/migration:** `outbound_webhook_endpoints`/`webhook_endpoints`, `webhook_deliveries`, `webhook_events`, `api_scopes` (extends existing `user_api_keys`/`api_key_quotas`) → `api_platform_webhooks_scopes`.
|
||
- **Config:** `[svix][scalar]` — `SVIX_AUTH_TOKEN`, `api.default_rate_limit`. **Workers:** `dispatch_webhook_task`, `webhook_retry_task` (dispatch) + `app/workers/webhooks.py`.
|
||
|
||
### Epic 5 — Compliance (GDPR / retention / consent)
|
||
- **OSS:** Neon append-only + Cerbos/OpenFGA decision logs (Apache-2.0).
|
||
- **Backend:** `services/compliance/{__init__,gdpr,export_builder,retention,consent,decision_log,legal_hold}.py`; `controllers/v1/{compliance,privacy}.py`.
|
||
- **Frontend:** web `(marketing)/{privacy,terms,dpa}/`, `settings/{privacy,compliance}/`, `admin/{data-requests,retention}/`; `components/compliance/*` (~17); `lib/compliance.ts`; `CookieConsentBanner`. Mobile `app/privacy.tsx`, `components/compliance/*`.
|
||
- **Tables/migration:** `gdpr_requests`/`data_export_requests`, `data_deletion_requests`, `retention_policies`, `consent_records`, `legal_holds`, `pii_access_log` (reuses `audit_log`) → `compliance_gdpr_retention_consent`.
|
||
- **Config:** `[compliance]` — retention/export TTLs (no new secret). **Workers:** `build_export_task`, `retention_purge_task`, `audit_archive_task` (ops) + `app/workers/compliance.py`.
|
||
|
||
### Epic 6 — Observability (OTel, health, SLO)
|
||
- **OSS:** OpenTelemetry (Apache-2.0) → VictoriaMetrics/SigNoz.
|
||
- **Backend:** `telemetry/{otel,tracing,metrics,instrumentation,slo}.py`; `services/observability/{slo,health}.py`; `controllers/v1/{health,slo}.py`. `asgi.py`/`celery_app.py` call `instrument_app()`/`instrument_worker()`.
|
||
- **Frontend:** web `status/page.tsx` (public), `(marketing)/security/`, `admin/{observability,health,slo}/`; `components/observability/*` (~14) + `components/status/*`; `instrumentation.ts`, `instrumentation-client.ts`, `lib/{observability,telemetry}.ts`. Mobile `app/status.tsx`, `components/{status,observability}/*`.
|
||
- **Tables/migration:** `slo_definitions`/`slo_targets`, `slo_burn_snapshots`, `service_health_snapshots` (metrics/traces live in TSDB, not Neon) → `observability_slo_targets`.
|
||
- **Config:** `[otel][slo]` — standard OTLP env. **Workers:** `slo_rollup_task`, `heartbeat_task`/`health_probe_task` (ops). **Docker:** `otel-collector` in the BASE stack.
|
||
|
||
### Epic 7 — Notifications (multi-channel)
|
||
- **OSS:** Novu (MIT) + apprise (BSD-2) fallback.
|
||
- **Backend:** `services/notifications/{__init__,base,novu_client,apprise_provider,preferences,templates}.py` + `channels/{email,sms,push,webhook,inapp}.py`; `controllers/v1/{notify,notification_prefs}.py` (existing `notifications.py` bell stays).
|
||
- **Frontend:** web `settings/notifications/`, `admin/notifications/`; `components/notifications/*` (extend ~12); `lib/{notifications,push}.ts`; `public/sw.js`, `PushOptInBanner`. Mobile `app/notification-preferences.tsx`, `components/notifications/*` (extend), `lib/notifications.ts` (+ expo-notifications).
|
||
- **Tables/migration:** `notification_channels`, `notification_preferences`, `notification_templates`, `notification_deliveries`, `notification_subscribers` → `notifications_multichannel_prefs`.
|
||
- **Config:** `[novu]` (+ provider blocks) — `NOVU_API_KEY`, `RESEND/SENDGRID`, `TWILIO_*`, `FCM_SERVER_KEY`. **Workers:** `deliver_notification_task`, `digest_batch_task` (dispatch) + `app/workers/notifications.py`.
|
||
|
||
### Epic 8 — Feature flags / experiments
|
||
- **OSS:** OpenFeature (Apache-2.0) + Flagsmith (BSD-3) / flagd.
|
||
- **Backend:** `core/flags.py`; `services/flags/{__init__,base,openfeature_client,flagsmith_provider,flagd_provider}.py`; `services/experiments/assignment.py`; `controllers/v1/{flags,experiments}.py`.
|
||
- **Frontend:** web `admin/{flags,flags/[key],experiments,experiments/[id]}/`; `components/flags/*` (~12) + `components/experiments/*` (~9); `FeatureFlagProvider`, `lib/{feature-flags,use-flag,experiments}.ts`. Mobile `app/flags.tsx`, `components/flags/*`, `lib/feature-flags.ts`.
|
||
- **Tables/migration:** `feature_flags`, `flag_segments`, `flag_rollouts`, `experiments`, `experiment_assignments`, `experiment_exposures` → `feature_flags_experiments`.
|
||
- **Config:** `[flags]` — `FLAGSMITH_ENVIRONMENT_KEY`, `flags.provider`. **Workers:** `log_exposure_task`, `experiment_rollup_task` (ops). **Docker:** `flagd/flags.json`.
|
||
|
||
### Epic 9 — Workflow orchestration
|
||
- **OSS:** Hatchet (MIT) + Temporal (MIT) alt.
|
||
- **Backend:** `services/workflows/{__init__,base,hatchet_client,temporal_client,dags,registry,render_workflow}.py`; `controllers/v1/workflows.py`; `app/workers/hatchet_bridge.py`.
|
||
- **Frontend:** web `workflows/{,new,[id]}/`, `admin/{workflows,workflows/[runId]}/`; `components/workflows/*` (~17); `lib/workflows.ts`. Mobile `app/{workflows,workflow/[id]}.tsx`, `components/workflows/*`.
|
||
- **Tables/migration:** `workflow_runs`, `workflow_steps`, `workflow_run_events`, `pipeline_run_map` (Hatchet owns durable state) → `workflow_orchestration_runs`.
|
||
- **Config:** `[hatchet]` — `HATCHET_CLIENT_TOKEN`. **Workers:** `enqueue_workflow_task`, `workflow_status_sync_task`.
|
||
|
||
### Epic 10 — BI / analytics pipeline
|
||
- **OSS:** Cube (Apache-2.0) + PostHog (MIT).
|
||
- **Backend:** `services/bi/{__init__,base,cube_client,posthog_client,event_pipeline,warehouse}.py`; `controllers/v1/{bi,events}.py`; `app/workers/analytics.py`.
|
||
- **Frontend:** web `analytics/{explore,funnels,retention,events,dashboards,dashboards/[id]}/`, `admin/{events,warehouse}/`; `components/bi/*` (~18); `AnalyticsProvider`, `lib/{bi,cube-client,analytics-track}.ts`. Mobile `app/{dashboards,dashboard/[id]}.tsx`, `components/bi/*`.
|
||
- **Tables/migration:** `product_events`/`analytics_events`, `event_schemas`, `event_dead_letter`, `funnel_definitions`, `cohort_snapshots`, `warehouse_syncs`, `bi_dashboards` → `bi_analytics_event_pipeline`.
|
||
- **Config:** `[cube][posthog]` — `CUBE_API_SECRET`, `POSTHOG_API_KEY`. **Workers:** `flush_events_task`, `rollup_aggregates_task`, `warehouse_sync_task` (ops). **Docker:** `cube/schema/*.js`.
|
||
|
||
---
|
||
|
||
## 4. Planned-file + LOC estimates (outcome, not target)
|
||
|
||
Honest ranges. Counts include new backend modules + tests, new web pages/components/lib, new mobile
|
||
screens/components/lib, migrations, docker overlays, and per-epic deep-dive docs. Append-point growth
|
||
(`schema.py`, `models.py`, `repositories.py`, `router.py`, `tasks.py`, `middleware.ts`, `layout.tsx`,
|
||
`lib/api.ts`) is **not** counted as new files — it grows existing files by convention.
|
||
|
||
| Epic | Backend files | Web files | Mobile files | Infra/docs | ~Files | ~LOC range |
|
||
|------|--------------:|----------:|-------------:|-----------:|-------:|-----------|
|
||
| 1 Access & Governance (graduation) | 9 | 12 | 3 | 2 | ~26 | 2.5k–4k |
|
||
| 2 Identity / SSO | 18 | 29 | 11 | 3 | ~61 | 6k–9k |
|
||
| 3 Billing platform | 20 | 40 | 12 | 4 | ~76 | 8k–12k |
|
||
| 4 API platform + SDKs | 18 | 43 | 10 | 3 | ~74 | 7k–11k |
|
||
| 5 Compliance | 16 | 30 | 8 | 4 | ~58 | 5k–8k |
|
||
| 6 Observability | 15 | 28 | 8 | 5 | ~56 | 5k–8k |
|
||
| 7 Notifications | 20 | 24 | 12 | 3 | ~59 | 5k–8k |
|
||
| 8 Feature flags / experiments | 14 | 26 | 6 | 3 | ~49 | 4k–7k |
|
||
| 9 Workflow orchestration | 12 | 24 | 8 | 3 | ~47 | 5k–8k |
|
||
| 10 BI / analytics | 16 | 34 | 10 | 3 | ~63 | 6k–10k |
|
||
| **Totals** | **~158** | **~290** | **~88** | **~33** | **~570–620** | **~55k–90k** |
|
||
|
||
**Anchor: ~600 planned new files, ~55k–90k LOC**, spread across ~10 backend service subdirs,
|
||
~20 new controllers, ~26 new ORM tables (+ matching repos/DTOs appended to the three god-files),
|
||
~10 migrations, ~6 new worker modules, ~5 new telemetry modules, ~2 new `core/` deps, ~14 web
|
||
component groups, ~10 mobile component groups, 8 docker overlays, and ~13 new docs — plus ~55 new
|
||
`tests/reelforge/test_*.py`. Restated: **the number is a readout of the capability surface**
|
||
(one file per provider seam / DTO group / table / endpoint group / worker queue / screen), not a
|
||
quota. Simpler epics land fewer files; that is the intended signal.
|
||
|
||
---
|
||
|
||
## 5. Build sequence & account-gating
|
||
|
||
**Land the cross-cutting substrates first** (per [`RESEARCH_ENTERPRISE_OSS.md`](./RESEARCH_ENTERPRISE_OSS.md) §5):
|
||
|
||
1. **Epic 8 — flags** (`FeatureFlagProvider` + `useFlag` + `core/flags.py`): every later surface ships flag-gated (dark-launch, gradual rollout, instant kill-switch).
|
||
2. **Epic 6 — observability** (`TelemetryProvider` + `instrumentation*.ts` + `otel-collector` in the base stack): every later surface is instrumented for free from day one; history accrues immediately.
|
||
3. **Epic 2 — identity/SSO**: finish the in-flight service/controllers on already-migrated tables (enterprise entry gate).
|
||
|
||
Then the value epics, each behind its own compose profile so the core `redis+api+worker+beat` stack
|
||
stays a one-command `make -f Makefile.reelforge up`:
|
||
|
||
4. **Epic 1 refine console** hosts the ops shell → Epics 3/4/5/6/7/8/9/10 each register a **thin admin resource** (`admin/<epic>/page.tsx`) rather than a bespoke app; `settings/<area>` are the tenant self-serve counterparts.
|
||
5. **Epic 3 Billing → 4 API platform → 5 Compliance → 7 Notifications → 10 BI → 9 Workflows** — heavy-infra sidecars (OpenMeter, Svix, Cube/PostHog, Hatchet) land only after their FastAPI adapter seam + compose profile exist.
|
||
|
||
**Account-gated (needs live external creds to fully verify; ships behind an injectable non-networked client seam until then):**
|
||
|
||
| Gate | Epics | Why |
|
||
|------|-------|-----|
|
||
| Live IdP / directory | 2 | SAML/OIDC round-trip + SCIM provisioning need a real IdP (Okta/Entra/Google). |
|
||
| Live billing accounts | 3 | OpenMeter ingest + Kill Bill invoicing/dunning + card mandates need provider accounts. |
|
||
| Live webhook + registry | 4 | Svix delivery/retry/replay + app-portal need a Svix instance/token. |
|
||
| Warehouse + product analytics | 10 | Cube semantic layer + PostHog ingest need a warehouse + PostHog project. |
|
||
| Metrics/traces backend | 6 | Collector export to VictoriaMetrics/SigNoz needs the store running. |
|
||
| Orchestrator engine | 9 | Hatchet durable DAG needs the Hatchet engine + its Postgres. |
|
||
|
||
Non-gated (verifiable end-to-end against Neon + mocks, no external account): **Epic 5 Compliance**,
|
||
**Epic 8 Feature flags** (flagd path), and the **Epic 1 ReBAC graduation** seams — these can land
|
||
and stay green without any live third-party credentials.
|
||
|
||
---
|
||
|
||
## 6. Guiding principles
|
||
|
||
1. **Keep existing files in place.** No moving, splitting, or renaming. The 1924-green suite must not edit for structural reasons. Domain-vertical migration stays deferred (see [`REPO_STRUCTURE.md`](./REPO_STRUCTURE.md)).
|
||
2. **Additive by convention.** New feature `<name>` = `services/<name>.py` (or subdir) + `controllers/v1/<name>.py` + `tests/reelforge/test_<name>.py` + a migration, and **appends** DTOs→`schema.py`, table→`models.py`, repo→`repositories.py`, one `include_router()`→`router.py`, stage/ops task→`tasks.py`. Providers live behind the subdir Protocol/registry seam.
|
||
3. **Fork verified MIT/Apache OSS foundations** ([`RESEARCH_ENTERPRISE_OSS.md`](./RESEARCH_ENTERPRISE_OSS.md)). Wrap each behind a FastAPI adapter + Protocol seam; never duplicate a foundation's own datastore in Neon — store only the thin mapping/config rows the adapter needs.
|
||
4. **One linear migration chain, additive columns, secrets encrypted at rest** via `crypto_tokens.py` (`SOCIAL_TOKEN_KEY` = the platform key). No branches, no drift.
|
||
5. **Substrates before surfaces:** flags (8) + telemetry (6) mount in both root layouts before any epic UI, so every later feature is flag-gated and instrumented for free.
|
||
6. **Stay green.** Every epic lands with tests to the 80% floor; the render `tests/golden` harness is the fidelity anchor; `make -f Makefile.reelforge check` is the local gate (no CI by design).
|
||
7. **File count follows capability.** Each planned file is one real seam. The ~600 total is a byproduct, never a goal.
|
||
|
||
---
|
||
|
||
_Authoritative product file plan — ReelForge. Written against the live tree (head `f1a2b3c4d5e6`,
|
||
1924 green). Last updated 2026-08-13. Supersedes ad-hoc file lists; cross-links
|
||
[`REPO_STRUCTURE.md`](./REPO_STRUCTURE.md), [`ROADMAP_V2.md`](./ROADMAP_V2.md),
|
||
[`RESEARCH_ENTERPRISE_OSS.md`](./RESEARCH_ENTERPRISE_OSS.md), [`ARCHITECTURE_NEXT.md`](./ARCHITECTURE_NEXT.md)._
|