Standalone Express backend eliminated: everything moves into Next.js route handlers

elitan deleted the `backend/` package entirely and relocated its code under the Next.js app. The result is one process, one set of dependencies, one deployment unit - but the migration introduced an HTTP compatibility shim that you'd be inheriting.

infrastructure

The main commit (b7320066) removes the backend/ directory - its package.json, src/index.ts (a 130-line Hono bootstrap), nixpacks.toml, tsconfig.json, and lockfile are gone. The actual route handlers, lib code, LLM modules, and DB layer are preserved and moved to frontend/src/server/backend/.

Traffic now enters through a catch-all Next.js route at frontend/src/app/api/v1/[[...path]]/route.ts. Auth paths go to better-auth. Everything else hits an oRPC RPCHandler, with an OpenAPIHandler as fallback. The former Express routes are reached via handleBackendRequest, which is dispatched after a hardcoded prefix list check (/chat, /projects, /tabular-review, etc.).

The key abstraction is frontend/src/server/backend/http/compat.ts (230 lines). The old Hono-style handlers weren't rewritten for Next.js - the compat module adapts their signatures to the Fetch API. This kept the migration's blast radius small. But it means you're not getting idiomatic Next.js route handlers; you're getting a shim that makes old Hono code work inside Next.js.

The ba3270f4 "Codex worktree snapshot" commit is noise. It re-adds backend/src/lib/supabase.ts (deleted by the prior commit), adds a CONTRIBUTING.md that still references the old two-package structure, and leaves unresolved merge markers in README.md. The supabase.ts is dead code that gets cleaned up by the folder rename downstream. Filter this commit out if cherry-picking.

9fd7e44b merges upstream main, pulling in a minor cleanup in userApiKeys.ts.

The practical deployment change: NEXT_PUBLIC_API_BASE_URL now points at http://localhost:3000/api/v1 instead of http://localhost:3001. The separate backend startup command is gone.

So what A meaningful architectural bet: single-service deployment, lower operational overhead. The cost is `compat.ts` and a catch-all route handler that bypasses standard Next.js routing. Before importing, verify streaming, body size limits, and request-cloning behaviour against your deployment target - particularly if you're on Cloudflare Workers via opennext, which is what upstream configures.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?

Commits in this thread

3 commits from elitan/mike, oldest first. Source extracted verbatim from the harvested git log.

SHA Subject Author Date
b7320066 refactor(api): move backend into next route handlers Johan Eliasson 2026-05-15 ↗ GitHub
ba3270f4 Codex worktree snapshot: archive-cleanup Johan Eliasson 2026-05-15 ↗ GitHub
Co-authored-by: Codex
9fd7e44b refactor(api): merge latest main Johan Eliasson 2026-05-15 ↗ GitHub

Capture this thread into my fork

Download a single Markdown prompt that tells Claude how to port every commit above into your working tree — adapting paths and structure to match your repo. Run it via claude -p < capture-thread-413.md from inside the repo you want the changes in.

⬇ Download capture-thread-413.md