My personal view is that in most cases is best to have everything in just one repository.
my-project/
frontend/
backend/
This is to make the daily work within the project as easy as possible. This makes sense as most features require changing both how the frontend and the backend works.
Pros of having all projects in one repository
- Much nicer to navigate the project and make changes
- Easy come up with descriptive commit messages + you see all changes you've made with
git status - You can run tests for all projects at once
- No risk of deploying non-matching / incompatible versions of the project
Cons of having all projects in one repository
- Some tools are not made with monorepos in mind. Especially all tools that build you project (CI tools, static site hosts) sometimes make assumptions of where your "
public" directory is. Most of these can be configured these days tho. - If you are building a multipurpose standalone API meant to be used in many projects (that cannot be in the same monorepo), this might not be the best approach. I'd suggest you use a monorepo if the subprojects are clearly linked and depend on each other.
Cons of using 2 separate repositories:
- You need to create 2 separate commits for each increment
- Changes are reviewed in two separate PRs
- 2 repositories can easily get out of sync when one PR is accepted before the other one is ready
- "Why isn't this feature working? 🤔" "Ah, I forgot to pull in the latest changes from the backend repo"