A monorepo template that actually works

When you get it right, you’ll never go back.A practical monorepoI’ve worked on dozens of projects ranging in size from the common 1–2 dev side project to full-scale enterprise applications. Monorepo architecture is a popular approach that can be intimi…


This content originally appeared on Level Up Coding - Medium and was authored by Jacob Bennett

When you get it right, you’ll never go back.

A practical monorepo

I’ve worked on dozens of projects ranging in size from the common 1–2 dev side project to full-scale enterprise applications. Monorepo architecture is a popular approach that can be intimidating at first but is a surprisingly powerful tool.

(As an aside, Medium uses a monorepo for all of its product services. It works really well for our team.)

I’m a strong proponent of starting new projects with a monorepo and only breaking things out once the monorepo stops working for specific (limited) use cases.

My favorite monorepo structure is simple, easy to adopt, and lasts forever.

lib: shared libraries

The /lib/ directory contains shared code. These libraries may be deployed to package managers (e.g. npm, PyPI). They should be independent of each other.

If you have code that’s used by multiple projects, add that code to /lib/. Common code in this folder includes protobuf definitions, custom error wrappers, and domain models.

Libraries in /lib/ must not be deployed as a standalone application (those are projects).

projects: deployed services

Projects in /projects/ are independent, deployable applications. They stand completely separate from each other and must be able to be deployed independently (i.e. you can deploy project1 without deploying project2).

If projects need code shared between them, that code belongs in /lib/.

secrets: encrypted secrets for the monorepo

/secrets/ contains encrypted secrets for the monorepo. Each secret (or directory of secrets) should contain an accompanying README that explains what the secret is and how it should be used.

Secrets are often used in build pipelines, but they can also be used in development environments. For example, a secret might contain a private API key that is used to access a third-party service.

This directory should not be imported by other directories.

tools: internal tooling

/tools/ contains configurations and code for internal tools.

This directory should not be imported by other directories.

Examples of common tools here include Terraform modules and internal CLIs.

I put together a template monorepo on GitHub. Good luck with your monorepo!

GitHub - bennett-jacob/monorepo: A practical monorepo template


A monorepo template that actually works was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Level Up Coding - Medium and was authored by Jacob Bennett


Print Share Comment Cite Upload Translate Updates
APA

Jacob Bennett | Sciencx (2022-11-16T03:17:10+00:00) A monorepo template that actually works. Retrieved from https://www.scien.cx/2022/11/16/a-monorepo-template-that-actually-works/

MLA
" » A monorepo template that actually works." Jacob Bennett | Sciencx - Wednesday November 16, 2022, https://www.scien.cx/2022/11/16/a-monorepo-template-that-actually-works/
HARVARD
Jacob Bennett | Sciencx Wednesday November 16, 2022 » A monorepo template that actually works., viewed ,<https://www.scien.cx/2022/11/16/a-monorepo-template-that-actually-works/>
VANCOUVER
Jacob Bennett | Sciencx - » A monorepo template that actually works. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/11/16/a-monorepo-template-that-actually-works/
CHICAGO
" » A monorepo template that actually works." Jacob Bennett | Sciencx - Accessed . https://www.scien.cx/2022/11/16/a-monorepo-template-that-actually-works/
IEEE
" » A monorepo template that actually works." Jacob Bennett | Sciencx [Online]. Available: https://www.scien.cx/2022/11/16/a-monorepo-template-that-actually-works/. [Accessed: ]
rf:citation
» A monorepo template that actually works | Jacob Bennett | Sciencx | https://www.scien.cx/2022/11/16/a-monorepo-template-that-actually-works/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.