Splitting an API, a web app, and Studio in one repo
I keep the public site, the API, and the editor in one pnpm monorepo, with a hard line between what is public HTTP and what is Studio-only.
chrishacia.com is a pnpm monorepo. The public site, the API, and Studio live in one repository, with their own packages, and they share a release. That is a choice I would make again, with the same boundary I keep insisting on: the public HTTP surface and the editor are not the same app just because they share a database.
Why one repo
The journal, the work entries, the media library, and the agent API all talk about the same records. If those lived in three repositories, I would spend the week aligning types and hoping a deploy order was right. One repo means one pull request can change a schema, the API that uses it, and the Studio screen that edits it.
The split inside the repo still matters. I keep an `apps/api` package for Express and Prisma, and an `apps/web` package for the public site and the Studio UI. Shared contracts can live in a package both of them depend on. What I do not want is the web app importing a server module and accidentally bundling a database client into a public page.
The line I will not blur
Studio is an authenticated editor. The public journal is a published, cacheable set of pages. They can share components for typography or a date format. They should not share "if I am logged in, also show the draft controls" on the public page unless that path is deliberate, tested, and still hidden from search.
The agent MCP tools sit on the API, behind OAuth grants. That is the same data Studio uses, with a different door in front of it. I wrote about that door in [Letting AI agents talk to my site, with OAuth and scoped grants](/journal/letting-ai-agents-talk-to-my-site-with-oauth-and-scoped-grants). The monorepo makes those tools easier to keep in the same change as the routes they call. It does not make them public.
How the pieces run
Locally, the database comes up with a named script, and the API and web apps have their own dev commands. In production, a release builds both, then a deploy script points a current symlink at that release. The details are in [Release folders and a symlink, so a deploy can roll back](/journal/release-folders-and-a-symlink-so-a-deploy-can-roll-back).
The thing I would tell someone starting a similar site is: one repo is fine. One package for everything is not. Give the API and the web app their own `package.json`, their own tests, and a shared contract that is boring to change. Then be strict about which of those packages is allowed to talk to the database, and which is allowed to be cached on the public internet.