Scaling a Kotlin codebase is mostly an argument about boundaries, and the argument runs in opposite directions depending on whether the project is growing or shrinking. Growth wants more seams so several people can work without colliding; contraction wants fewer pieces so a small team can still hold the whole thing in view. The materials are the same — Gradle modules, package layers, published interfaces — only the direction reverses.
Growing: split where change already happens
Early Kotlin projects tend to be split by technical layer — models here, services there, screens on top — and that arrangement ages badly, because a single feature edits all three. When you consider a new module, look at where the code has actually been changing and cut there instead.
A module that changes for one reason earns its build cost. A module called utils does not, because every feature ends up editing it and you have bought the paperwork of a boundary without the isolation.
Shrinking: merge the seams that stopped paying rent
When a project loses scope or contributors, the modules do not disappear on their own. Each empty layer still adds a build step, a dependency declaration and a place to look. Merging two modules is dull work — move the sources, move the tests in the same commit, fix the visibility, delete the empty directory — but it pays back every single day afterwards.
Delete code that nothing calls, and be honest about the difference between “unused” and “used only by the test that exists to keep it alive”. The second category is how a small codebase quietly becomes a large one.
Numbers to watch instead of a feeling
- Clean build time on a cold Gradle cache, measured before and after any restructuring.
- Time to compile a one-line change, which is what you feel all day.
- Count of modules and published APIs, tracked so growth is visible rather than gradual.
- Number of files a typical feature touches, which shows whether the seams follow the work.
Write these down before the change. Restructuring is easy to justify and hard to judge, and four numbers taken twice will settle an argument that intuition cannot.
Move in one commit that CI can prove
Whether you add or remove a boundary, keep the mechanical steps together: move files, update the Gradle build scripts, adjust imports, and let the pipeline run the full test suite on the result. A refactor spread across a week of commits leaves the project temporarily broken and teaches everyone to distrust large changes. One reviewable commit, with the tests green, is the version that survives contact with a real team.
Scale up by adding a boundary where work already divides, scale down by removing one that no longer divides anything, and measure the build both times. The direction matters less than the discipline of choosing it deliberately.