Hacker News new | ask | show | jobs
by hk1337 1377 days ago
I found that treating each directory as its own separate application or package is helpful. If you need to share resources between multiple apps/packages, use your dependency manager, most of them seem to have some sort of way to use local packages.
1 comments

Exactly! Frontend, backend, or desktop monorepo structure for Java, Rust, Typescript, etc:

  /src
    /lib
      /mysql-common
      /redis-common
      /...
    /services
      /app-1
      /app-2
      /...
You can use other directories to group assets, database migrations, documentation - whatever. The core build, test, CI, etc. tools can live in the root.

The ability to share common code and not have to worry about packaging internal libraries, versioning them, and rolling out updates n-many times is a game changer.

And if an app/package did grow to the point it needed its own repository, all the packages depending on it just need to update their dependency configuration to the new source.
The most typical case of this happening I've seen is an ancient unsupported legacy app. You still need to deploy it, but you only build it every few months or so. You rarely touch the thing, and its dependencies are pinned to old versions. The lack of support tends to drag down the rest of the monorepo, so it'll sometimes get "kicked out" as a bad citizen.

Really only reserved for the worst cases.