What Gets Easier and Harder When the App, API, and Admin Share One Repository
Sharing domain types in the 21N monorepo: a look at the benefits of code reuse together with the blast radius of shared changes.
Joohwan Yu · Founder, Full Stack Developer
Toris · Published
Contents
At 21N (21앤), the user app, the API, and the admin web all dealt with the same contract domain. That was also why I chose a monorepo. If you write the contract states and common types separately for each product, you have to apply the same change several times, and slightly different definitions easily creep in.
The Repetition Sharing Removed
Being able to see app and server changes together in one repository helped when working full-stack. When an API response type changed, it was easy to find which screens were affected. I also organized the local environment into a flow that runs the admin, API, and database together.
But being able to import a type is different from each app being deployed at the same time. Mobile apps in particular may not be updated by users. Just because you fixed everything at once in the repository does not mean every client in production understands the new rule.
The Questions That Arise as the Shared Package Grows
If you mix in server-only code just because it can be shared, the app’s dependencies widen needlessly. Today, I would separate domain types from runtime implementations. I would not put state names everyone needs to know and external-service settings only the server should know into the same convenience package.
Also, a change to a shared type can show compile errors, but it cannot verify compatibility with older apps on your behalf. Before deleting a field, you have to check what existing clients send and expect. The advantage of a monorepo must not hide this difference in deployment timing.
Three Things to Check Again
First, I would confirm the list of apps that actually use the changed shared package. Second, I would look at whether the meaning of requests and responses holds, not just type checks. Third, I would review whether existing apps still work even if the server ships first. These three are the same change checked at different layers.
A monorepo was a tool that suited me well, but it did not automatically produce a good structure. In exchange for the advantage of seeing shared changes at a glance, I had to handle the blast radius more responsibly. On the next project too, before the number of repositories, I will decide which contracts to share and which boundaries to deploy independently.
Related record: Monorepo Setup of the 21N Platform
Advertisement