Search code examples
reactjsgitfrontendbackenddevops

How to store frontend and backend in git?


Our team has a small web application project. We don't understand how the backend and frontend should be stored in git.

There are several ideas: store both frontend and backend in different repositories, store both in the same repository but in different branches, or store them in different directories.

Are there any industry standards or widely accepted best practices regarding this?


Solution

  • Definitely don't put them in branches. Branches are for working on the same content simultaneously, not for storing completely different content.

    With that out of the way, it depends if you want to run this as one project, or two.

    One repo

    A single repo is simpler. You don't have to coordinate changes and releases between the front and back end. If you have a bug or a feature, it can be coded and tested and released in one project.

    The downsides are that the front and back end will tend to tangle themselves together if you're not careful.

    Two repos

    This is more complex. It requires that changes and releases be split between distinct front and back end repos and coordinated. For example, if you want to add a feature that touches both ends you need two issues in two projects changing two repositories and then released in coordination.

    The back end will, effectively, be a dependency of the front end. It will need a clearly defined API for the front end to use. This can be good as it will keep the back and front end implementations separated, but it has costs.

    Which to use?

    If you're not familiar with coordinating multiple dependent projects, and you don't have a solid reason to keep the back and front ends separated, do the simple thing and use one repo.

    You can always split it later, however it will be harder to untangle.