Decoupling frontend from backend
Hopefully, you’ll not find anything revolutionary or cutting edge in this article, but in case you’ve been working on a X-year long project in a conservative organisation, you might find these words useful.
How to keep frontend separate from backend? #
Simple. Treat them as two different apps from day one.
- Backend — RESTful api. Outputs JSON only. No HTML whatsoever.
- Frontend — Static files only. HTML/JS/CSS/Images/Fonts. Served by NGINX/Apache. All rendering happens in browser only. Data is AJAXed from the the API.
In your organisation, frontend will likely be on separate server(s) from backend. Likely developed by completely different teams, individuals.
Actually, the fact that frontend is developed by different ppl from backend, is the key reason to keep in in a separate repo, in a separate server, in a separate production environment.