Best architecture for modern Django Projects

Hello everyone,

I’d like to open this topic to encourage a constructive discussion within the Django community about its role and usage in building modern applications.

Personally, I use Django primarily for backend management, as I prefer to handle the frontend using dedicated frameworks and libraries (such as React, Astro, Next.js, Expo/React Native, etc.).

Across various projects where I’ve integrated tools like JWT, Django REST Framework (DRF), Channels, Redis, Celery, WebSockets, Server-Sent Events (SSE), and more, I’ve consistently appreciated how Django enables rapid development. It’s particularly well-suited for startups or for quickly prototyping and validating new ideas.

Now, with the rise of AI-powered applications (e.g., chatbots, autonomous agents, etc.), I find myself wondering what the most effective and modern stack would be—one that embraces Django’s modular nature while covering the wide range of current development needs.

Recently, I came across Django Ninja (which I hadn’t used before) and noticed it shares many similarities with FastAPI, a popular choice for projects involving LangGraph and other tools used to build AI agents and chatbots.

This brings me to the core of my question:

In your opinion, what is the most comprehensive stack that allows Django to meet all the development needs of modern applications?

Does it make sense to integrate Django Ninja for handling SSE (for AI chat interfaces) and use DRF for CRUD operations, user authentication, and related functionalities within the same project?

In most of my recent work, I already rely on Django Channels and ASGI. I’ve tried DRF EventStream for SSE, but it doesn’t seem to offer the same level of flexibility or suitability for chatbot-style streaming responses as FastAPI does.

Given these considerations, for complex applications involving CRUD operations, user management, real-time chat, Stripe integration, and more—do you think it’s worth breaking away from Django’s monolithic structure in favor of a microservices-based architecture?

I’m thinking particularly in the context of startups that prioritize rapid development and future scalability (understanding, of course, that for projects that grow significantly in terms of user base, the architecture can be evolved at a later stage).

I’d love to hear your thoughts:

What’s your opinion and what would your ideal technological roadmap look like for building this type of application?

Architectural decisions are by their nature (and by definition in the academic sense) highly context sensitive.

There is no such thing as a one-size-fits-all answer to questions like these. These decisions need to be made by factoring in things like the true project requirements, timeline, staff size, experience, knowledge and skills. You may also need to account for things like legal and regulatory requirements.

You also want to account for your real needs and a reasonable / realistic plan for growth as opposed to some founder’s dream of becoming the next AWS next month. (Which, BTW, happens a lot less frequently than what every “big idea” person imagines.)

Hi Ken,

I agree with your perspective—there’s no one-size-fits-all architecture that meets every requirement. If there were, we’d lose the creative and challenging aspect of designing tailored solutions.

My question was aimed at exploring the current state of the Django ecosystem as a whole, with the intention of fostering a modular comparison of the best libraries currently available.

Specifically, my uncertainty lies in handling asynchronous contexts typical of chatbot applications. While researching online, I came across multiple alternatives for similar use cases. That’s why I wanted to understand what you believe to be the most effective solution for integrating such functionality with Django—comparing, for instance, FastAPI implementations versus Django Ninja, or WebSocket-based solutions versus those using StreamingHttpResponse and SSE-like approaches.

If you think this question is too broad for the forum, we can close the topic if needed. I was simply curious to learn about modern alternatives in terms of libraries, so I can further expand my knowledge and improve how I integrate the framework. :slight_smile:

No, I don’t think it’s too broad, because I think it raises a perspective that deserves discussion.

Most specifically, I don’t believe there is a valid direct answer to:

I don’t believe there is one - at least not one that covers the full range of considerations that should be made when selecting an architecture for a solution.

The concept of “most effective” cannot be addressed in isolation. Your application does not exist in a vacuum - or a silo. In a true production-quality environment, there are at least as many non-technical considerations as there are technical issue to address.

For a specific example, HTMX is clearly the best solution for us in the area where I’m currently working for dynamic front-end support and websocket integration. None of the JavaScript frameworks you mention above (React, et al.) would even be considered. (My DjangoCon talk from last year shows a tiny part of this.)

Or along similar lines, you compare

You can make a technical comparison between the two, identifying the limitations of each. And perhaps you could compare the amount of code that you need to supply to make each of them do what you need them to do. But about the most you can say regarding either one is that they either satisfy the requirement or they don’t. If they both satisfy your requirements, then it’s not likely going to matter which one you pick.

If one of the two doesn’t satisfy your requirements, then you shouldn’t select it, regardless of how easy it might be to use or how well integrated it is with Django or any other technical criteria you identify. If it doesn’t work for you, nothing else matters.

This parallel holds true for all of the different areas you identify.

Interesting — would you be able to share your DjangoCon talk if there’s a video or article available? I’ve always worked with a clear separation between frontend and backend.

Yes, it’s posted here: https://www.youtube.com/watch?v=TQ_SsdXoI3Q&pp=ygUVZGphbmdvY29uIHdlYnJ0YyAyMDI0

(All the DjangoCon videos are available.)

Agree with Ken that the right answer depends on context, but for the scenario you describe (a startup, CRUD plus auth, Stripe, and AI chat), there’s a default that works well more often than not.

Start with a modular monolith, not microservices: One Django project with clear app boundaries (accounts, billing, chat, and so on) and no cross-app reaching into each other’s models. You get Django’s speed of development now, and if a piece ever needs to become its own service, those boundaries make it a much smaller job. Microservices add deployment, monitoring, and data-consistency overhead that most startups don’t have the team size to justify early on.

Mixing DRF and Ninja in one project is fine: Mount them under different URL prefixes and use each where it fits: DRF for the established CRUD, permissions, and auth parts, and Ninja’s async endpoints for the newer AI-facing APIs. If you’re starting fresh, though, picking one keeps the codebase simpler.

For AI chat streaming, SSE is usually the better fit: Token streaming is one-way, so an async view returning StreamingHttpResponse with an async generator, running under ASGI, handles it cleanly over plain HTTP. Just make sure your proxy doesn’t buffer the response (for example, X-Accel-Buffering: no with nginx). Keep Channels and WebSockets for features that are genuinely two-way, like live collaboration or presence. On AI products we’ve built at Technource, splitting it this way kept the chat path simple and left Channels for the few places that actually needed it.

Use Celery for heavy background work, like document ingestion, embeddings, or long agent tasks, not for the streaming response itself.

The signals that it’s time to split something out are fairly concrete: a component that needs to scale very differently (AI workers are the usual first candidate), a different deployment pace, or a separate team owning it. Until one of those shows up, the monolith is usually the faster path.

I agree with Ken and with the modular monolith point above. For a startup, starting with one Django project with clear app boundaries is usually the fastest way to ship, and it keeps deployment and testing simple. The SSE point is also worth keeping in mind: for one-way token streaming, an async view with StreamingHttpResponse under ASGI is a good fit, while Channels and WebSockets are better saved for features that are genuinely two-way. The practical test I use is whether a piece needs to scale or deploy on its own — if it does not, it can stay in the monolith for now.