Architecture for a chatbot

Architecture for a chatbot

Comparative analysis of monolithic and modular approaches

Artificial intelligence and large language models (LLMs) are profoundly transforming digital interactions. This article offers an analysis of the advantages and disadvantages of two popular approaches to defining the architecture of a chatbot.

Date: 8 April 2025

Expertises:

Data Science 

Domaine: Software industry 

Innovation theme: Artificial Intelligences 

About project: ARIAC 

Author : Hugo Walem

1. Presentation of approaches

1.1. Monolithic approach
The monolithic approach involves building the chatbot application from a single technological tool. All code, from the user interface to business logic and data management, is grouped into a single block.

Example: Streamlit is an open-source Python framework for quickly creating interactive web applications from Python scripts. It is ideal for prototyping and internal applications.

1.2. Modular approach (Integration of Web Framework, API Server, and REST API)

The modular approach involves dividing the chatbot application into several independent components, each with a specific function. These components communicate with each other via APIs.
Examples:

  • Django: This is a high-level Python web framework, designed for rapid and clean development of complex websites. It offers many built-in features, such as database management, authentication, and security.
  • Angular: This is an open-source JavaScript framework for creating dynamic and interactive web user interfaces. It uses the TypeScript language and is particularly suitable for complex web applications.

Note: There are many other technologies that can be used to build modular chatbots. For the frontend, examples include React or Vue.js, and for the backend, Flask or FastAPI. The choice of Django and Angular in this comparative study is motivated by their popularity and their characteristics well-suited to the needs of many projects.

2. Comparison of approaches

2.1. Flexibility and customization

  • Modular approach:
    The modular approach combining a web framework such as Angular with a Django backend offers a highly customizable architecture adaptable to various sectors. Whether for a chatbot designed for customer support, data analysis, or task automation, this solution ensures a tailored design of the user interface while ensuring seamless interconnection with third-party services via well-defined APIs.
  • Monolithic approach:
    Streamlit is particularly suitable for rapid developments and functional prototypes, especially for internal use cases such as data analysis or interactive visualization. However, its model based on pre-built components restricts possibilities in terms of design and user experience, limiting its adoption for projects requiring high flexibility.

2.2. Scalability and performance

  • Modular approach:
    The architecture based on Django and Angular allows for efficient management of large user loads, an essential asset for companies needing a scalable solution. A well-optimized Django backend, when coupled with a high-performance server and caching tools like Redis, can support several thousand simultaneous users without performance degradation, making it a relevant choice for companies looking to deploy large-scale chatbots.
  • Monolithic approach:
    While practical for lightweight applications, Streamlit quickly shows its limits in terms of scalability. Each user consumes distinct resources, which reduces the system’s ability to respond to increasing demand. A standard server (2 vCPU, 4 GB RAM) can only handle a limited number of users before significant slowdowns occur.

2.3. Integration with other services

  • Modular approach:
    Thanks to Django REST Framework, integration with other services, whether internal or external, is facilitated. In sectors such as fintech, logistics, or healthcare, this interconnection capability is essential to ensure seamless data exchange between various platforms and tools.
  • Monolithic approach:
    Streamlit is not designed for complex interactions between the client and the server. Its simplified architecture limits API management and restricts the ability to integrate with other professional tools requiring advanced interactions.

2.4. Security and user management

  • Modular approach:
    In an environment where data protection is a central issue, such as in the banking or medical sectors, security is paramount. Django natively integrates advanced protections against common attacks such as SQL injections, CSRF, and XSS attacks. It also allows fine-grained management of users and permissions thanks to a robust authentication system.
  • Monolithic approach:
    Streamlit has basic mechanisms for application protection, but is not designed to handle secure infrastructures with multiple levels of authentication and permissions. This makes it less suitable for contexts where cybersecurity is a top priority.

2.5. Maintenance and scalability

  • Modular approach:
    The modular approach with frontend/backend separation ensures great flexibility for project evolution. Adding new features or replacing components becomes easier, which ensures efficient long-term maintenance. This model is particularly relevant in fast-growing companies seeking to evolve their applications according to market needs.
  • Monolithic approach:
    Streamlit is more suitable for demonstrations and prototypes. Its monolithic structure complicates scalability and maintenance, and incompatibilities between versions may appear over time, which can hinder updates and the addition of new features.

Summary

Modular Approach
(Web Framework + API Server + REST API)
Monolithic Approach
(Streamlit)
Flexibility Highly customizable, adaptable to various sectors Rapid development, limited in design and UX
Scalability Effectively manages large user loads Limited in scalability, slowdowns with increased users
Integration Facilitated with Django REST Framework, seamless interconnection Limited client-server interactions, restricted integration
Security Advanced protections, fine-grained user management Basic security, less suitable for secure infrastructures
Maintenance Simple scalability, efficient maintenance Monolithic structure, complex scalability and maintenance

Conclusion

In a professional setting, where robustness, scalability, and security are paramount criteria, the approach combining Django and Angular with a REST API appears to be the most suitable solution. It ensures not only great flexibility for evolution but also better interoperability with external tools and services. On the other hand, if the goal is to develop a prototype quickly, without worrying about the constraints related to load balancing or security, Streamlit can be an interesting alternative, especially for teams seeking to experiment and test concepts before a larger-scale deployment.

It is important to note that these two approaches are not mutually exclusive. A judicious strategy could consist of using Streamlit to perform a quick and inexpensive Proof of Concept (POC), thereby validating the feasibility of the project and its market interest. If the tests prove conclusive, a more sustainable and robust solution based on Django coupled with Angular could then be developed to ensure long-term operation.

Ultimately, the choice of architecture largely depends on the project’s requirements, its context of use, and the needs in terms of scalability and integration with existing infrastructures. As AI and LLMs continue to establish themselves as essential technologies, having an adaptable and scalable solution is more than ever a strategic issue for businesses.