How dimagi/open-chat-studio works
Main components
• Frontend/UI Layer:
• Web templates (using Django’s templating engine).
• Client-side JavaScript components and assets (including the chat widget and pipeline components).
• Static assets such as CSS, images, and JS that enable dynamic features.
• Backend (Django Monolith):
• Multiple Django “apps” organized under the apps/ folder. Each app focuses on a distinct domain (e.g., chat, experiments, pipelines, service_providers, admin, etc.).
• A core “gpt_playground” module that appears to house the global settings (settings.py, wsgi.py) and Celery configuration (celery.py) for background task processing.
• Background/Asynchronous Processing:
• Celery workers (with commands demonstrated in the README and settings in the gpt_playground package) that handle asynchronous jobs (like querying LLM services).
• Redis or another broker (as implied by the docker-compose setup) to support Celery.
• Database:
• A relational database (given Django’s ORM and numerous migrations in every app).
• Migrations indicate that schema evolution is handled for every module.
• External Services/Integrations:
• Integrations via service_providers (authentication services, LLM service integration, messaging service, etc.).
• API endpoints under apps/api as well as external API wrappers (e.g., apps/api/openai.py).
• Possibly Slack, SSO, and channels integrations that appear in designated apps.
• Developer Tools/DevOps:
• Docker and docker-compose (for local dev environment).
• CI/CD workflows in the .github/workflows directory.
• Tools for code quality, automated tests (pytest), linting (ruff), and pre-commit hooks.
Relationships and Interactions
• Database interactions are central – show that various Django apps persist and retrieve data from a central “Database” component.
Architectural Patterns/Design Principles
• Modular/Separation of Concerns: Emphasize that each domain (chat, experiments, pipelines, etc.) is encapsulated as a separate Django app.
• MVC/MVT: Although Django follows the Model-View-Template paradigm, show that models (with migrations), views, and templates are clearly separated.
• Asynchronous Processing: Illustrate the asynchronous processing of long-running tasks (such as LLM responses) via Celery.
• External Abstraction: Indicate that there is a layer abstracting communication with external APIs (service_providers and channels).
Relevant Technologies and Frameworks
• Core: Python 3.11 and Django.
• Background tasks: Celery with Redis (or a similar messaging broker).
• Frontend: JavaScript/TypeScript, Tailwind CSS, Alpine.js, and components built with Stencil and/or React (as seen in assets/javascript and components folders).
• Containerization: Docker (with Dockerfile and docker-compose-dev.yml) and Heroku deployment support.
• Code Quality: Tools like pre-commit, ruff, and pytest.