---
id: 18
title: "Backend: Project-scoped API routes"
assignee: claude
tags: [backend, projects, api]
created: 2026-02-10
---

## Description

Refactor the HTTP handler to support project-scoped API routes. All existing endpoints get a project prefix.

### New API shape

```
GET  /api/projects                              → list all projects
POST /api/projects                              → create a new project
GET  /api/projects/{slug}/board                 → board data for project
POST /api/projects/{slug}/board/tasks           → create task
PUT  /api/projects/{slug}/board/tasks/{id}      → update task
DELETE /api/projects/{slug}/board/tasks/{id}    → delete task
POST /api/projects/{slug}/board/tasks/{id}/move → move task
GET  /api/projects/{slug}/prompts               → list prompts
POST /api/projects/{slug}/prompts               → create prompt
...same pattern for documents, comments, poll, activity, diff
```

### What to build

1. **Route parsing** — Extract project slug from URL path, look up the Project instance from Workspace.
2. **Handler refactor** — BoardHandler currently uses class-level `board`/`prompts`/`documents`. Change to resolve per-request from the project slug.
3. **Project CRUD** — `GET /api/projects` returns project list. `POST /api/projects` creates a new project directory with scaffolded structure.
4. **Single-project mode** — When running in single-project mode (backward compat), all existing `/api/board` etc. routes still work, mapped to the sole project.

## Acceptance Criteria
- [ ] All existing endpoints work under `/api/projects/{slug}/...`
- [ ] `GET /api/projects` returns list of projects with slug, name, description
- [ ] `POST /api/projects` scaffolds a new project directory
- [ ] Handler resolves Board/ResourceStore per-request from project slug
- [ ] Single-project backward compat: `/api/board` still works when only one project
- [ ] 404 for unknown project slugs

## Notes
