When to use and not use a mono-repo?

default discord avatar
taun2160last year
9

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
    paulpopuslast year

    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
    taun2160last year

    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
    paulpopuslast year

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

  • default discord avatar
    arctomachinelast year

    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
    taun2160last year

    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
    arctomachinelast year

    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

  • default discord avatar
    johnrisby10 months ago

    Just thought I'd chip in here. After working with PayloadCMS for a month or so and transitioning some existing mongodb data, as well as moving some other content from (whisper it) WordPress, I've now realised my decision to use the local api wasn't wise. I found this while searching for any simple way to convert calls from local api to the rest api.



    Thankfully there's not a huge number of calls in the project (22, actually), so it won't take forever to change them hopefully but ...



    I hadn't fully thought deployment and scalability through but now realise I am better separating the CMS from the web site (both in terms of the code and also servers).



    Thankfully my actual code for my project isn't merged with Payload - it's a separate app, but I was using the local api as they were both on the same server. But it's certainly something I wish I'd have given more thought too and hopefully this may help someone else.



    I would imagine it makes more sense if you wanted to do something like a custom next.js front end to payload - that would work - but otherwise it does seem using the rest or graphql approach makes more sense.



    There, that's my moment of shame in the hope of helping someone out 😉

  • default discord avatar
    paulpopus10 months ago
    I hadn't fully thought deployment and scalability through but now realise I am better separating the CMS from the web site (both in terms of the code and also servers).

    Why? The local API should,, in theory, just be an instance of payload just with direct access to the database...so deployment yeah can be a bit trickier but I dont think scalability would be that affected

  • default discord avatar
    johnrisby10 months ago

    if I'm misunderstanding something, great, I'd love to know but what I mean is I want to move payload onto a separate server from my next.js app (which is all behind an nginx reverse proxy). if they are on separate machines, I can't use the local api can I?

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

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