Architecture
Status mix: CURRENT PHP/MySQL CodeShare. PLANNED experiment platform. FUTURE vision workers and router.
CURRENT runtime
| Layer | Choice | Why it is what it is |
|---|---|---|
| App | PHP 8 in app/pastesv2 | Same host as Reversal apps; fastest integration |
| HTTP | Apache root .htaccess | Clean URLs on pastes.reversal.org |
| DB | MySQL pastes_db | Existing CodeShare + legacy Paste table |
| Auth | EE Holdings session + local users + Google | Shared identity |
| Keys | pvsk_ hashed SHA-256 | Agent ingest without OAuth in Cursor |
| Command | Encrypted bind + HTTP forward | Per-project notes without exposing pvsk_ to agents |
Request path today:
Browser or agent -> TLS -> Apache rewrite -> PHP index.php or api/v1/*/index.php -> PDO -> pastesv2_* tables.
There is no job queue, no object store, no Playwright, no separate FastAPI service.
Target platform (PLANNED / FUTURE)
The strategy paper recommends:
- Frontend: Next.js / React / TypeScript when the experiment UI outgrows PHP pages (Phase 4+). Until then, CodeShare + Command PHP UIs.
- Core API: keep PHP for ingest and Command integration; add Python workers for eval/vision (Phase 3). FastAPI is optional, not a rewrite mandate.
- Database: PostgreSQL when version/experiment volume and JSON querying justify a migration. MySQL can carry Phase 1-2 if tables stay normalized.
- Queue: Redis + workers (Celery or PHP workers). Required before Playwright and LLM-as-judge.
- Object storage: S3 / R2 / MinIO for screenshots. Not LONGBLOB.
- Auth: continue EE identity + scoped API keys.
- Observability: OpenTelemetry + structured logs (PLANNED).
- Browser: Playwright (Phase 3).
- Vision: pluggable providers behind EE VIZN (FUTURE).
- ML: Python, scikit-learn / XGBoost, PyTorch only when rankers exist (Phase 7).
- Deploy: Docker when workers exist. Kubernetes only when queue depth and multi-region require it.
Scaling strategy
- Vertical MySQL + PHP for notes (CURRENT).
- Add
paste_versions+ratingson MySQL (Phase 1-2). - Offload assets to object storage; add Redis workers (Phase 3).
- Split read models for leaderboards (Phase 4).
- Migrate experiment OLTP to PostgreSQL if JSON and advisory locks become painful (Phase 4-5).
- Kubernetes last.
Do not start at step 6. A paste bin that cannot record a score does not need a cluster.
Diagram
See diagrams/architecture.mmd and the rendered copy in the main paper.
