Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate Git Repos for frontend and backend web development

I have been researching git submodules, git subtrees and sparse checkouts and I simply cannot wrap my head around it. Here is my use case:

I have one repo, lets say frontend-repo, that not only holds files for a AngularJS based frontend, but some folders relating to testing, documentation, etc. A subfolder in this repo, called 'codebase', stores the HTML, CSS and JS for the app.

I have another repo, lets say backend-repo, which holds the python/flask backend, which initially serves the AngularJS app. Those files need to be located in the application/static subfolder.

When doing development and testing, we need to edit the files in application/static, debug, test, iterate until done. Basically, I have been trying to find a way using git to have a local checkout of the frontend/codebase folder into the backend repo. Submodules I can't get to work; subtree doesn't seem to be able to handle this use case either.

What is the best practice here? I could simply setup a symlink from one dir to the other, but I was hoping git had a nicer way of doing this. Does anyone have experience in this kind of workflow?

like image 432
mrquintopolous Avatar asked Apr 30 '14 17:04

mrquintopolous


People also ask

Should I put frontend and backend be in separate repos?

It depends upon your web site or application. If you are using your backend for only rest api only then I would suggest to seperate your frontend code as it will be much less clutter. But if you are using it for templating html output then you will have to keep it in same repo.

Should frontend and backend be in separate folders?

Backend server and the frontend client are two totally separate things, so yes, they both have their own node_modules folders.

Should frontend and backend be deployed separately?

Your Frontend and backend must be decoupled. In other-words, the frontend and backend should be platform/technologically independent of each other. So your front end should either be in MVVM (Angular or React) or using only AJAX for data binding. The backend must only have Restful API or WebService.


Video Answer


1 Answers

If I understand your question, you want two repositories. One for the back-end and one for the front-end? And you'd like your front-end to be a sub-directory of the back-end?

What's the trouble, both subtrees and submodules seem fine. Submodules are a little more clunky to work with imo though.

Just make everything part of your back-end repo, and subtree split out the changes periodically to your front end repo from the sub-directory.

like image 176
johnb003 Avatar answered Nov 15 '22 05:11

johnb003