# abhishekwarkade2007-bit/ai-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/abhishekwarkade2007-bit/ai-assistant
- Repository: https://github.com/abhishekwarkade2007-bit/ai-assistant

## Overview

This is a browser-based assistant for chat, web search, and opening pages as context. Users submit a chat prompt, search query, or URL; the browser sends requests to local Express routes or Netlify Functions, then displays results and makes search/page context available to chat. Chat can use OpenAI or Gemini, while search fetches DuckDuckGo HTML and page browsing fetches the supplied URL. The local server and Netlify functions are parallel backends. Source excerpts show their request handling; deployment routing is documented in the README.

Main entry points: [`public/app.js`](https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/public/app.js) (Chat and tools), [`netlify/functions/_shared.js`](https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/netlify/functions/_shared.js) (Function helpers), [`server.js`](https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/server.js) (Local chat route), [`netlify/functions/search.js`](https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/netlify/functions/search.js) (Function search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser interface"]
  node_webui["Assistant UI<br/>[index.html]"]
  node_browser_logic["Chat and tools<br/>[app.js]"]
end

subgraph group_local["Local backend"]
  node_local_host["Express host<br/>[server.js]"]
  node_local_chat["Local chat route<br/>[server.js]"]
  node_local_search["Local search route<br/>[server.js]"]
  node_local_browse["Local browse route<br/>[server.js]"]
end

subgraph group_netlify["Netlify backend"]
  node_netlify_chat["Function chat<br/>[chat.js]"]
  node_netlify_search["Function search<br/>[search.js]"]
  node_netlify_browse["Function browse<br/>[browse.js]"]
  node_shared["Function helpers<br/>[_shared.js]"]
end

subgraph group_integrations["External services"]
  node_openai["OpenAI API"]
  node_gemini["Gemini API"]
  node_duckduckgo["DuckDuckGo"]
  node_web_pages["Web pages"]
end

node_user(("Assistant user"))

node_user -->|"uses"| node_webui
node_webui -->|"loads"| node_browser_logic
node_browser_logic -->|"posts chat"| node_local_chat
node_browser_logic -->|"posts query"| node_local_search
node_browser_logic -->|"posts URL"| node_local_browse
node_browser_logic -->|"posts chat"| node_netlify_chat
node_browser_logic -->|"posts query"| node_netlify_search
node_browser_logic -->|"posts URL"| node_netlify_browse
node_local_host -->|"serves"| node_webui
node_local_chat -->|"requests completion"| node_openai
node_local_chat -->|"requests completion"| node_gemini
node_local_search -->|"fetches results"| node_duckduckgo
node_local_browse -->|"fetches page"| node_web_pages
node_netlify_chat -->|"calls helpers"| node_shared
node_netlify_search -->|"calls helpers"| node_shared
node_netlify_browse -->|"calls helpers"| node_shared
node_shared -->|"requests completion"| node_openai
node_shared -->|"requests completion"| node_gemini
node_netlify_search -->|"fetches results"| node_duckduckgo
node_netlify_browse -->|"fetches page"| node_web_pages

click node_webui "https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/public/index.html"
click node_browser_logic "https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/public/app.js"
click node_local_host "https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/server.js"
click node_local_chat "https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/server.js"
click node_local_search "https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/server.js"
click node_local_browse "https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/server.js"
click node_netlify_chat "https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/netlify/functions/chat.js"
click node_netlify_search "https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/netlify/functions/search.js"
click node_netlify_browse "https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/netlify/functions/browse.js"
click node_shared "https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/netlify/functions/_shared.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_webui,node_browser_logic,node_user toneBlue
class node_local_host,node_local_chat,node_local_search,node_local_browse toneAmber
class node_netlify_chat,node_netlify_search,node_netlify_browse,node_shared toneMint
class node_openai,node_gemini,node_duckduckgo,node_web_pages toneRose
```

## Components

### Browser interface

- [Assistant UI](https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/public/index.html): `public/index.html`
- [Chat and tools](https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/public/app.js): `public/app.js`

### Local backend

- [Express host](https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/server.js): `server.js`
- [Local chat route](https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/server.js): `server.js`
- [Local search route](https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/server.js): `server.js`
- [Local browse route](https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/server.js): `server.js`

### Netlify backend

- [Function chat](https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/netlify/functions/chat.js): `netlify/functions/chat.js`
- [Function search](https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/netlify/functions/search.js): `netlify/functions/search.js`
- [Function browse](https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/netlify/functions/browse.js): `netlify/functions/browse.js`
- [Function helpers](https://github.com/abhishekwarkade2007-bit/ai-assistant/blob/main/netlify/functions/_shared.js): `netlify/functions/_shared.js`

### External services

- **OpenAI API**
- **Gemini API**
- **DuckDuckGo**
- **Web pages**

### Other components

- **Assistant user**

## Connections

- Assistant user → Assistant UI: uses (evidence: `README.md`)
- Assistant UI → Chat and tools: loads (evidence: `public/app.js`)
- Chat and tools → Local chat route: posts chat (evidence: `public/app.js`)
- Chat and tools → Local search route: posts query (evidence: `public/app.js`)
- Chat and tools → Local browse route: posts URL (evidence: `public/app.js`)
- Chat and tools → Function chat: posts chat (evidence: `public/app.js`)
- Chat and tools → Function search: posts query (evidence: `public/app.js`)
- Chat and tools → Function browse: posts URL (evidence: `public/app.js`)
- Express host → Assistant UI: serves (evidence: `server.js`)
- Local chat route → OpenAI API: requests completion (evidence: `server.js`)
- Local chat route → Gemini API: requests completion (evidence: `server.js`)
- Local search route → DuckDuckGo: fetches results (evidence: `server.js`)
- Local browse route → Web pages: fetches page (evidence: `server.js`)
- Function chat → Function helpers: calls helpers (evidence: `netlify/functions/chat.js`)
- Function search → Function helpers: calls helpers (evidence: `netlify/functions/search.js`)
- Function browse → Function helpers: calls helpers (evidence: `netlify/functions/browse.js`)
- Function helpers → OpenAI API: requests completion (evidence: `netlify/functions/_shared.js`)
- Function helpers → Gemini API: requests completion (evidence: `netlify/functions/_shared.js`)
- Function search → DuckDuckGo: fetches results (evidence: `netlify/functions/search.js`)
- Function browse → Web pages: fetches page (evidence: `netlify/functions/browse.js`)
