refactor: decompose api.py into data domain modules #42

Closed
opened 2026-05-01 12:09:35 -07:00 by pyr0ball · 1 comment
Owner

Context

api.py (630 lines) is a catch-all for the label loop, IMAP fetch, config, stats, benchmark orchestration, and finetune triggers. Extract each into its own module under app/data/.

Work

  • Extract label/queue/skip/discard/undo/config routes → app/data/label.py
  • Extract IMAP fetch routes → app/data/fetch.py (from imap_fetch.py)
  • Extract SFT corrections routes → app/data/corrections.py (from sft.py)
  • Move app/imitate.pyapp/data/imitate.py
  • api.py becomes app factory only (~80 lines: imports, router mounts, SPA static files)

Acceptance

  • All existing tests pass
  • API routes unchanged (no URL changes)
  • api.py < 100 lines
## Context `api.py` (630 lines) is a catch-all for the label loop, IMAP fetch, config, stats, benchmark orchestration, and finetune triggers. Extract each into its own module under `app/data/`. ## Work - Extract label/queue/skip/discard/undo/config routes → `app/data/label.py` - Extract IMAP fetch routes → `app/data/fetch.py` (from `imap_fetch.py`) - Extract SFT corrections routes → `app/data/corrections.py` (from `sft.py`) - Move `app/imitate.py` → `app/data/imitate.py` - `api.py` becomes app factory only (~80 lines: imports, router mounts, SPA static files) ## Acceptance - All existing tests pass - API routes unchanged (no URL changes) - `api.py` < 100 lines
pyr0ball added this to the v2 — Pipeline Architecture milestone 2026-05-01 12:09:35 -07:00
pyr0ball added the
backend
reorg
labels 2026-05-01 12:09:35 -07:00
Author
Owner

Shipped in the Apr 19–May 4 sprint. api.py is now a factory-only wiring file; routes live in label.py, fetch.py, corrections.py, imitate.py, cforch.py with backward-compat redirects.

Shipped in the Apr 19–May 4 sprint. api.py is now a factory-only wiring file; routes live in label.py, fetch.py, corrections.py, imitate.py, cforch.py with backward-compat redirects.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Circuit-Forge/avocet#42
No description provided.