r/devops • u/BigBootyBear • Oct 19 '26
Architecture To monorepo or not?
My startup is in consumer electronics. The product is 1 device with 1-2 peripherals that come with it. Users connect to a mobile app with a backend that does data analysis on what the product measures.
ATM I have 4 repos: a flutter app and a FastAPI backend with sqlite. The embedded side uses PlatformIO+Arduino for the device/hub, and same stack for the peripehrals.
The DevOps is getting unwieldy. On the one side, I'd like everything to be in one place so agents can easily build up a context and CI/CD is not scattered. On the other hand, I hate working with massive project trees and loading up vscode would be a nightmare.
Thoughts? At work I use git submoduels but I was told that's not a monorepo.
76
u/stevecrox0914 Oct 19 '26
I prefer seperate git repositories.
The CI process can assume the repository root has the build management configuration. That makes CI and CD far simplier
Each repository has to publish its artefacts for other repositories to use them.
That encourages a release process and encourages your programmers to respect a dependency.
It encourages you to treat each unit as a self contained item, which ensures good code boundaries.
Lastly a single repository with git sub modules of your repositories gives many of the actual benefits of a monorepo. Best of all worlds in my opinion
14
u/WonderfulTill4504 Oct 19 '26 edited Oct 20 '26
Avoid submodules unless you enjoy the complexities of pinning your main repo to a module. I have a few of those and they suck balls.
Go to mono-repo and put a layer on top of it to manage the sub projects like buck2. If is pure python is even simpler, each submodule is self contained with a is own pyproject.toml.
If is Java, use Gradle with Kotlyn or even Maven (you probably like pain but each to its own). Avoid Ant.
For C++ try to use something like Conan to avoid mounting compilers and shit over NFS.
There are many ways to skin this cat. Looks like you have a code base so moving independent projects into a mono-repo is your first task so try to keep their own folder structure (and fix the ones fucked) and use buck2.
7
u/brian_sword Oct 19 '26
I think a monorepo would be a great choice in your case, since the Flutter app, FastAPI backend, and embedded firmware are all parts of the same product. Having everything in one place can make CI/CD and AI assisted development easier.
But it is also important not to force everything into one giant workspace. You can keep each component in its own directory with separate dependencies, build scripts, and CI jobs.
6
u/solatic Oct 19 '26
Forget the repository structure for one minute. Focus on the deployment cadence and how quickly you can get something rolled out in production.
If you haven't shipped anything to production / customers yet, everything is in a garage, then a monorepo makes sense. You deploy changes to the Arduino multiple times a day as you build the thing. Letting an agent make changes to FastAPI + Flutter + embedded at the same time is awesome. You can start with a monorepo.
Eventually though that monorepo is gonna lie to you. You can't actually roll out the change to embedded or Flutter as quickly as you roll out the FastAPI changes. And that's gonna bite you when an agent removes something from the backend that people running an older version of the mobile app still need, or when the agent changes mobile to add visibility into something new in the embedded code that just doesn't exist out there yet.
Start with monorepo while you're iterating on the MVP. Break out into polyrepo when release cadence reality catches up to you and having formal interfaces between backend / frontend / embedded helps you release each one independently, and make changes to each one independently, within its natural release cadence.
4
u/SikhGamer Oct 19 '26
Love monorepos. If all your stuff is constantly talking backwards and forwards then it's the only way.
3
u/LogicalExtension Oct 19 '26
Monorepo is great if you have a whole lot of stuff that moves together and needs to stay that way or re-uses a bunch of common code. One git commit can make changes across everything that touches it.
It's not all rainbows and lollipops though.
A well structured series of git repos isn't really any harder for an agent to navigate, and in many cases can be easier. A huge monorepo can result in agent context windows getting filled quickly while it tries to figure out how everything fits together.
Both can be helped by good AGENT.md files.
3
u/kolorcuk Oct 19 '26
Great repos, 4 repos seems very ok.
I do not get, just clone 4 repos for you agent.
3
u/the_frisbeetarian Oct 19 '26
I would not prematurely split repositories until there is an obvious reason for doing so. Testing a product e2e is way easier to do in a monorepo. From an agentic standpoint it is also easier to iterate on a monorepo with Claude versus the inverse. My company has hundreds of repos. I would love to unwind all of that. The majority of our day isn’t spent developing the product. It is spent coordinating dependencies.
2
u/Relevant_Pause_7593 Oct 19 '26
Monorepos here might solve these problems- but it will also create new ones. Are some things better? Sure. But now you have to manage merge queues, etc.
What is ok, is to combine a couple repos together- because overly distributed repos can crest headaches too.
2
u/115v Oct 19 '26
Never was a fan of mono repos. As long as you’re documenting properly it should be fine
2
u/BoBoBearDev Oct 19 '26
GUI components, monorepo. Otherwise, there is no reason to use monorepo. Microservices was supposed to be independent.
2
u/mysteryweapon Oct 19 '26
I have a friend that works for an org that recently decided that monorepo was the way to go
Everything was starting to be migrated to it, and then they found that the GHA were overwhelming hosted enterprise GitHub
The solution? Why, build your bespoke github server instead
I hear that mono repos can be great in the right situation, but they can also be absolutely terrible, and I don't think they are appropriate for every org
1
u/jake_mok-Nelson Oct 24 '26
For a startup where products are highly related, a monorepo makes sense. Especially in a time of LLMs where harnesses rely on git pretty heavily.
When you realise your API has a lot of consumers and is needing extra attention, break it out, and so on.
You're not a large enterprise, and you don't need the extra process this early in all likelihood.
1
u/jameshearttech Oct 19 '26
At work our main repo is a mid-sized monorepo containing 50+ projects. I work in it daily with VS Code in a dev container running claude code in the terminal.
1
u/zMynxx Oct 19 '26
I believe it depends on the lifecycle of the generated artifact, whether it is shared on not
1
u/Kookoombar Oct 19 '26
On the embedded point: the flashed binary is still an artifact, it's just a .bin or .hex rather than an image. Have CI build each firmware target, name the file with the version and git SHA, and publish it somewhere versioned like an S3 bucket or the release assets. Add a small manifest saying which app and backend versions it was tested with, so flashing a device is just pulling a known file.
Whichever repo layout you pick, that artifact step is what keeps releases traceable, and it makes rollbacks a lot less painful when a device is already out in someone's house.
1
u/Triple-B-564 Oct 19 '26
I’d go for monorepo/not change your current setup (giving value to customer, get more customer is more important than repo setup).
You’ve got one product with tightly related pieces: firmware, peripherals, backend, and mobile app. That usually means changes tend to span multiple repos, especially around protocols, data formats, versioning, and release coordination.
Your CI/CD concern is valid, but it’s usually manageable with path-based triggers so you only build/deploy the parts that changed. So a change in Flutter doesn’t need to trigger firmware builds, and vice versa.
I’d avoid git submodules unless you have a very specific reason to use them. They add complexity without really giving you the same benefits as a true monorepo.
That said, there’s no perfect answer.
For a startup, the bigger priority is delivering value quickly rather than spending too much time optimizing repo structure too early. A monorepo can make coordination easier, especially when different parts of the product need to stay in sync.
1
u/3loodhound Oct 19 '26
No
1
u/Mundane_Section_7146 Oct 19 '26
Yes
1
u/ryan_builds_ci Oct 19 '26
the thing that usually decides this is where the contract between device, app and backend lives. if the payload format or api schema changes, you want that change in one PR that touches all three sides, otherwise the versions drift quietly and you find out in the field. one pattern that helps is a single repo with path-filtered CI, so firmware only builds when firmware/ changes while the app and backend stay independent. and for the vscode thing, opening just the subfolder you're working in means the tree size mostly stops mattering.
1
u/disoculated Oct 19 '26
Unless you're going to only have a very small team of developers forever, or if you are big enough to have a team that manages your developer infrastructure, you will probably not see a big benefit from a monorepo. It can be challenging enough to just get an entire company into a single github organization.
1
u/Rakn Oct 20 '26
Monorepos in bigger companies need dedicated teams managing them. If you are a 1-3 person startup it doesn’t really matter too much. The important thing to remember is that just because it’s all in one repository doesn’t mean it’s doesn’t require some sort of structure.
1
u/hamzezn Oct 20 '26
We run about a dozen products (FastAPI backends, several frontends, a mobile app) in one repo, mostly so AI agents and CI see everything in one place. It works, with a few things I'd do differently from the start:
on: push: paths: ['firmware/**']) so a Flutter change doesn't rebuild the firmware.For 4 repos that all ship as one product, I'd merge them. The firmware is the only part I'd think twice about, since it releases on a different cadence, but a folder plus path-filtered CI handles that fine.
1
u/aidenclarke_12 Oct 20 '26
4 repos that size still makes a small monorepo, path filters in ci keep each folder building separately and Vscode can just open the subfolder you need
1
u/pdp10 Oct 20 '26
Think hard about what you just typed.
Consumer electronics can easily have a written contract API to loosely-couple the backend and the client. Smooth operations are going to need strategy to cope with aged client codebases, anyway.
1
u/ight-bet Oct 21 '26
Yeah you can definitely mono repo this.
Depends how many people are developing.
You can at least combine flutter, fast api and db stuff. Leaving the embedded out. But if not many devs just throw it all in 1
1
u/hiasmee Oct 21 '26
Do mono for dev, split later for production.
We have mono repository with:
And I love it. We have two mobile aps and one desktop app. For every feature we had to do commits to different repos. Now one feature one pr. It is simple and fast.
When our dev and beta phase are done we will probably split it, but now, if you don't want to outsource some features, this is the best solution at least for us.
And it is better for AI agentic development process.
1
u/sngz Oct 21 '26
can't believe some of the answers I'm reading here. monorepo vs multiple repo is a choice to solve organizational issues that seep into technical costs. there are trade offs to using both.
1
u/abhinavs1920 Oct 19 '26
Four repos is below the size where monorepo tooling pays for itself. The pain you're describing isn't repo count, it's CI being defined four times - reusable workflows from one shared repo make the scatter mostly go away while the trees stay small. The agent-context problem is solvable without merging too: a workspace file or a thin index repo the agent clones alongside the real ones. Submodules are the worst of both options: monorepo tree, separate-repo tooling.
1
u/zukke3000 Oct 19 '26
Does it matter? Stuff like that is an imitation of work. Just pick something and stick to it, until it gets painful. Focus of bringing value to your startup, not on rewriting pipelines each Thursday.
0
u/Manic5PA Oct 19 '26
Monorepo is a bit like microservices, where it can make sense in some cases, but 99% of the people doing it have no real use case to justify the effort and end up building something truly abominable.
0
u/notrufus Oct 19 '26
I have a monorepo for the majority of my system. 3 typescript apps for a shop management system.
I have a separate repo for some FOSS libraries that are free for whoever to use.
One plus is that AI works really well with them. Since all of the context/skills/etc are shared, making changes involving multiple services are really easy to coordinate.
Also, CI versions everything and deploys them consistently every time a merge to main happens, that way if there’s an issue, I can roll everything back to the previous working system.
0
u/Brothapleasedont Oct 19 '26
I've never been forced to work in a monorepo, so anytime I see them it hurts. I feel like with monorepos you trade wayyyy too much architectural felixibility for convenience. They feel like immediate tech debt to me, but I've never been a monorepo guy.
0
u/ChiRho84 Oct 20 '26
Monorepos are for monoliths. Also, Conway's Law.
0
u/[deleted] Oct 19 '26
[deleted] — view deleted comment
23
u/[deleted] Oct 19 '26
[removed] — view removed comment
6
u/[deleted] Oct 19 '26
[removed] — view removed comment