# convex/chef architecture

> Architecture diagram of the GitHub repository convex/chef, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/convex/chef
- Repository: https://github.com/convex/chef

## Overview

Chef is an AI app builder: a user starts or resumes a project, chats with the code-generation agent, and works with generated files in an in-browser editor, terminal, and preview. The agent parses streamed artifact actions and offers project tools; Convex supplies chat, session, and project persistence, while the README describes the resulting apps as full-stack Convex apps. The graph preserves those major product areas, but unsampled links between chat submission, agent execution, and backend persistence are left unasserted.

Main entry points: [`app/components/chat/BaseChat.client.tsx`](https://github.com/convex/chef/blob/main/app/components/chat/BaseChat.client.tsx) (Chat interface), [`chef-agent`](https://github.com/convex/chef/tree/main/chef-agent) (Agent loop), [`app/components/workbench/Workbench.client.tsx`](https://github.com/convex/chef/blob/main/app/components/workbench/Workbench.client.tsx) (Workbench shell), [`app/components/chat/MessageInput.tsx`](https://github.com/convex/chef/blob/main/app/components/chat/MessageInput.tsx) (Prompt input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Chat experience"]
  node_chat["Chat interface"]
  node_input["Prompt input<br/>[MessageInput.tsx]"]
  node_messages["Message renderer"]
  node_assistant["Assistant message"]
  node_model["Model selection<br/>[ModelSelector.tsx]"]
  node_history["Chat history<br/>[Menu.client.tsx]"]
end

subgraph group_agent["Generation agent"]
  node_context["Prompt context"]
  node_parser["Artifact parser<br/>[message-parser.ts]"]
  node_tools["Agent tools"]
  node_agentloop["Agent loop"]
end

subgraph group_workspace["Project workbench"]
  node_workbench["Workbench shell"]
  node_editor["Code editor<br/>[EditorPanel.tsx]"]
  node_files["Project files<br/>[FileTree.tsx]"]
  node_preview["Live preview<br/>[Preview.tsx]"]
  node_terminal["Terminal tabs<br/>[TerminalTabs.tsx]"]
  node_webcontainer["WebContainer runtime<br/>[index.ts]"]
end

subgraph group_backend["Convex services"]
  node_convex[("Convex backend")]
  node_messagesdb[("Chat persistence<br/>[messages.ts]")]
  node_sessions[("Sessions<br/>[sessions.ts]")]
  node_project["Generated app template"]
end

node_user(("Builder"))
node_modelprovider{{"Model provider"}}

node_user -->|"starts project"| node_chat
node_chat -->|"renders"| node_input
node_chat -->|"shows workspace"| node_workbench
node_input -->|"selects model"| node_model
node_chat -->|"shows messages"| node_messages
node_messages -->|"renders"| node_assistant
node_input -.->|"submits prompt"| node_agentloop
node_agentloop -.->|"requests generation"| node_modelprovider
node_context -->|"parses stream"| node_parser
node_agentloop -.->|"builds context"| node_context
node_agentloop -.->|"dispatches tools"| node_tools
node_parser -.->|"emits file actions"| node_workbench
node_workbench -->|"shows editor"| node_editor
node_workbench -->|"shows preview"| node_preview
node_editor -->|"renders tree"| node_files
node_editor -->|"renders tabs"| node_terminal
node_preview -.->|"loads preview"| node_webcontainer
node_user -->|"browses chats"| node_history
node_history -->|"queries history"| node_messagesdb
node_messagesdb -->|"checks access"| node_sessions
node_convex -->|"stores chats"| node_messagesdb
node_convex -->|"stores metadata"| node_sessions
node_user -->|"builds app"| node_project

click node_chat "https://github.com/convex/chef/blob/main/app/components/chat/BaseChat.client.tsx"
click node_input "https://github.com/convex/chef/blob/main/app/components/chat/MessageInput.tsx"
click node_messages "https://github.com/convex/chef/blob/main/app/components/chat/Messages.client.tsx"
click node_assistant "https://github.com/convex/chef/blob/main/app/components/chat/AssistantMessage.tsx"
click node_model "https://github.com/convex/chef/blob/main/app/components/chat/ModelSelector.tsx"
click node_history "https://github.com/convex/chef/blob/main/app/components/sidebar/Menu.client.tsx"
click node_context "https://github.com/convex/chef/blob/main/chef-agent/ChatContextManager.ts"
click node_parser "https://github.com/convex/chef/blob/main/chef-agent/message-parser.ts"
click node_tools "https://github.com/convex/chef/tree/main/chef-agent/tools"
click node_agentloop "https://github.com/convex/chef/tree/main/chef-agent"
click node_workbench "https://github.com/convex/chef/blob/main/app/components/workbench/Workbench.client.tsx"
click node_editor "https://github.com/convex/chef/blob/main/app/components/workbench/EditorPanel.tsx"
click node_files "https://github.com/convex/chef/blob/main/app/components/workbench/FileTree.tsx"
click node_preview "https://github.com/convex/chef/blob/main/app/components/workbench/Preview.tsx"
click node_terminal "https://github.com/convex/chef/blob/main/app/components/workbench/terminal/TerminalTabs.tsx"
click node_webcontainer "https://github.com/convex/chef/blob/main/app/lib/webcontainer/index.ts"
click node_convex "https://github.com/convex/chef/tree/main/convex"
click node_messagesdb "https://github.com/convex/chef/blob/main/convex/messages.ts"
click node_sessions "https://github.com/convex/chef/blob/main/convex/sessions.ts"
click node_project "https://github.com/convex/chef/tree/main/template"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_chat,node_input,node_messages,node_assistant,node_model,node_history toneBlue
class node_context,node_parser,node_tools,node_agentloop toneAmber
class node_workbench,node_editor,node_files,node_preview,node_terminal,node_webcontainer toneMint
class node_convex,node_messagesdb,node_sessions,node_project toneRose
class node_user,node_modelprovider toneIndigo
```

## Components

### Chat experience

- [Chat interface](https://github.com/convex/chef/blob/main/app/components/chat/BaseChat.client.tsx): `app/components/chat/BaseChat.client.tsx`
- [Prompt input](https://github.com/convex/chef/blob/main/app/components/chat/MessageInput.tsx): `app/components/chat/MessageInput.tsx`
- [Message renderer](https://github.com/convex/chef/blob/main/app/components/chat/Messages.client.tsx): `app/components/chat/Messages.client.tsx`
- [Assistant message](https://github.com/convex/chef/blob/main/app/components/chat/AssistantMessage.tsx): `app/components/chat/AssistantMessage.tsx`
- [Model selection](https://github.com/convex/chef/blob/main/app/components/chat/ModelSelector.tsx): `app/components/chat/ModelSelector.tsx`
- [Chat history](https://github.com/convex/chef/blob/main/app/components/sidebar/Menu.client.tsx): `app/components/sidebar/Menu.client.tsx`

### Generation agent

- [Prompt context](https://github.com/convex/chef/blob/main/chef-agent/ChatContextManager.ts): `chef-agent/ChatContextManager.ts`
- [Artifact parser](https://github.com/convex/chef/blob/main/chef-agent/message-parser.ts): `chef-agent/message-parser.ts`
- [Agent tools](https://github.com/convex/chef/tree/main/chef-agent/tools): `chef-agent/tools`
- [Agent loop](https://github.com/convex/chef/tree/main/chef-agent): `chef-agent`

### Project workbench

- [Workbench shell](https://github.com/convex/chef/blob/main/app/components/workbench/Workbench.client.tsx): `app/components/workbench/Workbench.client.tsx`
- [Code editor](https://github.com/convex/chef/blob/main/app/components/workbench/EditorPanel.tsx): `app/components/workbench/EditorPanel.tsx`
- [Project files](https://github.com/convex/chef/blob/main/app/components/workbench/FileTree.tsx): `app/components/workbench/FileTree.tsx`
- [Live preview](https://github.com/convex/chef/blob/main/app/components/workbench/Preview.tsx): `app/components/workbench/Preview.tsx`
- [Terminal tabs](https://github.com/convex/chef/blob/main/app/components/workbench/terminal/TerminalTabs.tsx): `app/components/workbench/terminal/TerminalTabs.tsx`
- [WebContainer runtime](https://github.com/convex/chef/blob/main/app/lib/webcontainer/index.ts): `app/lib/webcontainer/index.ts`

### Convex services

- [Convex backend](https://github.com/convex/chef/tree/main/convex): `convex`
- [Chat persistence](https://github.com/convex/chef/blob/main/convex/messages.ts): `convex/messages.ts`
- [Sessions](https://github.com/convex/chef/blob/main/convex/sessions.ts): `convex/sessions.ts`
- [Generated app template](https://github.com/convex/chef/tree/main/template): `template`

### Other components

- **Builder**
- **Model provider**

## Connections

- Builder → Chat interface: starts project
- Chat interface → Prompt input: renders (evidence: `app/components/chat/BaseChat.client.tsx`)
- Chat interface → Workbench shell: shows workspace (evidence: `app/components/chat/BaseChat.client.tsx`)
- Prompt input → Model selection: selects model (evidence: `app/components/chat/MessageInput.tsx`)
- Chat interface → Message renderer: shows messages (evidence: `app/components/chat/BaseChat.client.tsx`)
- Message renderer → Assistant message: renders (evidence: `app/components/chat/Messages.client.tsx`)
- Prompt input → Agent loop: submits prompt
- Agent loop → Model provider: requests generation
- Prompt context → Artifact parser: parses stream (evidence: `chef-agent/ChatContextManager.ts`)
- Agent loop → Prompt context: builds context (evidence: `chef-agent/ChatContextManager.ts`)
- Agent loop → Agent tools: dispatches tools (evidence: `chef-agent/ChatContextManager.ts`)
- Artifact parser → Workbench shell: emits file actions
- Workbench shell → Code editor: shows editor (evidence: `app/components/workbench/Workbench.client.tsx`)
- Workbench shell → Live preview: shows preview (evidence: `app/components/workbench/Workbench.client.tsx`)
- Code editor → Project files: renders tree (evidence: `app/components/workbench/EditorPanel.tsx`)
- Code editor → Terminal tabs: renders tabs (evidence: `app/components/workbench/EditorPanel.tsx`)
- Live preview → WebContainer runtime: loads preview
- Builder → Chat history: browses chats (evidence: `app/components/sidebar/Menu.client.tsx`)
- Chat history → Chat persistence: queries history (evidence: `app/components/sidebar/Menu.client.tsx`)
- Chat persistence → Sessions: checks access (evidence: `convex/sessions.ts`)
- Convex backend → Chat persistence: stores chats (evidence: `convex/sessions.ts`)
- Convex backend → Sessions: stores metadata (evidence: `convex/sessions.ts`)
- Builder → Generated app template: builds app
