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.
641 lines
43 KiB
Markdown
641 lines
43 KiB
Markdown
# ReelForge — Historical Repo Structure & Additive-File Convention
|
||
|
||
> **Historical status:** This document describes the pre-monorepo layout and the
|
||
> earlier decision to avoid structural moves. For the current `apps/*`,
|
||
> `packages/*`, and `external/*` layout and its incremental target, use
|
||
> [`REPOSITORY_LAYOUT_SPEC.md`](./REPOSITORY_LAYOUT_SPEC.md). Runtime behavior
|
||
> remains governed by `INTEGRATION_CONTRACT.md` and the code.
|
||
|
||
> The remainder is a preserved historical map and is **not** authoritative for
|
||
> current paths or new work. It previously superseded the move-heavy parts
|
||
> of [`ARCHITECTURE_RESTRUCTURE.md`](./ARCHITECTURE_RESTRUCTURE.md): we are **not**
|
||
> migrating existing files into `domains/` vertical slices. Instead we **keep every
|
||
> existing file exactly where it is** and organize **new** work by an additive
|
||
> convention. Companion to [`ARCHITECTURE.md`](./ARCHITECTURE.md) (current runtime),
|
||
> [`ARCHITECTURE_NEXT.md`](./ARCHITECTURE_NEXT.md) (runtime target), and
|
||
> [`DATA_MODEL.md`](./DATA_MODEL.md) (schema). Written against the real tree.
|
||
|
||
---
|
||
|
||
## The pivot, stated once
|
||
|
||
`ARCHITECTURE_RESTRUCTURE.md` proposed a correct-in-the-abstract refactor:
|
||
shatter the god-files and move MPT's flat **layer-by-type** layout into
|
||
**domain-by-domain vertical slices**. That plan is **deliberately deferred**. The
|
||
directive is now:
|
||
|
||
- **Existing files stay put.** No moving, no splitting, no renaming. The
|
||
**1986-green** test suite (`test/` MPT legacy + `tests/reelforge` + `tests/golden`)
|
||
must not need a single edit for structural reasons.
|
||
- **New features = new files in the right place**, following the conventions in
|
||
§4. A small set of **shared "append-point" files** (§3) grow by appending, never
|
||
by forking.
|
||
- The domain-migration in `ARCHITECTURE_RESTRUCTURE.md` remains on record as an
|
||
**optional future** refactor — not something any feature PR should trigger.
|
||
|
||
---
|
||
|
||
## 1. TL;DR — the repo at a glance
|
||
|
||
Fork of **MoneyPrinterTurbo**. Python/FastAPI backend + Celery workers powering
|
||
**three** client surfaces — a Next.js web app, an Expo mobile app, and the former
|
||
Electron desktop implementation (now legacy reference, replaced by native
|
||
Rust/GPUI) — plus an enterprise governance+identity layer, an
|
||
in-process run/smoke harness (`ops/`), and the inherited (now frozen) MPT Streamlit UI.
|
||
|
||
| Area | Path | Size | Role |
|
||
|---|---|---|---|
|
||
| Backend | `app/` | **~148 `.py`** (+ ~85 tests) | FastAPI API + Celery pipeline + enterprise governance/identity. Source of truth. |
|
||
| Web app | `web/` | **~263 `.ts/.tsx`**, 38 routed pages | Next.js 15 App Router — the primary end-user UI + refine admin console. |
|
||
| Mobile app | `mobile/` | **~147 `.ts/.tsx`**, ~28 screens | Expo / expo-router — thin client over the same backend. |
|
||
| Historical desktop | former `desktop/` | **~40 files** (Electron + Vite + React 19) | Legacy reference only; active desktop is Rust/GPUI under `apps/desktop`. |
|
||
| Legacy UI | `webui/` | 1 × 4124-LOC `Main.py` + i18n | **Frozen** MPT Streamlit UI. Superseded by `web/` + `mobile/` + `desktop/`; still test-covered. |
|
||
| Assets | `resource/` | fonts, songs, hooks, voices, public | **Load-bearing** bundled pipeline assets, accessed via `app/utils/utils.py` helpers. |
|
||
| Runtime scratch | `storage/` | — | **Gitignored** per-job render artifacts. Never committed. |
|
||
| Migrations | `migrations/` | ~24 Alembic revisions | Single linear chain; head `f1a2b3c4d5e6` (enterprise identity/SSO). |
|
||
| Run harness | `ops/` + `Makefile.dev` + `docker-compose.full.yml` | — | In-process ASGI smoke (`ops/smoke.py`, PASS), seed data, full-stack dev bring-up. |
|
||
| Deploy | `docker/`, compose files | — | `docker-compose.reelforge.yml` (active core) + `docker-compose.full.yml` (full stack); MPT composes are legacy. |
|
||
| Docs | `docs/reelforge/` | 25+ files | This map + architecture/data/API/status + `PRODUCT_BLUEPRINT.md` / `RESEARCH_ENTERPRISE_OSS.md`. |
|
||
|
||
**Guiding principle:** *Keep existing files; add new work by convention.* Everything
|
||
below tells you (a) what exists and (b) exactly which new file to create — with no
|
||
existing file moved or split.
|
||
|
||
---
|
||
|
||
## 2. Annotated tree per area
|
||
|
||
### 2.1 Backend — `app/`
|
||
|
||
```
|
||
app/
|
||
├── __init__.py # package marker
|
||
├── asgi.py # FastAPI app factory: lifespan (Sentry, cross-post recovery),
|
||
│ # exception handlers, CORS, mounts /tasks + / static, includes root router
|
||
├── router.py # root APIRouter — include_router() for all 29 v1 controllers (APPEND-POINT)
|
||
│
|
||
├── config/
|
||
│ ├── __init__.py # exposes `config` singleton
|
||
│ └── config.py # TOML/env config loader (669 LOC): keys, providers, paths, feature flags
|
||
│
|
||
├── core/
|
||
│ ├── __init__.py # cross-cutting concerns marker
|
||
│ └── clerk.py # Clerk JWT verification bridge (web/mobile auth → User)
|
||
│
|
||
├── controllers/
|
||
│ ├── base.py # legacy MPT global-key verify_token + task manager wiring
|
||
│ ├── ping.py # health/ping route
|
||
│ ├── manager/
|
||
│ │ ├── base_manager.py # abstract task queue manager + TaskQueueFullError
|
||
│ │ ├── memory_manager.py # in-process task queue (single-node/dev)
|
||
│ │ └── redis_manager.py # Redis-backed task queue (multi-node)
|
||
│ └── v1/ # ONE controller module per feature domain (mounted in router.py)
|
||
│ ├── base.py # new_router() factory + caller-resolution (x-api-key → User)
|
||
│ ├── video.py # legacy MPT video/subtitle/bgm/material endpoints
|
||
│ ├── llm.py # legacy MPT LLM script/terms endpoints
|
||
│ ├── jobs.py (1794) # CORE pipeline API: create/list/get/rerun/dub jobs, broll (APPEND-POINT)
|
||
│ ├── studio.py # Creator Studio: on-demand publish + photo→avatar preset
|
||
│ ├── billing.py # credit purchase + webhooks (Stripe/iyzico/Creem/Polar)
|
||
│ ├── catalog.py # caption-style / music / layout catalogs
|
||
│ ├── me.py # growth "me": insights, referral loop, saved presets
|
||
│ ├── voices.py # Brand Voice cloning (ElevenLabs IVC)
|
||
│ ├── ideas.py # SPARK AI idea engine (generate + save concepts)
|
||
│ ├── notifications.py # in-app bell/unread badge/center
|
||
│ ├── schedule.py # scheduled publishing
|
||
│ ├── covers.py # cover/thumbnail generator
|
||
│ ├── workspaces.py # team workspaces (invites, roles, shared credits)
|
||
│ ├── brand.py # brand watermark settings
|
||
│ ├── social.py # AI social caption & hashtags
|
||
│ ├── api_keys.py # public API keys mint/list/revoke
|
||
│ ├── analytics.py # creator BI dashboard
|
||
│ ├── marketplace.py # template marketplace publish/browse/clone/rate
|
||
│ ├── performance.py # hook performance loop (log outcomes → win scores)
|
||
│ ├── connections.py (675) # Direct-Publish OAuth account-connect + publish
|
||
│ ├── share.py # public watermarked share pages (+ public /public/r)
|
||
│ ├── creators.py # creator profiles + follow graph + leaderboards
|
||
│ ├── calendar.py # publishing calendar grid + reschedule (over ScheduledPublish)
|
||
│ │ # ── ENTERPRISE Epic 1 — Access & Governance ──
|
||
│ ├── rbac.py # workspace member roles + GET /me/permissions (Casbin decisions)
|
||
│ ├── audit.py # GET /me/workspaces/{id}/audit — append-only audit-log reader
|
||
│ ├── admin.py # platform-admin (User.is_staff): /admin/users|workspaces|jobs + impersonate
|
||
│ │ # ── ENTERPRISE Epic 2 — Identity & SSO ──
|
||
│ ├── sso.py # SAML SP: /sso/{ws}/metadata|login|acs + per-workspace connection CRUD
|
||
│ ├── scim.py # SCIM 2.0 provisioning: /scim/v2/{ws}/Users|Groups (list/create/patch/delete)
|
||
│ └── security_policy.py # GET/PUT /me/workspaces/{id}/security — workspace security policy
|
||
│
|
||
├── models/
|
||
│ ├── const.py # enums/constants
|
||
│ ├── exception.py # HttpException
|
||
│ ├── llm_provider.py # LLM provider enum/config
|
||
│ ├── schema.py (4164) # ALL Pydantic request/response DTOs (195 classes) (APPEND-POINT)
|
||
│ └── db/
|
||
│ ├── base.py # SQLAlchemy declarative Base, engine, session plumbing
|
||
│ ├── models.py (1544) # ALL 27 ORM tables (Mapped[] typing) (APPEND-POINT)
|
||
│ └── repositories.py (3646) # 25 Repository classes (data access) (APPEND-POINT)
|
||
│
|
||
├── services/ # 84 service files — domain logic (grouped in §2.2)
|
||
│ ├── data/azure_voices.json # static Azure voice catalog
|
||
│ ├── utils/video_effects.py # shared FFmpeg effect helpers
|
||
│ ├── avatar/ {base.py Protocol+registry, heygen.py, latentsync_runpod.py}
|
||
│ ├── tts/ {elevenlabs_timestamps.py, voice_clone.py}
|
||
│ ├── captions/ {ass_karaoke.py, presets.py, words.py}
|
||
│ ├── compose/ {compose_ffmpeg.py}
|
||
│ ├── editing/ {auto_zoom.py, matting.py, motion.py, silence_cut.py}
|
||
│ ├── script/ {ugc.py}
|
||
│ ├── billing/ {service.py, plans.py, stripe_client.py, iyzico_client.py, creem_client.py, polar_client.py}
|
||
│ ├── publishers/{base.py seam, tiktok.py}
|
||
│ ├── storage/ {r2.py Cloudflare R2/S3}
|
||
│ ├── calendar.py # publishing calendar over ScheduledPublish
|
||
│ │ # ── ENTERPRISE Epic 1 (Access & Governance) ──
|
||
│ ├── rbac.py # pycasbin RBAC decision engine + tenant-isolation gate
|
||
│ ├── audit.py # append-only audit-log writer/reader
|
||
│ ├── admin.py # platform-admin queries (users/workspaces/jobs, impersonation)
|
||
│ │ # ── ENTERPRISE Epic 2 (Identity & SSO) ──
|
||
│ ├── sso.py # SAML SP (python3-saml, guarded import) + external-identity linking
|
||
│ ├── scim.py # SCIM 2.0 user/group provisioning (scim2-filter-parser optional)
|
||
│ └── security_policy.py # per-workspace security policy (session/MFA/domain rules)
|
||
│
|
||
├── telemetry/
|
||
│ ├── cost.py # per-job USD cost telemetry (unit economics)
|
||
│ ├── events.py # append-only job event log
|
||
│ ├── progress.py # stage-weight → progress %
|
||
│ └── sentry.py # Sentry wiring (api/worker), NO-OP without DSN
|
||
│
|
||
├── utils/
|
||
│ ├── file_security.py # path/upload safety
|
||
│ ├── logging_utils.py # loguru setup
|
||
│ └── utils.py # get_response envelope, task_dir/public_dir, dir helpers, misc
|
||
│
|
||
└── workers/
|
||
├── celery_app.py # Celery application config
|
||
├── context.py # JSON-serializable JobContext passed between chain stages
|
||
├── pipeline.py # pipeline assembly + enqueue (DAG wiring)
|
||
└── tasks.py (616) # Celery stage tasks (script→tts→{avatar∥captions}→compose→upload) (APPEND-POINT)
|
||
```
|
||
|
||
### 2.2 Backend services grouped by domain (84 files)
|
||
|
||
New service files file into the matching group. Provider-style integrations go
|
||
**behind the existing subdir's Protocol/registry seam** (see §4), not as new top-level services.
|
||
|
||
- **reels-pipeline (core):** `reelforge.py` (1793 — `ReelForgeParams` DTO + 6 pure stage transforms), `task.py` (1309), `video.py` (1372 legacy), `material.py`, `subtitle.py`, `preview.py`, `templates.py`, `task_artifacts.py`, `webui_task.py`
|
||
- **voice/tts:** `voice.py` (1829), `tts/elevenlabs_timestamps.py`, `tts/voice_clone.py`, `transcribe.py`
|
||
- **avatar:** `avatar/base.py` (Protocol + registry), `avatar/heygen.py`, `avatar/latentsync_runpod.py`
|
||
- **captions:** `captions/ass_karaoke.py`, `captions/presets.py`, `captions/words.py`
|
||
- **compose/editing:** `compose/compose_ffmpeg.py` (1355), plus the **editing polish stage** `editing/{silence_cut,auto_zoom,motion,matting}.py` — opt-in pure-FFmpeg pre-compose passes gated on `Job.params` (Submagic-style silence-cut, attention auto-zoom, synthetic camera motion, rembg matting), `utils/video_effects.py`
|
||
- **media/broll/music:** `broll.py`, `bgm.py`, `bgm_ai.py`, `music.py`, `elevenlabs_music.py`, `sonilo.py`, `twelvelabs.py`, `cover.py`
|
||
- **marketplace:** `marketplace.py` (671)
|
||
- **analytics/insights/hook-performance:** `analytics.py`, `insights.py`, `hook_performance.py`
|
||
- **community/creators/share/referrals:** `creators.py`, `share.py`, `referrals.py`, `notifications.py`
|
||
- **billing/quotas:** `billing/service.py` (920), `billing/plans.py`, `billing/{stripe,iyzico,creem,polar}_client.py`, `apikey_quota.py`
|
||
- **publishing/oauth/scheduler:** `publish.py`, `publishers/base.py`, `publishers/tiktok.py`, `oauth_connect.py`, `scheduler.py`, `upload_post.py`, `webhooks.py`, `crypto_tokens.py` (OAuth token encryption)
|
||
- **workspaces:** `workspaces.py`
|
||
- **ai/ideas/translate:** `ideas.py`, `translate.py`, `llm.py` (legacy), `script/ugc.py`
|
||
- **calendar:** `calendar.py`
|
||
- **enterprise — access & governance (Epic 1):** `rbac.py` (pycasbin decision engine + tenant-isolation gate), `audit.py` (append-only audit-log service), `admin.py` (platform-admin queries + impersonation)
|
||
- **enterprise — identity & SSO (Epic 2):** `sso.py` (SAML SP via python3-saml, guarded import), `scim.py` (SCIM 2.0 provisioning, scim2-filter-parser optional), `security_policy.py` (per-workspace security policy)
|
||
- **infra (cache/ratelimit/state/storage):** `cache_manager.py`, `material_cache.py`, `ratelimit.py`, `state.py`, `storage/r2.py`, `version_checker.py`
|
||
|
||
### 2.3 Web — `web/` (Next.js 15 · React 19 · Tailwind + shadcn/ui · Clerk)
|
||
|
||
Path alias: everything imports via `@/…` (`@/lib/api`, `@/components/<feature>/…`).
|
||
|
||
```
|
||
web/
|
||
├── app/ # App Router — one dir per route, "use client" page.tsx per screen
|
||
│ ├── layout.tsx # Root: ClerkProvider (dark), Inter, global metadata, globals.css
|
||
│ ├── globals.css # Tailwind base + design tokens
|
||
│ ├── (marketing)/ # PUBLIC route group (layout-only, no URL segment)
|
||
│ │ ├── layout.tsx # Navbar + footer chrome
|
||
│ │ ├── page.tsx # Landing (hero / how-it-works / showcase)
|
||
│ │ └── pricing/page.tsx # Public pricing + checkout plans
|
||
│ ├── sign-in/[[...sign-in]]/… # Clerk catch-all sign-in
|
||
│ ├── sign-up/[[...sign-up]]/… # Clerk catch-all sign-up
|
||
│ ├── dashboard/page.tsx # Authed home: reel history grid + nav + credits + bell
|
||
│ ├── new/page.tsx # Reel-creation Wizard entry
|
||
│ ├── jobs/[id]/page.tsx # Job detail: stages, media, rerun/share/dub/broll/cover/social/publish
|
||
│ ├── batch/[id]/page.tsx # Multi-variant batch view
|
||
│ ├── ideas/page.tsx # SPARK idea engine
|
||
│ ├── presets/page.tsx # Brand-kit presets
|
||
│ ├── avatars/page.tsx # Selfie → talking-photo avatars
|
||
│ ├── voices/page.tsx # Brand Voice cloning
|
||
│ ├── brand/page.tsx # Brand watermark editor
|
||
│ ├── analytics/page.tsx # Creator BI dashboard (recharts)
|
||
│ ├── insights/page.tsx # Lightweight growth insights
|
||
│ ├── performance/page.tsx # Hook Performance Loop
|
||
│ ├── calendar/page.tsx # Publishing calendar grid
|
||
│ ├── scheduled/page.tsx # Scheduled-publish list
|
||
│ ├── connections/page.tsx # Social OAuth + direct publish
|
||
│ ├── marketplace/page.tsx # Template marketplace
|
||
│ ├── leaderboard/page.tsx # Creator reputation leaderboard
|
||
│ ├── creators/[handle]/page.tsx # PUBLIC creator profile + follow
|
||
│ ├── referral/page.tsx # Referral share + redeem
|
||
│ ├── team/page.tsx # Workspaces
|
||
│ ├── usage/page.tsx # Per-API-key monthly usage
|
||
│ ├── notifications/page.tsx # Notification center
|
||
│ ├── settings/api-keys/page.tsx # API-key mint/list/revoke
|
||
│ ├── settings/team/page.tsx # workspace members + RBAC roles
|
||
│ ├── settings/audit/page.tsx # ENTERPRISE: audit-log viewer
|
||
│ ├── settings/sso/page.tsx # ENTERPRISE: SAML SSO connection config
|
||
│ ├── billing/page.tsx (+success/, +cancel/) # Credit-pack checkout
|
||
│ ├── admin/ # ENTERPRISE: refine-powered platform-admin console (User.is_staff)
|
||
│ │ ├── layout.tsx # <Refine> provider shell (data + access-control providers)
|
||
│ │ ├── page.tsx # admin overview
|
||
│ │ ├── users/page.tsx # users list
|
||
│ │ ├── workspaces/page.tsx # workspaces list
|
||
│ │ └── jobs/page.tsx # platform-wide jobs list
|
||
│ └── r/[token]/page.tsx # PUBLIC watermarked share page (no auth)
|
||
│
|
||
├── components/ # ui/ shadcn primitives + one dir per feature
|
||
│ ├── ui/ # shadcn kit: badge, button, card, input, label, progress, select, skeleton, textarea
|
||
│ └── <feature>/ # e.g. wizard, jobs, batch, ideas, presets, avatars, voices, voiceover,
|
||
│ # brand, broll, cover, dub, social, share, analytics, insights, performance,
|
||
│ # usage, calendar, schedule, connections, marketplace, creators, team,
|
||
│ # referral, notifications, apikeys, billing, marketing
|
||
│ # Each colocates *.tsx + use-<feature>.ts data hook + pure helpers
|
||
│ # (format.ts, <feature>-utils.ts, constant tables)
|
||
│
|
||
├── lib/ # shared client (see §3)
|
||
│ ├── api.ts (2305) # THE typed fetch client — request<T>() envelope, ApiError, buildHeaders,
|
||
│ │ # presignAndUpload, pollJob, ~1 fn per endpoint (APPEND-POINT)
|
||
│ ├── types.ts (2259) # THE DTO/enum/const source of truth (APPEND-POINT)
|
||
│ ├── calendar.ts # per-feature client (the emerging pattern; reuses api.ts primitives)
|
||
│ ├── refine/ # ENTERPRISE: refine adapters for the /admin console
|
||
│ │ ├── data-provider.ts # @refinedev/core DataProvider mapping resources → admin* api.ts fns
|
||
│ │ └── access-control.ts # accessControlProvider (staff/role gating)
|
||
│ ├── utils.ts # cn() class-merge
|
||
│ ├── use-api-token.ts # useApiToken() → Clerk JWT → x-api-key
|
||
│ ├── job-media.ts # job media-URL guards
|
||
│ ├── spark-prefill.ts # sessionStorage handoff SPARK → wizard
|
||
│ ├── use-my-workspaces.ts # app-wide workspace hook (cross-feature → lib/)
|
||
│ └── use-payment-providers.ts # app-wide enabled-provider hook (cross-feature → lib/)
|
||
│
|
||
├── middleware.ts # Clerk auth: isPublicRoute (/r/*, /creators/*) + isProtectedRoute
|
||
├── next.config.mjs · tailwind.config.ts · tsconfig.json (@/* → ./*)
|
||
└── package.json # @clerk/nextjs, @refinedev/core, @refinedev/nextjs-router,
|
||
# recharts, lucide-react, clsx, tailwind-merge
|
||
```
|
||
|
||
Per-feature micro-convention (consistent): `use-<feature>.ts` owns load/error/reload
|
||
state, calls `useApiToken()` then `@/lib` functions, updates state immutably, aborts
|
||
in-flight requests on unmount; `format.ts` / `<feature>-utils.ts` / constant tables are
|
||
pure and testable; `*.tsx` are presentational with named prop interfaces, `cn()`, lucide + `ui/`.
|
||
|
||
### 2.4 Mobile — `mobile/` (Expo · expo-router · dark theme `#0b0b12`)
|
||
|
||
Thin client; every screen fetches through `lib/api.ts` (or a feature-scoped sibling
|
||
like `lib/calendar.ts`) and passes the session API key as `options.token` (→ `x-api-key`).
|
||
|
||
```
|
||
mobile/
|
||
├── app/ # expo-router file-based routing
|
||
│ ├── _layout.tsx # Root Stack + SessionContext; loads persisted key; ROUTE REGISTRY (APPEND-POINT)
|
||
│ ├── index.tsx # Sign-in — paste API key, stored via SecureStore
|
||
│ ├── (tabs)/
|
||
│ │ ├── _layout.tsx # Authed Tabs; redirects to "/" when no key; NotificationBell header
|
||
│ │ ├── create.tsx # CREATE tab — main reel form (764 LOC, largest screen)
|
||
│ │ ├── jobs.tsx # JOBS tab — caller's jobs with live status
|
||
│ │ └── me.tsx # ME tab — profile + LINK HUB to every secondary screen (APPEND-POINT)
|
||
│ ├── job/[id].tsx # Job detail — player, stages, rerun/dub/cover/share
|
||
│ ├── creator/[id].tsx # Public creator profile + follow
|
||
│ ├── analytics.tsx · ideas.tsx · performance.tsx · marketplace.tsx · notifications.tsx
|
||
│ ├── calendar.tsx · scheduled.tsx · team.tsx · api-keys.tsx · usage.tsx · connections.tsx
|
||
│ ├── leaderboard.tsx · voices.tsx · avatars.tsx · brand.tsx
|
||
│
|
||
├── lib/
|
||
│ ├── api.ts (2072) # MAIN typed client, grouped by § section; API_BASE, ApiError, isAbortError,
|
||
│ │ # RequestOptions, LocalFile, presignAndUpload, pollJob (APPEND-POINT)
|
||
│ ├── types.ts (2241) # backend contract types, kept in sync with web/lib/types.ts (APPEND-POINT)
|
||
│ ├── calendar.ts # self-contained feature client (template for new self-contained features)
|
||
│ ├── session.ts # SecureStore key session + SessionContext + useSession()
|
||
│ ├── job-status.ts · job-media.ts # presentation + safe media-URL helpers
|
||
│ └── pick-selfie.ts · pick-voice-sample.ts · pick-recording.ts · pick-logo.ts # → LocalFile pickers
|
||
│
|
||
└── components/<feature>/ # one dir per screen (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)
|
||
# PascalCase *.tsx pieces + lowercase .ts helpers (format.ts, constants, hooks);
|
||
# Me-hub sections use shared components/me/use-resource.ts lifecycle hook
|
||
```
|
||
|
||
Per-feature module pattern: thin route screen `app/<feature>.tsx` (layout + data
|
||
orchestration) → renders `components/<feature>/<Feature>Manager.tsx` (or `Section`) →
|
||
composed of small presentational pieces + lowercase helpers.
|
||
|
||
### 2.5 Historical desktop — former Electron implementation
|
||
|
||
Native screen-recording client and the **third client surface** on the same FastAPI
|
||
backend. It does **not** reimplement the pipeline: it records the screen, uploads the
|
||
clip to R2 via the backend presign endpoint, creates a job (`POST /jobs`), polls it,
|
||
and shows the result. Hardened by default (`contextIsolation: true`,
|
||
`nodeIntegration: false`, `sandbox: true`); the renderer talks to main **only** through
|
||
a typed `contextBridge` (`window.reelforge`). **No secrets in the renderer bundle** —
|
||
the API base + token live in the main process (encrypted at rest via `safeStorage`) and
|
||
authenticated calls are proxied through main.
|
||
|
||
```
|
||
apps/desktop/electron-legacy/ # frozen migration reference; not a deployable
|
||
├── electron/ # MAIN process + preload (TypeScript → dist-electron/)
|
||
│ ├── main.ts # app/window lifecycle, desktopCapturer, ipcMain handlers, nav hardening
|
||
│ ├── preload.ts # contextBridge → typed window.reelforge; no raw ipcRenderer exposed
|
||
│ ├── ipc.ts # canonical IPC channel names + payload contracts (single source of truth)
|
||
│ ├── api-proxy.ts # main-process HTTP proxy: attaches token, host-allowlist enforced
|
||
│ └── config-store.ts # secure config store (safeStorage-encrypted token, allowed-host policy)
|
||
├── src/ # RENDERER (React 19, Vite)
|
||
│ ├── main.tsx · App.tsx # renderer entry + root component
|
||
│ ├── features/recorder/ # ScreenRecorder.ts, useScreenRecorder.ts, captureSources.ts,
|
||
│ │ # mediaSupport.ts, RecorderPanel.tsx/.css, format.ts, errors.ts, types.ts
|
||
│ ├── screens/ # ConnectScreen, CreateScreen, LibraryScreen, SettingsScreen,
|
||
│ │ # RecordStep, ConfigureStep, ConfigForm, reelParams.ts
|
||
│ ├── views/ # RecordView, GenerateView, LibraryView, SettingsDialog
|
||
│ ├── lib/ # api.ts (proxied client), types.ts, recorder.ts, upload.ts, useJob.ts
|
||
│ └── styles.css · global.d.ts · vite-env.d.ts
|
||
├── index.html # Vite renderer HTML entry
|
||
├── dist-electron/ # compiled main/preload output (tsc)
|
||
├── electron-builder.yml # packaging config
|
||
├── vite.config.ts · tsconfig.json · tsconfig.electron.json
|
||
├── package.json · package-lock.json # reelforge-desktop; electron, vite, @vitejs/plugin-react, react 19
|
||
└── README.md
|
||
```
|
||
|
||
This tree is preserved only as historical migration context. New desktop work
|
||
belongs to the Rust/GPUI modules under `apps/desktop/src` and follows
|
||
`REPOSITORY_LAYOUT_SPEC.md`; no Electron source receives product changes.
|
||
|
||
### 2.6 Legacy UI — `webui/` (frozen)
|
||
|
||
```
|
||
webui/
|
||
├── Main.py # 4124 LOC Streamlit single-file UI. Drives the ORIGINAL MPT pipeline (not the RF Celery one)
|
||
├── styles.css
|
||
├── .streamlit/config.toml # note: Main.py:80 looks for .streamlit/webui.toml, which is ABSENT
|
||
└── i18n/ # 10 locales: en, zh, de, ru, pt, es, vi, id, tr (tr is RF-added)
|
||
```
|
||
|
||
Still wired into `docker-compose.yml`/`.release.yml`/`.gpu.yml`, `webui.sh`/`.bat`,
|
||
`pyproject.toml`, and still covered by `test/services/test_webui_*.py` (part of the
|
||
1986-green suite, 4 skipped). **Frozen: no new features here.** See §5.
|
||
|
||
### 2.7 Assets — `resource/` (load-bearing; accessed via `app/utils/utils.py` helpers)
|
||
|
||
```
|
||
resource/
|
||
├── fonts/ # 13 fonts — libass karaoke captions + cover.py; full Turkish glyph set. font_dir()
|
||
├── songs/ # 29 × .mp3 BGM library, whitelisted. song_dir()
|
||
├── hooks/ # en.yaml, tr.yaml hook-line catalogs (script/ugc.py, templates.py, catalog.py)
|
||
├── voices.yaml # curated ElevenLabs voice catalog backing GET /v1/voices (overridable)
|
||
└── public/index.html # static landing mounted at "/" by asgi.py:96 (content is stale MPT copy)
|
||
```
|
||
|
||
### 2.8 Runtime scratch — `storage/` (gitignored)
|
||
|
||
```
|
||
storage/ # .gitignore: /storage/ → untracked. NEVER commit.
|
||
└── tasks/reelforge/ # per-job render scratch; storage_dir()/task_dir(); bind-mounted so api+worker share artifacts
|
||
# storage/bgm/ = runtime BGM upload whitelist counterpart to resource/songs
|
||
```
|
||
|
||
### 2.9 Migrations — `migrations/` (Alembic, single linear chain)
|
||
|
||
```
|
||
migrations/
|
||
├── env.py, script.py.mako
|
||
└── versions/ # ~24 revisions. Base 1624fc8a02de (reelforge_initial_schema).
|
||
# HEAD f1a2b3c4d5e6 (identity_sso_scim). Linear, no branches/merges.
|
||
# Recent: e5f2a9c74b13 (access_governance_rbac_audit → audit_log + User.is_staff),
|
||
# f1a2b3c4d5e6 (identity_sso_scim → sso_connections/scim_tokens/
|
||
# security_policies/external_identities).
|
||
# Naming: YYYYMMDD_HHMM_<rev>_<slug>.py
|
||
```
|
||
|
||
### 2.10 Deploy — `docker/` + compose + Dockerfiles
|
||
|
||
```
|
||
docker/worker-entrypoint.sh # Celery worker bootstrap
|
||
Dockerfile · Dockerfile.gpu # base + GPU images
|
||
docker-compose.reelforge.yml # ACTIVE core stack: redis + api (uvicorn app.asgi:app :8080)
|
||
# + worker (celery -Q celery,render) + beat. Secrets via .env.reelforge (gitignored)
|
||
docker-compose.full.yml # FULL-STACK bring-up: core stack + web (ops/web.Dockerfile) + postgres,
|
||
# for local end-to-end runs. Env via .env.full.example. See §2.13 + Makefile.dev
|
||
docker-compose.yml / .release.yml / .gpu.yml # LEGACY MPT streamlit stacks (deprecate with webui)
|
||
```
|
||
|
||
### 2.11 Tests — `test/` vs `tests/` (intentional split)
|
||
|
||
```
|
||
test/ # LEGACY MPT unittest suite (incl. test_webui_*.py). Part of the 1986-green suite (4 skipped).
|
||
tests/reelforge/ # ~62–85 pytest modules — the ReelForge suite (mirror new features here)
|
||
tests/golden/ # acceptance.py + manifest.yaml (golden acceptance harness)
|
||
```
|
||
|
||
### 2.12 Docs — `docs/reelforge/`
|
||
|
||
`ARCHITECTURE.md`, `ARCHITECTURE_NEXT.md`, `ARCHITECTURE_RESTRUCTURE.md` (superseded
|
||
domain-move plan), `DATA_MODEL.md`, `API.md`, `INTEGRATION_CONTRACT.md`, `STATUS.md`,
|
||
`PLAN_COVERAGE.md`, `CONFIG.md`, `DEPLOYMENT.md`, `FEATURES.md`, `NEXT_PHASES.md`,
|
||
`ROADMAP_V2.md`, `SECURITY_AUDIT.md`, `DEVELOPMENT.md`, `RESEARCH_*.md`,
|
||
`PRODUCT_BLUEPRINT.md` (the 10-epic enterprise program; Epics 1-2 done, Epic 3 Billing
|
||
in progress), `RESEARCH_ENTERPRISE_OSS.md` (OSS due-diligence for the enterprise layer),
|
||
and **this file** (`REPO_STRUCTURE.md`).
|
||
|
||
### 2.13 Run harness — `ops/` + `Makefile.dev` + `docker-compose.full.yml`
|
||
|
||
The developer bring-up + verification harness (additive; no production runtime impact).
|
||
|
||
```
|
||
ops/
|
||
├── smoke.py # in-process ASGI smoke test (imports the app, exercises key routes) — PASS
|
||
├── seed.py # seed/bootstrap data for local + full-stack runs
|
||
├── web.Dockerfile(+.dockerignore) # image build for the Next.js web app (used by docker-compose.full.yml)
|
||
└── README.md # how to run the harness
|
||
Makefile.dev # dev targets: bring up the full stack, seed, smoke, lint/test shortcuts
|
||
scripts/dev-bootstrap.sh # one-shot local environment bootstrap
|
||
docker-compose.full.yml # full-stack compose (see §2.10)
|
||
.env.full.example # env template for the full-stack run
|
||
```
|
||
|
||
---
|
||
|
||
## 3. Append-point files (grow, never fork)
|
||
|
||
These files are **intentionally large and shared**. New features **append** to them
|
||
instead of creating parallel copies. That is the trade the "keep files in place"
|
||
directive makes: cohesion over count.
|
||
|
||
### Backend
|
||
|
||
| File | Lines | What gets appended |
|
||
|---|---|---|
|
||
| `app/models/schema.py` | 4164 | New Pydantic request/response DTOs (envelope-based `BaseResponse` subclasses) |
|
||
| `app/models/db/models.py` | 1544 | New ORM table class (`__tablename__` + `Mapped[]` columns) |
|
||
| `app/models/db/repositories.py` | 3646 | New `XRepository` class (data-access methods for the new table) |
|
||
| `app/router.py` | 101 | One `include_router()` line per new controller |
|
||
| `app/controllers/v1/jobs.py` | 1794 | New endpoints belonging to the core job pipeline (broll/rerun/dub live here) |
|
||
| `app/workers/tasks.py` | 616 | New Celery stage tasks that extend the pipeline DAG |
|
||
| `app/services/reelforge.py` | 1793 | New fields on `ReelForgeParams` + new pure stage transforms |
|
||
|
||
### Web (`web/lib/`)
|
||
|
||
- **`api.ts`** — the default home for endpoints; add one exported function per endpoint.
|
||
- **`types.ts`** — the single DTO/const source of truth; append the feature's types + clamp constants.
|
||
- **`calendar.ts`** — the emerging **escape hatch**: a new per-feature `lib/<feature>.ts`
|
||
module that reuses `API_BASE`/`ApiError`/`RequestOptions` from `@/lib/api` and
|
||
re-implements the tiny `request<T>()` locally, so the shared file is never touched.
|
||
|
||
### Mobile (`mobile/lib/` + registries)
|
||
|
||
- **`lib/api.ts`** — add a `// ---- §Feature ----` section of exported functions (or a self-contained `lib/<feature>.ts`, the `calendar.ts` template).
|
||
- **`lib/types.ts`** — append shapes/enums (mirror `web/lib/types.ts`).
|
||
- **`app/_layout.tsx`** — append one `<Stack.Screen name="<feature>" …/>` (route registry).
|
||
- **`app/(tabs)/me.tsx`** — append one `<Pressable … router.push("/<feature>")>` link card (Me hub).
|
||
|
||
---
|
||
|
||
## 4. WHERE-NEW-FILES-GO — concrete checklists
|
||
|
||
> Existing files stay put. Every item below is **additive**. Nothing in these
|
||
> checklists requires editing the 1986-green suite for structural reasons.
|
||
|
||
### 4.1 New backend feature `<name>`
|
||
|
||
**New files:**
|
||
1. `app/services/<name>.py` — domain logic. Single file by default; use a subdir
|
||
`app/services/<name>/` (with `__init__.py`) **only if genuinely multi-file**,
|
||
following the existing `avatar/`, `billing/`, `captions/`, `compose/`, `editing/`,
|
||
`publishers/`, `script/`, `storage/`, `tts/` pattern. Keep files 200–400 LOC, 800 max.
|
||
2. `app/controllers/v1/<name>.py` — v1 controller via
|
||
`app.controllers.v1.base.new_router()`; per-user auth via `x-api-key` → `User`;
|
||
every response through `utils.get_response(...)`; errors as `HttpException`.
|
||
3. `tests/reelforge/test_<name>.py` (+ `test_<name>_api.py` for larger features) —
|
||
unit + API tests, TDD, 80%+ coverage. **Do not add to legacy `test/`.**
|
||
4. `migrations/versions/<YYYYMMDD_HHMM>_<rev>_<slug>.py` — one Alembic revision whose
|
||
`down_revision` = current head (`f1a2b3c4d5e6`). Keep the chain linear.
|
||
|
||
**Appends to shared files (§3):**
|
||
- DTOs → `app/models/schema.py`
|
||
- ORM table → `app/models/db/models.py`
|
||
- Repository → `app/models/db/repositories.py`
|
||
- Register router → one line in `app/router.py`
|
||
- If it extends the render pipeline → stage in `app/workers/tasks.py` + params field in `app/services/reelforge.py`
|
||
|
||
**Placement rule — provider integrations go behind the existing seam, not top-level:**
|
||
a new TTS/avatar/billing/publisher backend is a **new module inside the existing
|
||
subdir** behind that subdir's Protocol/registry (e.g. new avatar provider →
|
||
`app/services/avatar/<provider>.py` registered in `avatar/base.py`; new payment
|
||
provider → `app/services/billing/<provider>_client.py` wired into `billing/service.py`).
|
||
|
||
### 4.2 New web page `<feature>`
|
||
|
||
1. **Route** → `app/<feature>/page.tsx` (`"use client"`, default export). Detail route
|
||
→ `app/<feature>/[id]/page.tsx`. Sub-setting → `app/settings/<feature>/page.tsx`.
|
||
Public-only → add its matcher to `middleware.ts` `isPublicRoute`; auth-only → `isProtectedRoute`.
|
||
2. **Components** → `components/<feature>/`: presentational `*.tsx` + a `use-<feature>.ts`
|
||
data hook + pure helpers (`format.ts`, `<feature>-utils.ts`, constant tables). Reuse
|
||
`components/ui/*`; do not fork primitives. Surface it with a nav
|
||
`<Button asChild><Link>` in the `src/features/jobs-library` dashboard view.
|
||
3. **API + types** — pick one:
|
||
- **(A) Append to `lib/api.ts` + `lib/types.ts`** (default): best for 1–3 endpoints
|
||
reusing existing DTOs; one cohesive client, one import path. Trade-off: edits a
|
||
2.3k-LOC hotspot (merge-conflict risk under parallel workflows).
|
||
- **(B) New `lib/<feature>.ts` module** (the `calendar.ts` pattern): best for a
|
||
cohesive endpoint group or a workflow that must not touch the shared file. Import
|
||
`API_BASE`/`ApiError`/`RequestOptions` from `@/lib/api`, replicate a local
|
||
`request<T>()`, keep feature-only DTOs inline (or add shared ones to `lib/types.ts`).
|
||
- **Rule of thumb:** 1–3 endpoints on existing types → **(A)**; a cohesive new
|
||
endpoint group or a parallel/independent workflow → **(B)**. Genuinely app-wide
|
||
cross-feature hooks (like `use-my-workspaces.ts`) go directly in `lib/`, not a feature dir.
|
||
|
||
### 4.3 New mobile screen `<feature>`
|
||
|
||
1. **Route screen** → `app/<feature>.tsx` (or `app/<feature>/[id].tsx`). Thin: reads
|
||
`useSession()`, orchestrates data, renders the manager component.
|
||
2. **Components** → `components/<feature>/`: `<Feature>Manager.tsx` (or `Section`) entry
|
||
+ small PascalCase pieces + lowercase helpers (`format.ts`, constants, hooks).
|
||
3. **API client** → append a `// ---- §Feature ----` section to `lib/api.ts`, **or**
|
||
create `lib/<feature>.ts` (the `calendar.ts` template) for a self-contained feature.
|
||
4. **Types** → append to `lib/types.ts` (mirror `web/lib/types.ts`).
|
||
5. **Register route** → append one `<Stack.Screen name="<feature>" …/>` to `app/_layout.tsx`.
|
||
6. **Link it** → append one `<Pressable>` link card to the Me hub in `app/(tabs)/me.tsx`
|
||
(add a `(tabs)/` entry only for a rare top-level tab; today only Create/Jobs/Me are tabs).
|
||
7. *(If it uploads media)* add `lib/pick-<feature>.ts` (normalize to `LocalFile`, then
|
||
`presignAndUpload` from `lib/api.ts`).
|
||
|
||
### 4.4 New supporting assets / infra
|
||
|
||
- **Bundled backend asset** → `resource/<category>/`, always accessed through an
|
||
`app/utils/utils.py` helper (mirror `font_dir()`/`song_dir()`/`resource_dir()`).
|
||
New category = new subdir + new helper; never hardcode paths.
|
||
- **User-uploaded runtime equivalent** → `storage/…` (gitignored; `resource/songs` ↔ `storage/bgm`).
|
||
- **Runtime output** → `storage/…` only, via `storage_dir()`/`task_dir()`. Never commit.
|
||
- **Hook/voice catalog entries** → edit the existing YAML data files
|
||
(`resource/hooks/<lang>.yaml`, `resource/voices.yaml`) — data, not code.
|
||
- **Deploy/service config** → extend `docker-compose.reelforge.yml` + `docker/`; leave
|
||
the legacy MPT compose files untouched.
|
||
- **Docs** → `docs/reelforge/<TOPIC>.md` (uppercase topic), cross-linked from `STATUS.md` / `PLAN_COVERAGE.md`.
|
||
- **User-facing UI** → `web/` or `mobile/`. **Never** extend `webui/`.
|
||
|
||
### 4.5 Templates worth reading before you start
|
||
|
||
- Backend feature: `app/controllers/v1/calendar.py` + `app/services/calendar.py`
|
||
- Web self-contained client: `web/lib/calendar.ts`; feature dir: `web/components/calendar/`
|
||
- Mobile self-contained client: `mobile/lib/calendar.ts`; route: `mobile/app/calendar.tsx`;
|
||
registry: `mobile/app/_layout.tsx`; link hub: `mobile/app/(tabs)/me.tsx`;
|
||
async-resource hook: `mobile/components/me/use-resource.ts`
|
||
- Enterprise service+controller: `app/services/rbac.py` + `app/controllers/v1/rbac.py`
|
||
(Casbin decision engine); refine admin adapters: `web/lib/refine/{data-provider,access-control}.ts`
|
||
- Desktop client: `apps/desktop/src` (native Rust/GPUI only).
|
||
|
||
---
|
||
|
||
## 5. KEEP / DEPRECATE / RUNTIME verdicts
|
||
|
||
| Area | Verdict | Rationale |
|
||
|---|---|---|
|
||
| `webui/` (Main.py, styles, i18n) | **DEPRECATE — retire candidate, do not delete yet** | Replaced by `web/` + `mobile/`. Still wired into 3 compose files + `webui.sh/.bat` and covered by `test/services/test_webui_*.py` (part of the 1986-green suite). Retiring = remove wiring + those tests as a deliberate later PR; out of scope for additive work. **Frozen; no new features.** |
|
||
| `resource/fonts/` | **KEEP — load-bearing** | libass captions + cover.py; Turkish glyphs; test-verified. |
|
||
| `resource/songs/` | **KEEP — load-bearing** | BGM library, whitelisted, test-verified. |
|
||
| `resource/hooks/` | **KEEP — load-bearing** | Hook catalogs for script/templates/catalog API. |
|
||
| `resource/voices.yaml` | **KEEP — load-bearing** | Backs GET /v1/voices; overridable. |
|
||
| `resource/public/index.html` | **KEEP (mount target) — content STALE** | Mounted at `/` by asgi.py; re-brand copy later, but the file must exist. |
|
||
| `storage/` | **RUNTIME-ONLY (gitignored)** | Untracked per-job scratch; bind-mounted. Never commit. |
|
||
| former `desktop/` Electron tree | **LEGACY REFERENCE** | Superseded by native Rust/GPUI under `apps/desktop`; no new product work. |
|
||
| `web/app/admin/` + `web/lib/refine/` | **KEEP — active (NEW, enterprise)** | refine-powered platform-admin console; gated on `User.is_staff`. |
|
||
| `app/services/{rbac,audit,admin,sso,scim,security_policy}.py` + controllers | **KEEP — active (NEW, enterprise)** | Access & Governance (Epic 1) + Identity/SSO (Epic 2). Epic 3 Billing in progress. |
|
||
| `ops/` + `Makefile.dev` + `docker-compose.full.yml` + `scripts/dev-bootstrap.sh` | **KEEP — dev harness (NEW)** | In-process smoke (`ops/smoke.py`, PASS), seed, full-stack bring-up. No prod-runtime impact. |
|
||
| `docker/` + `Dockerfile*` + `docker-compose.reelforge.yml` | **KEEP — active** | The live ReelForge deployment stack. |
|
||
| `docker-compose.yml` / `.release.yml` / `.gpu.yml` | **DEPRECATE (with webui)** | Legacy MPT streamlit stacks; retire alongside `webui/`. |
|
||
| `migrations/` | **KEEP — active** | Linear Alembic chain; head `f1a2b3c4d5e6` (identity/SSO), ~24 revisions. |
|
||
| `test/` | **KEEP — legacy but green** | MPT unittest suite; guards reused MPT pipeline + webui. |
|
||
| `tests/` (reelforge + golden) | **KEEP — primary** | ReelForge's own suite + golden harness. |
|
||
| `docs/reelforge/ARCHITECTURE_RESTRUCTURE.md` | **KEEP as record — SUPERSEDED** | The domain-move plan the directive overrode; keep for history, do not execute. |
|
||
| `docs/skill/`, `docs/*.jpg`, `.ipynb`, `sponsors/` | **KEEP (inherited MPT assets)** | Harmless; low priority. |
|
||
|
||
---
|
||
|
||
## 6. Why this doc does not move or split files
|
||
|
||
This map **intentionally keeps every existing file in place**. The directive is that
|
||
new features become **new files in the right place** and a small set of shared
|
||
append-point files (§3) that grow by appending. Concretely:
|
||
|
||
- The **1986-green suite** stays green with zero structural edits.
|
||
- The **domain-folder migration** in
|
||
[`ARCHITECTURE_RESTRUCTURE.md`](./ARCHITECTURE_RESTRUCTURE.md) (moving `app/services/`
|
||
and friends into `domains/` vertical slices, shattering the god-files) is a **valid
|
||
but deferred/optional** future refactor — not something any feature PR should trigger.
|
||
- If the god-files (`schema.py` 4164, `repositories.py` 3646, `web/lib/api.ts` 2305,
|
||
`mobile/lib/api.ts` 2072) ever become an intolerable hotspot, the **preferred
|
||
incremental relief is the per-feature module escape hatch** (`lib/<feature>.ts`, the
|
||
`calendar.ts` pattern) — additive, conflict-free, and reversible — **not** a big-bang move.
|
||
|
||
Key evidence files: `app/utils/utils.py` (dir helpers ~L92–137), `app/asgi.py`
|
||
(static mounts ~L90–96), `.gitignore` (storage + test whitelists),
|
||
`migrations/versions/20260813_1500_f1a2b3c4d5e6_identity_sso_scim.py` (head),
|
||
`web/lib/calendar.ts` + `mobile/lib/calendar.ts` (the per-feature-client escape hatch).
|
||
|
||
---
|
||
|
||
*Authoritative repo map + new-file convention. Supersedes the move-heavy parts of
|
||
`ARCHITECTURE_RESTRUCTURE.md`. Last updated 2026-08-13.*
|