I’m building a small “newsroom” application where Django handles the backend (API, authentication, admin) and Vue 3 handles the frontend UI. I’m still fairly new to combining Django with a modern JavaScript framework, and I’m running into questions about the correct project structure.

My goal is:

  • Django provides a REST API

  • Vue 3 (with Vite) is the standalone frontend

  • The frontend and backend will be deployed separately later

  • Local development should be simple, with minimal configuration

Right now my folder structure looks like this:

newsroom/
    backend/
        manage.py
        newsroom/
            settings.py
            urls.py
        articles/
            models.py
            views.py
            serializers.py
    frontend/
        src/
        vite.config.js
        package.json

I’m unsure if this is considered a good pattern or if there are better ways to organize a Django + Vue project where the frontend is completely decoupled. I also want to make sure this structure won’t cause problems when I start working with authentication and serving the built Vue files in production.

My questions:

  1. Is this a clean and maintainable structure for a Django + Vue 3 project, or should the frontend be inside the Django project folder?

  2. When deploying, is it better to serve Vue separately as its own static site, or build the Vue app and let Django serve the compiled files?

  3. Are there any common pitfalls when using Django REST Framework with a Vite-based Vue frontend (CORS, static files, routing, etc.) that I should prepare for early?

I’ve read several articles but most of them use older setups (Webpack, or Vue inside Django templates), so I’m hoping for advice based on current best practices with Django REST + Vue 3 + Vite.

5 Replies 5

I'd keep them in separate repositories. One for the backend, one for the frontend. Deploy them separately, since they have vastly different requirements. The frontend just needs to be built once, and then it's just a bunch of static files. Deploy that on some static host (e.g. AWS S3) and serve it through a CDN with well configured caching. The backend can be deployed wherever is best for scalability and cost. Don't serve the frontend from the backend, because your backend server running dynamic Python doesn't need to be bothered for serving some static CSS files.

Thanks for the clear explanation. This helps a lot. One question: if I keep both projects inside one monorepo for development (Django in a backend folder and Vue in a frontend folder), is that still considered a reasonable approach as long as I deploy them separately? I just want to make sure I’m not creating issues later when I move to production.

Sure, if you want to, you can keep them in one repo. It has the advantage of making version synchronisation easier (your frontend will likely depend on the backend being the same version to provide the APIs it needs). However, it might also make some things slightly more complicated, for example if you have a CI/CD pipeline which automatically deploys every new version; with a shared repo, it'll always trigger a deploy for both, even if just one of them changed. It also clutters the folder more; many tools put some files at the top level of the repo for configuration and stuff, and since a frontend and backend use very different tools, it may either get cluttered or even conflict in some extreme cases.

Thanks, that makes sense. The version sync benefit is exactly why I was considering a monorepo, but your point about CI/CD triggering unnecessary deploys is helpful. I might start with a monorepo while developing and then split them later once the project grows. Appreciate the clarification.

This isn't specific to Vite because for any build tool the result is usually dist directory with static files to deploy. frontend certainly shouldn't be located inside backend, this doesn't serve a good purpose.

Regarding the monorepo argument, CI/CD pipelines can be configured to not be triggered by the changes in irrelevant paths. But unless both projects share some files between them (in JS-only monorepo, these could be at least configurations and dependencies, but this is not the case), there's no benefit from a monorepo, it could be split instantly. Version synchronization can be achieved solely through git tags.

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.