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.)