# anurag0224q/coding_buddy architecture

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

- Interactive diagram: https://gitdiagram.com/anurag0224q/coding_buddy
- Repository: https://github.com/anurag0224q/coding_buddy

## Overview

Coding Buddy is a browser-based AI coding assistant. Users manage chats, choose a chat mode, attach text or code files, and stream AI responses; settings allow default or user-supplied provider credentials and connection testing. The main path runs from the chat UI through the streaming client and Node API to shared request shaping and provider adapters. Local chat and settings persistence is a separate state branch. A Cloudflare Worker is also present, but its runtime wiring is not shown in the excerpts; its links are therefore marked unverified.

Main entry points: [`src/pages/ChatPage.jsx`](https://github.com/anurag0224q/coding_buddy/blob/main/src/pages/ChatPage.jsx) (Chat workspace), [`server/app.js`](https://github.com/anurag0224q/coding_buddy/blob/main/server/app.js) (HTTP API), [`server/providers.js`](https://github.com/anurag0224q/coding_buddy/blob/main/server/providers.js) (Provider adapters), [`src/components/SettingsModal.jsx`](https://github.com/anurag0224q/coding_buddy/blob/main/src/components/SettingsModal.jsx) (Provider settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat interface"]
  node_chat["Chat workspace<br/>[ChatPage.jsx]"]
  node_app["App routing<br/>[App.tsx]"]
  node_settings["Provider settings<br/>[SettingsModal.jsx]"]
  node_sidebar["Chat sidebar<br/>[Sidebar.jsx]"]
  node_markdown["Markdown renderer<br/>[Markdown.jsx]"]
  node_codeblock["Code formatting<br/>[CodeBlock.jsx]"]
  node_streamclient["Streaming client<br/>[aiClient.js]"]
  node_apiclient["JSON API client<br/>[api.ts]"]
end

subgraph group_state["Browser state"]
  node_storage[("Chat and settings storage<br/>[storage.js]")]
end

subgraph group_service["AI service"]
  node_requestcore["Prompt and message shaping<br/>[core.js]"]
  node_providers["Provider adapters<br/>[providers.js]"]
end

subgraph group_runtime["Server runtimes"]
  node_nodeapi["HTTP API<br/>[app.js]"]
  node_worker["Worker runtime<br/>[index.js]"]
end

node_user(("User"))
node_ai{{"AI providers"}}

node_user -->|"opens app"| node_app
node_app -->|"routes to"| node_chat
node_chat -->|"opens"| node_settings
node_chat -->|"renders"| node_sidebar
node_chat -->|"renders"| node_markdown
node_markdown -->|"uses"| node_codeblock
node_chat -->|"loads and saves"| node_storage
node_settings -.->|"saves settings"| node_storage
node_chat -->|"streams chat"| node_streamclient
node_settings -->|"tests connection"| node_apiclient
node_chat -->|"loads config"| node_apiclient
node_streamclient -.->|"posts chat"| node_nodeapi
node_apiclient -.->|"calls API"| node_nodeapi
node_nodeapi -->|"shapes request"| node_requestcore
node_nodeapi -->|"streams completion"| node_providers
node_nodeapi -->|"tests connection"| node_providers
node_providers -->|"calls provider"| node_ai
node_worker -.->|"uses shaping"| node_requestcore
node_worker -.->|"uses adapters"| node_providers

click node_chat "https://github.com/anurag0224q/coding_buddy/blob/main/src/pages/ChatPage.jsx"
click node_app "https://github.com/anurag0224q/coding_buddy/blob/main/src/App.tsx"
click node_settings "https://github.com/anurag0224q/coding_buddy/blob/main/src/components/SettingsModal.jsx"
click node_sidebar "https://github.com/anurag0224q/coding_buddy/blob/main/src/components/Sidebar.jsx"
click node_markdown "https://github.com/anurag0224q/coding_buddy/blob/main/src/components/Markdown.jsx"
click node_codeblock "https://github.com/anurag0224q/coding_buddy/blob/main/src/components/CodeBlock.jsx"
click node_streamclient "https://github.com/anurag0224q/coding_buddy/blob/main/src/lib/aiClient.js"
click node_apiclient "https://github.com/anurag0224q/coding_buddy/blob/main/src/lib/api.ts"
click node_storage "https://github.com/anurag0224q/coding_buddy/blob/main/src/lib/storage.js"
click node_nodeapi "https://github.com/anurag0224q/coding_buddy/blob/main/server/app.js"
click node_worker "https://github.com/anurag0224q/coding_buddy/blob/main/worker/index.js"
click node_requestcore "https://github.com/anurag0224q/coding_buddy/blob/main/server/core.js"
click node_providers "https://github.com/anurag0224q/coding_buddy/blob/main/server/providers.js"

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_app,node_settings,node_sidebar,node_markdown,node_codeblock,node_streamclient,node_apiclient,node_user toneBlue
class node_storage toneAmber
class node_requestcore,node_providers toneMint
class node_nodeapi,node_worker toneRose
class node_ai toneIndigo
```

## Components

### Chat interface

- [Chat workspace](https://github.com/anurag0224q/coding_buddy/blob/main/src/pages/ChatPage.jsx): `src/pages/ChatPage.jsx`
- [App routing](https://github.com/anurag0224q/coding_buddy/blob/main/src/App.tsx): `src/App.tsx`
- [Provider settings](https://github.com/anurag0224q/coding_buddy/blob/main/src/components/SettingsModal.jsx): `src/components/SettingsModal.jsx`
- [Chat sidebar](https://github.com/anurag0224q/coding_buddy/blob/main/src/components/Sidebar.jsx): `src/components/Sidebar.jsx`
- [Markdown renderer](https://github.com/anurag0224q/coding_buddy/blob/main/src/components/Markdown.jsx): `src/components/Markdown.jsx`
- [Code formatting](https://github.com/anurag0224q/coding_buddy/blob/main/src/components/CodeBlock.jsx): `src/components/CodeBlock.jsx`
- [Streaming client](https://github.com/anurag0224q/coding_buddy/blob/main/src/lib/aiClient.js): `src/lib/aiClient.js`
- [JSON API client](https://github.com/anurag0224q/coding_buddy/blob/main/src/lib/api.ts): `src/lib/api.ts`

### Browser state

- [Chat and settings storage](https://github.com/anurag0224q/coding_buddy/blob/main/src/lib/storage.js): `src/lib/storage.js`

### AI service

- [Prompt and message shaping](https://github.com/anurag0224q/coding_buddy/blob/main/server/core.js): `server/core.js`
- [Provider adapters](https://github.com/anurag0224q/coding_buddy/blob/main/server/providers.js): `server/providers.js`

### Server runtimes

- [HTTP API](https://github.com/anurag0224q/coding_buddy/blob/main/server/app.js): `server/app.js`
- [Worker runtime](https://github.com/anurag0224q/coding_buddy/blob/main/worker/index.js): `worker/index.js`

### Other components

- **User**
- **AI providers**

## Connections

- User → App routing: opens app (evidence: `src/App.tsx`)
- App routing → Chat workspace: routes to (evidence: `src/App.tsx`)
- Chat workspace → Provider settings: opens (evidence: `src/pages/ChatPage.jsx`)
- Chat workspace → Chat sidebar: renders (evidence: `src/pages/ChatPage.jsx`)
- Chat workspace → Markdown renderer: renders (evidence: `src/pages/ChatPage.jsx`)
- Markdown renderer → Code formatting: uses (evidence: `src/components/Markdown.jsx`)
- Chat workspace → Chat and settings storage: loads and saves (evidence: `src/pages/ChatPage.jsx`)
- Provider settings → Chat and settings storage: saves settings
- Chat workspace → Streaming client: streams chat (evidence: `src/pages/ChatPage.jsx`)
- Provider settings → JSON API client: tests connection (evidence: `src/components/SettingsModal.jsx`)
- Chat workspace → JSON API client: loads config (evidence: `src/pages/ChatPage.jsx`)
- Streaming client → HTTP API: posts chat
- JSON API client → HTTP API: calls API
- HTTP API → Prompt and message shaping: shapes request (evidence: `server/app.js`)
- HTTP API → Provider adapters: streams completion (evidence: `server/app.js`)
- HTTP API → Provider adapters: tests connection (evidence: `server/app.js`)
- Provider adapters → AI providers: calls provider (evidence: `server/providers.js`)
- Worker runtime → Prompt and message shaping: uses shaping (evidence: `worker/index.js`)
- Worker runtime → Provider adapters: uses adapters (evidence: `worker/index.js`)
