# chainlit/cookbook architecture

> Architecture diagram of the GitHub repository chainlit/cookbook, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chainlit/cookbook
- Repository: https://github.com/chainlit/cookbook

## Overview

##### Project type and purpose
- This is an open-source monorepo (“Chainlit Cookbook”) containing a collection of standalone demo projects. Each folder under the root is a self-contained Chainlit chatbot UI example, illustrating different features, LLM providers, or integrations.

##### File structure
- Top-level:
- .gitignore, README.md – repo-wide configuration and entrypoint documentation.
- One directory per demo (e.g., ai-web-search-linkup, anthropic-chat, custom-frontend, react-native-chat, etc.).
- Inside each demo folder:
- app.py – the Python Chainlit application entrypoint.
- chainlit.md – Chainlit configuration and UI annotations.
- requirements.txt and .env.example – dependencies and environment-variable templates.
- Optional subfolders (public, src, frontend) hold static assets, React/Vue code, or helper modules.
- “archive” contains older or experimental demos.

##### README for additional insights
- The root README explains how to clone the repo, install dependencies, select a demo folder, and launch via “chainlit run app.py -w”.
- No monolithic architecture; each demo is standalone.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-level Monorepo view
    GitHub["GitHub Repo (Chainlit Cookbook)"]:::code
    GitIgnore[".gitignore"]:::code
    Readme["README.md"]:::code
    LocalDev["Local Dev Env\n(CLI, Git, Python)"]:::runtime
    CLI["Chainlit CLI\n(chainlit run app.py -w)"]:::runtime
    Demos["Demo Folders\n...repeat for 30+ demos"]:::code

    LocalDev -->|"clones"| GitHub
    GitHub -->|contains| GitIgnore
    GitHub -->|contains| Readme
    GitHub -->|contains| Demos
    LocalDev -->|"runs"| CLI
    CLI -->|"select demo & run"| Demos

    %% Zoom into one representative demo
    subgraph "Demo: custom-frontend" 
        direction TB
        CFFrontend["Browser UI"]:::runtime
        CFServer["Chainlit Server"]:::runtime
        CFLogic["Python App Logic\n(app.py)"]:::code
        CFConfig["chainlit.md\n.env.example\nrequirements.txt"]:::code
        CFStatic["Static Assets / Frontend"]:::code
        LLM["LLM API\n(OpenAI/Anthropic)"]:::external
        VectorDB["Vector DB\n(Pinecone, Chroma)"]:::data
        Tools["Optional Tools/Plugins"]:::external

        CFFrontend -->|requests| CFServer
        CFServer -->|handles UI events| CFLogic
        CFConfig -->|configures| CFServer
        CFLogic -->|invokes| LLM
        CFLogic -->|reads/writes| VectorDB
        CFLogic -->|optional| Tools
        CFServer -->|serves| CFStatic
        CFServer <-->|WebSocket| CFFrontend
    end

    %% Click Events
    click GitIgnore "https://github.com/chainlit/cookbook/blob/main/.gitignore"
    click Readme "https://github.com/chainlit/cookbook/blob/main/README.md"
    click CFLogic "https://github.com/chainlit/cookbook/blob/main/custom-frontend/backend/app.py"
    click CFConfig "https://github.com/chainlit/cookbook/blob/main/custom-frontend/backend/chainlit.md"
    click CFStatic "https://github.com/chainlit/cookbook/blob/main/custom-frontend/frontend/src/App.tsx"

    %% Styles
    classDef code fill:#D0E1F9,stroke:#0B5FFF,color:#0B5FFF
    classDef runtime fill:#D0F9D3,stroke:#2F8F2F,color:#2F8F2F
    classDef external fill:#F9E2D0,stroke:#FF8C00,color:#FF8C00
    classDef data fill:#E5D0F9,stroke:#8000FF,color:#8000FF
```
