How 0gis0/chainlit-demo works
Project Type and Purpose
• This is a container-based demo application combining a Python chat UI (Chainlit) with Azure OpenAI and external “Model Context Protocol” (MCP) servers.
• Purpose: let a developer spin up a local dev container, run a Chainlit chat app, wire in Azure OpenAI LLM calls, and dynamically attach MCP servers (e.g., a filesystem server) to enrich the model’s context.
Top-Level Components
• Dev Environment
• VSCode Dev Container (.devcontainer/devcontainer.json)
• Python runtime, Node.js runtime
• Chainlit Chat App
• app.py (entrypoint)
• .chainlit/ (CLI config & translation JSONs)
• requirements.txt
• Configuration
• .azure.env (sample in .azure.env-sample) – holds Azure OpenAI creds and endpoint
• External Services
• Azure OpenAI endpoint (cloud API)
• MCP Servers (Node.js microservices, e.g. @modelcontextprotocol/server-filesystem)
• File System Context
• Local workspace (/workspaces/chainlit-demo)
• poema.txt (example artifact)
Interactions & Data Flow
• Developer opens the repo in VSCode → launches Dev Container
• Inside container, runs chainlit run app.py -w → Chainlit server and web UI spin up
• User submits prompt in browser UI → Chainlit backend processes message
→ Chainlit calls Azure OpenAI REST API using credentials from .azure.env
• Responses from Azure and MCP servers merge back in Chainlit → rendered in UI
• E.g., writing a poem: Chainlit instructs filesystem MCP server to save output to poema.txt
Architectural Patterns & Principles
• Microservices for each MCP server (isolated Node.js processes)
• Containerized development environment (reproducible builds, no local installs)
• Plugin/extension model: Chainlit can dynamically load multiple MCP servers via simple CLI commands
• Clear separation of concerns: UI layer (Chainlit front), orchestrator layer (Chainlit backend), LLM service, context providers
Essentials to Capture
• Configuration files and environment variables