← notes

Two package.json files, one repo, no workspace

Sep 26, 2023

Onchain insights and analytics for Base, as an Express backend and a Create React App frontend.

Two directories, two package.json files, two lockfiles, no root manifest and no workspace. This is how most small projects are laid out, chosen by default rather than decided, and it is worth writing down what it costs.

Two installs and two dependency trees is the visible half. The invisible half is that the API and its only consumer share no types, so the response shape exists twice, once in the route handler, once in whatever the React component assumes, and nothing checks they agree. That drift is silent and surfaces as undefined in the UI. The split origin also forces a dev proxy production does not need, plus CORS that exists purely because of the layout.

A workspace fixes the installs and gives somewhere for a shared types package, which is the real win, and does not fix the two-server dev story. For a project with a lifespan of weeks the flat layout is defensible; the mistake is not noticing it was a decision.

The version I would build now keeps the two servers and puts shared response types in a third directory both import.