# ingu627/ai-agent-service architecture

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

- Interactive diagram: https://gitdiagram.com/ingu627/ai-agent-service
- Repository: https://github.com/ingu627/ai-agent-service

## Overview

AI Agent Service is a conversational assistant with a React client and an optional FastAPI proxy. The user submits a message or quick prompt; the chat UI delegates generation, displays the reply, and persists conversation history locally. Generation can use OpenAI or Perplexity, with optional Tavily search grounding; the proxy handles search and model completion server-side when configured. The UI also supports streaming, export, and keyboard shortcuts. Backend and frontend source excerpts show the primary calls; some UI capabilities are documented but their detailed implementation was not sampled.

Main entry points: [`frontend/src/components/ChatBot.tsx`](https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/components/ChatBot.tsx) (Chat interface), [`backend/api.py`](https://github.com/ingu627/ai-agent-service/blob/main/backend/api.py) (Chat API), [`frontend/src/services/apiService.ts`](https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/services/apiService.ts) (AI API client), [`backend/services.py`](https://github.com/ingu627/ai-agent-service/blob/main/backend/services.py) (Completion service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Chat experience"]
  node_app["App shell<br/>[App.tsx]"]
  node_chat["Chat interface<br/>[ChatBot.tsx]"]
  node_messages["Message bubbles<br/>[MessageBubble.tsx]"]
  node_typing["Typing indicator"]
  node_shortcuts["Keyboard shortcuts"]
end

subgraph group_client["Client services"]
  node_clientapi["AI API client<br/>[apiService.ts]"]
  node_history[("Chat history<br/>[storageService.ts]")]
end

subgraph group_backend["Backend service"]
  node_backendapi["Chat API<br/>[api.py]"]
  node_contracts["Request contracts<br/>[schemas.py]"]
  node_settings["Runtime settings<br/>[config.py]"]
  node_search["Search grounding<br/>[search.py]"]
  node_completion["Completion service<br/>[services.py]"]
  node_logging["Logging<br/>[app_logging.py]"]
end

subgraph group_external["AI integrations"]
  node_openai{{"OpenAI"}}
  node_perplexity{{"Perplexity"}}
  node_tavily{{"Tavily Search"}}
end

node_user(("User"))
node_browserstore[("Browser local storage")]

node_user -->|"opens"| node_app
node_app -->|"renders"| node_chat
node_chat -->|"requests generation"| node_clientapi
node_chat -->|"loads and saves"| node_history
node_history -->|"reads and writes"| node_browserstore
node_chat -->|"registers actions"| node_shortcuts
node_chat -->|"renders"| node_messages
node_chat -->|"renders"| node_typing
node_clientapi -->|"calls completion"| node_openai
node_clientapi -->|"calls completion"| node_perplexity
node_clientapi -->|"searches web"| node_tavily
node_clientapi -->|"posts chat"| node_backendapi
node_backendapi -->|"validates payload"| node_contracts
node_backendapi -->|"requests search"| node_search
node_search -->|"searches web"| node_tavily
node_backendapi -->|"requests completion"| node_completion
node_completion -->|"calls completion"| node_openai
node_completion -->|"calls completion"| node_perplexity
node_backendapi -->|"loads configuration"| node_settings
node_search -->|"loads configuration"| node_settings
node_completion -->|"loads configuration"| node_settings
node_backendapi -->|"configures logging"| node_logging
node_search -->|"logs failures"| node_logging
node_completion -->|"logs provider"| node_logging

click node_app "https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/App.tsx"
click node_chat "https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/components/ChatBot.tsx"
click node_messages "https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/components/MessageBubble.tsx"
click node_typing "https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/components/TypingIndicator.tsx"
click node_shortcuts "https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/hooks/useKeyboardShortcuts.ts"
click node_clientapi "https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/services/apiService.ts"
click node_history "https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/services/storageService.ts"
click node_backendapi "https://github.com/ingu627/ai-agent-service/blob/main/backend/api.py"
click node_contracts "https://github.com/ingu627/ai-agent-service/blob/main/backend/schemas.py"
click node_settings "https://github.com/ingu627/ai-agent-service/blob/main/backend/config.py"
click node_search "https://github.com/ingu627/ai-agent-service/blob/main/backend/search.py"
click node_completion "https://github.com/ingu627/ai-agent-service/blob/main/backend/services.py"
click node_logging "https://github.com/ingu627/ai-agent-service/blob/main/backend/app_logging.py"

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_app,node_chat,node_messages,node_typing,node_shortcuts,node_user toneBlue
class node_clientapi,node_history,node_browserstore toneAmber
class node_backendapi,node_contracts,node_settings,node_search,node_completion,node_logging toneMint
class node_openai,node_perplexity,node_tavily toneRose
```

## Components

### Chat experience

- [App shell](https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Chat interface](https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/components/ChatBot.tsx): `frontend/src/components/ChatBot.tsx`
- [Message bubbles](https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/components/MessageBubble.tsx): `frontend/src/components/MessageBubble.tsx`
- [Typing indicator](https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/components/TypingIndicator.tsx): `frontend/src/components/TypingIndicator.tsx`
- [Keyboard shortcuts](https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/hooks/useKeyboardShortcuts.ts): `frontend/src/hooks/useKeyboardShortcuts.ts`

### Client services

- [AI API client](https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/services/apiService.ts): `frontend/src/services/apiService.ts`
- [Chat history](https://github.com/ingu627/ai-agent-service/blob/main/frontend/src/services/storageService.ts): `frontend/src/services/storageService.ts`

### Backend service

- [Chat API](https://github.com/ingu627/ai-agent-service/blob/main/backend/api.py): `backend/api.py`
- [Request contracts](https://github.com/ingu627/ai-agent-service/blob/main/backend/schemas.py): `backend/schemas.py`
- [Runtime settings](https://github.com/ingu627/ai-agent-service/blob/main/backend/config.py): `backend/config.py`
- [Search grounding](https://github.com/ingu627/ai-agent-service/blob/main/backend/search.py): `backend/search.py`
- [Completion service](https://github.com/ingu627/ai-agent-service/blob/main/backend/services.py): `backend/services.py`
- [Logging](https://github.com/ingu627/ai-agent-service/blob/main/backend/app_logging.py): `backend/app_logging.py`

### AI integrations

- **OpenAI**
- **Perplexity**
- **Tavily Search**

### Other components

- **User**
- **Browser local storage**

## Connections

- User → App shell: opens (evidence: `README.md`)
- App shell → Chat interface: renders (evidence: `frontend/src/App.tsx`)
- Chat interface → AI API client: requests generation (evidence: `frontend/src/components/ChatBot.tsx`)
- Chat interface → Chat history: loads and saves (evidence: `frontend/src/components/ChatBot.tsx`)
- Chat history → Browser local storage: reads and writes (evidence: `frontend/src/services/storageService.ts`)
- Chat interface → Keyboard shortcuts: registers actions (evidence: `frontend/src/components/ChatBot.tsx`)
- Chat interface → Message bubbles: renders (evidence: `frontend/src/components/ChatBot.tsx`)
- Chat interface → Typing indicator: renders (evidence: `frontend/src/components/ChatBot.tsx`)
- AI API client → OpenAI: calls completion (evidence: `frontend/src/services/apiService.ts`)
- AI API client → Perplexity: calls completion (evidence: `frontend/src/services/apiService.ts`)
- AI API client → Tavily Search: searches web (evidence: `frontend/src/services/apiService.ts`)
- AI API client → Chat API: posts chat (evidence: `frontend/src/services/apiService.ts`)
- Chat API → Request contracts: validates payload (evidence: `backend/api.py`)
- Chat API → Search grounding: requests search (evidence: `backend/api.py`)
- Search grounding → Tavily Search: searches web (evidence: `backend/search.py`)
- Chat API → Completion service: requests completion (evidence: `backend/api.py`)
- Completion service → OpenAI: calls completion (evidence: `backend/services.py`)
- Completion service → Perplexity: calls completion (evidence: `backend/services.py`)
- Chat API → Runtime settings: loads configuration (evidence: `backend/api.py`)
- Search grounding → Runtime settings: loads configuration (evidence: `backend/search.py`)
- Completion service → Runtime settings: loads configuration (evidence: `backend/services.py`)
- Chat API → Logging: configures logging (evidence: `backend/api.py`)
- Search grounding → Logging: logs failures (evidence: `backend/search.py`)
- Completion service → Logging: logs provider (evidence: `backend/services.py`)
