Overview
Audit the existing FastAPI server and refactor all routes to delegate logic to core.* modules. The server should be a thin adapter, not contain business logic.
Background
Per the v2 architecture principle:
CLI (typer) ─┬── core.* ─── adapters.*
│
Server (fastapi) ─┘
Server and CLI are siblings, both calling core. This ensures:
- No duplicate logic between CLI and server
- Server can be optional (CLI-first philosophy)
- Easier testing (test core once, not twice)
Deliverables
1. Route Audit
2. Core Module Mapping
Ensure each CLI command has a corresponding core function that the server can also call:
| CLI Command |
Core Module |
Server Route |
cf init |
core.workspace |
POST /api/workspaces |
cf prd add |
core.prd |
POST /api/projects/{id}/prd |
cf prd generate |
core.prd_discovery |
POST /api/projects/{id}/prd/generate |
cf tasks generate |
core.tasks |
POST /api/projects/{id}/tasks/generate |
cf work start |
core.runtime |
POST /api/tasks/{id}/start |
cf work follow |
core.streaming |
GET /api/tasks/{id}/stream |
cf blocker answer |
core.blockers |
POST /api/blockers/{id}/answer |
| ... |
... |
... |
3. Refactor Pattern
For each route:
# Before (inline logic)
@router.post("/tasks/{task_id}/start")
async def start_task(task_id: str):
task = db.get_task(task_id)
task.status = "IN_PROGRESS"
db.save(task)
return {"status": "started"}
# After (delegate to core)
@router.post("/tasks/{task_id}/start")
async def start_task(task_id: str):
from codeframe.core import runtime
result = await runtime.start_task_run(task_id)
return result
4. Route Consistency
Acceptance Criteria
Related Issues
References
docs/V2_STRATEGIC_ROADMAP.md - Phase 2 requirements
docs/CLI_WIREFRAME.md - CLI command → module mapping
Overview
Audit the existing FastAPI server and refactor all routes to delegate logic to
core.*modules. The server should be a thin adapter, not contain business logic.Background
Per the v2 architecture principle:
Server and CLI are siblings, both calling core. This ensures:
Deliverables
1. Route Audit
codeframe/server/andcodeframe/ui/routers/2. Core Module Mapping
Ensure each CLI command has a corresponding core function that the server can also call:
cf initcore.workspacePOST /api/workspacescf prd addcore.prdPOST /api/projects/{id}/prdcf prd generatecore.prd_discoveryPOST /api/projects/{id}/prd/generatecf tasks generatecore.tasksPOST /api/projects/{id}/tasks/generatecf work startcore.runtimePOST /api/tasks/{id}/startcf work followcore.streamingGET /api/tasks/{id}/streamcf blocker answercore.blockersPOST /api/blockers/{id}/answer3. Refactor Pattern
For each route:
4. Route Consistency
/api/{resource}/{id}/{action}Acceptance Criteria
core.*modulesRelated Issues
References
docs/V2_STRATEGIC_ROADMAP.md- Phase 2 requirementsdocs/CLI_WIREFRAME.md- CLI command → module mapping