Skip to content

Commit ba7df7b

Browse files
committed
docs: sync all documentation with post-cleanup state
1 parent c99b7b7 commit ba7df7b

7 files changed

Lines changed: 253 additions & 258 deletions

File tree

CLAUDE.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ Monorepo with two apps, skills, and shared infra. See [ADR-001](docs/adr-001-cla
1515
apps/api/ — FastAPI backend (Python 3.12, uv)
1616
src/helprs/
1717
core/ — config, database, dependencies, exceptions, middleware, security
18-
modules/ — domain modules: identity, installation, webhook, container (Phase 2)
18+
modules/ — domain modules: identity, installation, webhook, container
1919
admin/ — SQLAdmin panel + credential management
2020
tests/ — mirrors modules/ structure
2121
alembic/ — DB migrations
2222
apps/web/ — React frontend (Vite, TypeScript)
23-
src/features/ — feature modules: auth, dashboard, installation, session
24-
src/shared/ — shared components/utils
23+
src/features/ — feature modules: auth, landing, installation, session
24+
src/shared/ — API client (shared/api/client.ts)
2525
skills/ — Claude Code skill definitions (mounted into ephemeral containers)
2626
infra/
2727
docker/ — Dockerfiles (api, web, claude-runner)
@@ -57,8 +57,6 @@ Skills are pluggable Claude Code agent definitions in `skills/`. See `skills/SKI
5757
| Skill | Purpose | PR fetch strategy |
5858
|-------|---------|-------------------|
5959
| `challenge-me` | Socratic quiz on PR changes | Shallow clone |
60-
| `code-review` | Multi-layer adversarial review | Shallow clone |
61-
| `security-audit` | Vulnerability scan on diff | Diff only |
6260

6361
## Code Style
6462

PROJECT-STATUS.md

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ sequenceDiagram
5757
| **webhook** | `apps/api/src/helprs/modules/webhook/` | Webhook signature verification, event dispatch, persistent event storage, crash-recovery replay, periodic reaper |
5858
| **container** | `apps/api/src/helprs/modules/container/` | Container session CRUD, Docker lifecycle (create/start/stop/remove), SSE log streaming, TTL-based cleanup |
5959
| **admin** | `apps/api/src/helprs/admin/` | SQLAdmin panel at `/admin` for credential management |
60-
| **comprehension** | `apps/api/src/helprs/modules/comprehension/` | Pre-pivot DDD module (empty -- only `__pycache__` remains) |
61-
| **billing** | `apps/api/src/helprs/modules/billing/` | Removed per open-source pivot (empty -- only `__pycache__` remains) |
6260

6361
### Frontend features
6462

@@ -67,8 +65,8 @@ sequenceDiagram
6765
| **auth** | `apps/web/src/features/auth/` | OAuth callback handler, protected route wrapper, Zustand auth store |
6866
| **landing** | `apps/web/src/features/landing/` | Landing page with GitHub App install CTA |
6967
| **installation** | `apps/web/src/features/installation/` | Post-install setup flow (SetupView) and settings management (SettingsView) |
70-
| **session** | `apps/web/src/features/session/` | Skill selection UI (SkillSelector), container session management (ContainerSession), terminal output renderer (TerminalOutput), plus pre-pivot components (ChatPanel, ChatView, ScoreCard, etc.) |
71-
| **shared** | `apps/web/src/shared/` | SSE parser hook (`useSSE`), reduced-motion hook, viewport hook, theme tokens |
68+
| **session** | `apps/web/src/features/session/` | Skill selection UI (SkillSelector), container session management (ContainerSession), terminal output renderer (TerminalOutput) |
69+
| **shared** | `apps/web/src/shared/` | API client with auth token management |
7270

7371
### Skills system
7472

@@ -91,7 +89,7 @@ Skills are mounted read-only into ephemeral containers via Docker volume binds.
9189

9290
## 3. What's Built
9391

94-
### Backend (35 source files, 25 test files)
92+
### Backend (25 source files, 25 test files)
9593

9694
**Core infrastructure** -- stable, tested:
9795
- App factory with async lifespan managing DB engine (`apps/api/src/helprs/main.py`)
@@ -113,17 +111,17 @@ Skills are mounted read-only into ephemeral containers via Docker volume binds.
113111
- BYOK credential storage (Fernet-encrypted Anthropic API keys)
114112
- Installation access token minting via GitHub API
115113
- PR comment posting with retry logic
116-
- 4 test files (router, service, BYOK router, BYOK service, suppression service)
114+
- 5 test files (router, service, BYOK router, BYOK service, suppression service)
117115

118116
**Webhook module** -- stable, tested:
119117
- HMAC-SHA256 signature verification
120118
- Event dispatcher routing by event type + action
121119
- Persistent webhook event storage for crash recovery
122120
- Replay system: boot-time replay + periodic reaper (5-minute interval)
123121
- PR opened handler: creates container session + posts PR comment with session link
124-
- 5 test files (dispatcher, handlers, repository, replay, router, verification)
122+
- 6 test files (dispatcher, handlers, repository, replay, router, verification)
125123

126-
**Container module** -- new, tested (no real Docker integration yet):
124+
**Container module** -- tested (no real Docker integration yet):
127125
- `ContainerSession` ORM model with status enum (pending/running/completed/failed/timeout)
128126
- `DockerClient` protocol + `AioDockerClient` production implementation (aiodocker)
129127
- Session CRUD: create, get, get-or-404
@@ -133,13 +131,9 @@ Skills are mounted read-only into ephemeral containers via Docker volume binds.
133131
- Resource limits: 512MB memory, 1 CPU, 15-minute TTL
134132
- 3 test files + 1 integration test (service, router, models, container flow)
135133

136-
**Alembic migrations** -- 10 migration files:
137-
- `github_users`, `installations`, `webhook_events`, `sessions`
138-
- `byok_configs`, `suppression` (installation settings)
139-
- `questions`, `answers`, `scores`, `reports_and_feedback` (pre-pivot, may need cleanup)
140-
- `container_sessions` (new)
134+
**Alembic migrations** -- 10 migration files covering all tables. Note: 5 pre-pivot comprehension migrations remain in history (sessions, questions, answers, scores, reports_and_feedback) -- the backend code is removed but migration files are retained for history.
141135

142-
### Frontend (42 source files, 23 test files)
136+
### Frontend (14 source files, 6 test files)
143137

144138
**Auth flow** -- stable:
145139
- `OAuthCallback.tsx` -- handles GitHub OAuth redirect, exchanges code for token
@@ -154,31 +148,16 @@ Skills are mounted read-only into ephemeral containers via Docker volume binds.
154148
- `SetupView.tsx` -- post-install configuration wizard
155149
- `SettingsView.tsx` -- installation settings management
156150

157-
**Session flow** -- new container components + pre-pivot comprehension components:
158-
159-
New (container-based):
151+
**Session flow** -- container-based:
160152
- `SkillSelector.tsx` -- displays available skills as cards (challenge-me, code-review, security-audit), 1 test
161153
- `ContainerSession.tsx` -- manages container lifecycle (create session, connect SSE, display output, stop), 1 test
162-
- `TerminalOutput.tsx` -- terminal-like renderer with macOS-style window chrome, auto-scroll, amber accent, 1 test
154+
- `TerminalOutput.tsx` -- terminal-like renderer with macOS-style window chrome, auto-scroll, 1 test
163155
- `containerApi.ts` -- API client for container endpoints
164156
- `containerTypes.ts` -- TypeScript types for container sessions
165157
- `SessionView.tsx` -- route component orchestrating SkillSelector and ContainerSession
166158

167-
Pre-pivot (still in tree, partially orphaned):
168-
- `ChatPanel.tsx`, `ChatView.tsx`, `ChatMessage.tsx` -- interactive Q&A session UI (pre-pivot comprehension flow)
169-
- `ScoreCard.tsx`, `SessionFeedback.tsx`, `ReportButton.tsx` -- scoring and feedback components
170-
- `DiffViewer.tsx`, `CodeLink.tsx` -- code diff rendering
171-
- `AnswerInput.tsx`, `SessionHeader.tsx` -- session interaction components
172-
- `SplitLayout.tsx`, `MobileLayout.tsx`, `TabbedLayout.tsx` -- layout components
173-
- `store.ts`, `useSession.ts`, `types.ts` -- session state management
174-
- 17 test files for pre-pivot components
175-
176-
**Shared** -- stable:
177-
- `useSSE.ts` -- SSE connection hook with reconnection logic, 1 test
178-
- `parseSSE.ts` -- SSE event parser, 1 test
179-
- `useReducedMotion.ts` -- accessibility hook for reduced motion preference
180-
- `useViewport.ts` -- responsive viewport hook
181-
- `tokens.ts` -- design system theme tokens
159+
**Shared**:
160+
- `api/client.ts` -- fetch wrapper with auth header injection, 401 retry, re-auth redirect
182161

183162
**Routing** (`app.tsx`):
184163
- `/` -- Landing page
@@ -239,14 +218,11 @@ Pre-pivot (still in tree, partially orphaned):
239218
### Frontend integration
240219

241220
- **Frontend calls the right endpoints but hasn't been tested against a running backend.** The `containerApi.ts` client, `ContainerSession.tsx` SSE connection, and `TerminalOutput.tsx` renderer are built but only unit-tested with mocks.
242-
- **No dashboard page exists.** The app routes from landing -> install -> settings -> session, but there's no `/dashboard` showing all installations and their sessions. (Referenced in project memory as a known gap.)
221+
- **No dashboard page exists.** The app routes from landing -> install -> settings -> session, but there's no `/dashboard` showing all installations and their sessions.
243222

244-
### Cleanup needed
223+
### Package cleanup
245224

246-
- **Pre-pivot comprehension components**: 15+ files in `apps/web/src/features/session/` (ChatPanel, ChatView, ChatMessage, ScoreCard, DiffViewer, AnswerInput, SessionHeader, etc.) with 17 test files are from the pre-pivot interactive Q&A approach. They are not used by the new container-based flow but remain in the tree.
247-
- **Pre-pivot comprehension module**: `apps/api/src/helprs/modules/comprehension/` has empty directory structure (domain, application, infrastructure, presentation) with only `__pycache__`.
248-
- **Pre-pivot billing module**: `apps/api/src/helprs/modules/billing/` is empty (only `__pycache__`).
249-
- **Pre-pivot migrations**: `questions`, `answers`, `scores`, `reports_and_feedback` tables were created for the comprehension flow and are no longer needed by the container approach. They add schema weight without serving the current architecture.
225+
- `react-diff-view` and `react-resizable-panels` remain in `package.json` but are no longer used by any component. They should be removed.
250226

251227
---
252228

@@ -268,7 +244,7 @@ Pre-pivot (still in tree, partially orphaned):
268244
3. **Error handling and retry logic.** Container creation failures, Docker daemon unavailability, SSE connection drops.
269245
4. **Logging and monitoring.** Structured logs for container lifecycle events are in place; add metrics (container count, duration, success rate) and alerting.
270246
5. **Rate limiting per installation.** Current rate limits are per-IP; add per-installation limits to prevent abuse.
271-
6. **Pre-pivot code cleanup.** Remove empty `comprehension` and `billing` modules, pre-pivot frontend components, and orphaned database migrations.
247+
6. **Remove unused npm packages.** `react-diff-view`, `react-resizable-panels`, `refractor`, `react-markdown`, `remark-gfm` are leftover from the pre-pivot UI and no longer imported.
272248

273249
### P2 -- Feature expansion
274250

@@ -285,7 +261,6 @@ Pre-pivot (still in tree, partially orphaned):
285261
2. **Mobile responsive layout.** Terminal output and skill selection on small screens.
286262
3. **Documentation site.** MkDocs config exists (`mkdocs.yml`) but is not deployed.
287263
4. **Contributing guide for skill authors.** How to create a new skill, test it locally, submit a PR.
288-
5. **Accessibility.** `useReducedMotion` hook exists but is not wired to all animated components.
289264

290265
---
291266

@@ -325,9 +300,6 @@ Pre-pivot (still in tree, partially orphaned):
325300
| Zustand | ^5.0.12 | State management |
326301
| React Query | ^5.97.0 | Server state / data fetching |
327302
| React Router | ^7.14.0 | Client-side routing |
328-
| react-markdown | 10.1.0 | Markdown rendering |
329-
| react-diff-view | 3.3.3 | Diff rendering (pre-pivot) |
330-
| react-resizable-panels | 4.9.0 | Split panel layout (pre-pivot) |
331303
| Vitest | ^4.1.4 | Testing |
332304
| Testing Library | ^16.3.2 | Component testing utilities |
333305
| ESLint | ^10.2.0 | Linting |

README.md

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,55 @@
11
# helPRs
22

3-
Socratic comprehension sessions for pull requests. helPRs helps developers deeply understand code changes by guiding them through interactive question-and-answer sessions on PRs.
3+
Pluggable AI skill runner for pull requests. helPRs spins up ephemeral Docker containers running Claude Code CLI to execute skills (comprehension quizzes, code reviews, security audits) against PRs and streams results back in real time.
4+
5+
**BYOK model** -- users provide their own Claude credentials. The backend never calls the Claude API directly; containers use the credentials natively.
46

57
## Quick Start
68

79
```bash
8-
# Copy environment variables
9-
cp .env.example .env
10+
# Start all services (API :8000, Web :5173, Postgres :5432)
11+
docker compose up --build
12+
13+
# Run tests
14+
make test
1015

11-
# Start all services (api, web, db)
12-
make dev
16+
# Lint
17+
make lint
1318
```
1419

15-
Services:
16-
- **API**: http://localhost:8000 (FastAPI + OpenAPI docs at `/docs`)
17-
- **Web**: http://localhost:5173 (React + Vite)
18-
- **DB**: PostgreSQL 16 on port 5432
20+
## How It Works
1921

20-
## Development
21-
22-
```bash
23-
make lint # Run ruff (backend) + eslint (frontend)
24-
make test # Run pytest (backend) + vitest (frontend)
25-
make build # Build production Docker images
26-
make migrate # Run Alembic database migrations
27-
```
22+
1. GitHub PR event hits the webhook receiver
23+
2. API posts a PR comment with a session link
24+
3. User selects a skill (or auto-trigger if configured)
25+
4. Backend spins up an ephemeral Docker container with Claude Code CLI
26+
5. Container runs the skill against the PR
27+
6. Results stream back via SSE passthrough to the frontend
28+
7. Container is destroyed after completion or timeout
2829

2930
## Project Structure
3031

3132
```
32-
helprs/
33-
├── apps/
34-
│ ├── api/ # FastAPI backend (Python 3.12, uv)
35-
│ └── web/ # React frontend (Vite, Tailwind v4)
36-
├── infra/
37-
│ ├── docker/ # Dockerfiles + nginx config
38-
│ └── coolify/ # Production deployment config
39-
├── docker-compose.yml
40-
├── Makefile
41-
└── .env.example
33+
apps/api/ -- FastAPI backend (Python 3.12, uv)
34+
apps/web/ -- React frontend (Vite, TypeScript, Tailwind 4)
35+
skills/ -- Claude Code skill definitions
36+
infra/docker/ -- Dockerfiles (api, web, claude-runner)
37+
infra/coolify/ -- Production docker-compose
4238
```
4339

4440
## Tech Stack
4541

46-
| Layer | Technology |
47-
|----------|-------------------------------------|
48-
| Backend | Python 3.12, FastAPI, SQLAlchemy 2 |
49-
| Frontend | React 19, Vite, Tailwind CSS v4 |
50-
| Database | PostgreSQL 16 |
51-
| Infra | Docker, GitHub Actions, Coolify |
42+
| Layer | Technology |
43+
|------------|-------------------------------------------|
44+
| Backend | Python 3.12, FastAPI, SQLAlchemy 2, uv |
45+
| Frontend | React 19, Vite, Tailwind CSS v4, Zustand |
46+
| Database | PostgreSQL 16 |
47+
| Containers | Docker, aiodocker, Claude Code CLI |
48+
| Infra | GitHub Actions, Coolify, GHCR |
49+
50+
## Documentation
51+
52+
- **[PROJECT-STATUS.md](PROJECT-STATUS.md)** -- detailed status, what's built, what's not yet working, roadmap
53+
- **[CLAUDE.md](CLAUDE.md)** -- developer context (quick start, patterns, gotchas)
54+
- **[docs/](docs/)** -- architecture, data models, API contracts, component inventory
55+
- **[docs/adr-001-claude-code-container-pivot.md](docs/adr-001-claude-code-container-pivot.md)** -- architecture decision record for the container pivot

docs/architecture-api.md

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Architecture -- Backend (api)
22

3-
> Auto-generated on 2026-04-17 (post-pivot rewrite)
3+
> Updated 2026-04-17 (post-cleanup)
44
55
## Executive Summary
66

@@ -15,7 +15,7 @@ FastAPI backend serving as a container orchestrator, webhook receiver, and admin
1515
| ORM | SQLAlchemy | >= 2.0.36 | Async ORM (asyncpg driver) |
1616
| Migrations | Alembic | >= 1.14 | Schema migrations |
1717
| Settings | Pydantic Settings | >= 2.7 | Typed env var config |
18-
| Container | Docker SDK | TBD | Ephemeral container lifecycle |
18+
| Container | aiodocker | >= 0.23 | Async Docker client for ephemeral container lifecycle |
1919
| Logging | structlog | >= 24.4 | Structured logging |
2020
| Monitoring | Sentry SDK | >= 2.19 | Error tracking |
2121
| Rate Limiting | SlowAPI | >= 0.1.9 | Per-IP rate limiting |
@@ -26,8 +26,6 @@ FastAPI backend serving as a container orchestrator, webhook receiver, and admin
2626
| Testing | pytest + pytest-asyncio | >= 8.3 | Test framework |
2727
| Linting | ruff | >= 0.8 | Linter + formatter |
2828

29-
**Removed:** pydantic-ai (no longer needed -- AI runs in containers)
30-
3129
## Architecture Pattern
3230

3331
```
@@ -50,14 +48,16 @@ FastAPI backend serving as a container orchestrator, webhook receiver, and admin
5048
| +-- middleware.py CORS, timing
5149
| +-- security.py JWT, Fernet, HMAC
5250
|
53-
+-- modules/
54-
+-- identity/ (Flat: router -> service -> model)
55-
+-- installation/ (Flat: router -> service -> model)
56-
+-- webhook/ (Flat: router -> dispatcher -> handlers -> model)
57-
+-- container/ (NEW: container orchestration + result relay)
51+
+-- modules/ (All flat pattern)
52+
+-- identity/ (router -> service -> model)
53+
+-- installation/ (router -> service -> model)
54+
+-- webhook/ (router -> dispatcher -> handlers -> model)
55+
+-- container/ (router -> service -> model)
5856
```
5957

60-
### Flat Modules (identity, installation, webhook)
58+
### Flat Module Pattern
59+
60+
All four modules use the same structure:
6161

6262
```
6363
module/
@@ -67,20 +67,9 @@ module/
6767
+-- schemas.py # Pydantic request/response schemas
6868
```
6969

70-
### Container Module (new)
71-
72-
```
73-
container/ # Coming in Phase 2
74-
+-- router.py # Container session endpoints + SSE relay
75-
+-- service.py # Container lifecycle (provision, inject creds, destroy)
76-
+-- orchestrator.py # Docker SDK integration (create, start, stream, remove)
77-
+-- models.py # ContainerSession SQLAlchemy model
78-
+-- schemas.py # Request/response schemas
79-
```
80-
81-
**Removed:** `comprehension/` DDD module (domain/, application/, infrastructure/, presentation/) and `billing/` stub.
70+
The webhook module adds `dispatcher.py`, `handlers.py`, `verification.py`, `tasks.py`, and `repository.py` for its event processing pipeline.
8271

83-
## Backend Role (Post-Pivot)
72+
## Backend Role
8473

8574
The backend is a **thin orchestrator**, not an AI host:
8675

@@ -120,5 +109,5 @@ The backend is a **thin orchestrator**, not an AI host:
120109
1. **No AI in the backend**: all AI logic runs inside ephemeral containers
121110
2. **BYOK model**: each installation provides their own Claude credentials
122111
3. **SSE passthrough**: backend relays container output, does not generate AI responses
123-
4. **Flat modules only**: removed DDD layer -- all modules use the simple flat pattern
112+
4. **Flat modules only**: all modules use the simple flat pattern (router/service/models/schemas)
124113
5. **Background webhook processing**: raw events persisted first, dispatched async with retry

0 commit comments

Comments
 (0)