When to use and not use a mono-repo?

default discord avatar
Taun
last week
11

Hi. For general curiosity, and to perhaps help others who are also unclear of this - what are the typical use-cases of using a mono-repo, such as the Nextjs-custom-server template of Payload, vs using a two repos for back-end and front-end?


What have been the pros and cons in your experience?

  • default discord avatar
    noheadphones
    last week

    I think your deployment strategy is going to have the biggest influence on this



    Personally I will still deploy Payload separately if I intend the API to be used or integrated with other systems or complex systems..like if I need consistent and fast response times from Payload



    For marketing sites or situations where the API is needed just more sporadically, I think mono should be fine and the simplest and quickest method



    My concern with the latter would be, what happens if the site grows out and I need to deploy Payload separately instead...the migration from the local API to a rest/gql one wouldnt be very pleasant



    I haven't yet had a project where end users would be given access to Payload's admin UI, usually its a custom and more limited admin panel...so that situation might affect the solution

  • default discord avatar
    Taun
    last week

    Thanks Paul. Have you used the Nextjs custom-server repo? I was experiencing errors and strange behaviour with that compared to using separate repos. Is there a higher risk of these kinds of rare and buggy errors to occur when using a mono repo? I assume because it's all packaged in 1- there's a higher chance of corrupting files?



    Have you had more issues with the mono-repo than duo?

  • default discord avatar
    noheadphones
    last week

    I haven't used the mono repo yet, not properly anyway

  • default discord avatar
    Arctomachine
    last week

    Monorepo is good when you are working on both front and back ends at the same time and host them together. It is one app that acts as whole, so it is great choice to keep codebase in one place

  • default discord avatar
    Taun
    last week

    Yea, but there must be cons that comes with that, I'm interested to get more insight into that, such as deployment limitations. Perhaps a mono-repo is better for specific use-cases, and problematic for others.

  • default discord avatar
    Arctomachine
    last week

    For me biggest challenge for this approach would be scalability. While app is small, it can be hosted on vps just by running each process inside pm2. But what if it needs multiple servers, each with few copies of processes running? So far it is beyond my knowledge

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.