Skip to content

Instantly share code, notes, and snippets.

@rikukissa
Last active September 10, 2023 14:12
Show Gist options
  • Select an option

  • Save rikukissa/726bb514d42a85fbb43bd9e70c25f3db to your computer and use it in GitHub Desktop.

Select an option

Save rikukissa/726bb514d42a85fbb43bd9e70c25f3db to your computer and use it in GitHub Desktop.
Should I have my UI and my API in separate repositories?
# Is it a good practive to have separate repositories for backend and frontend?
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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment