# nikhil-69/rag-chat architecture

> Architecture diagram of the GitHub repository nikhil-69/rag-chat, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nikhil-69/rag-chat
- Repository: https://github.com/nikhil-69/rag-chat

## Overview

RAG-CHAT is an always-on-top Electron interview assistant. The user signs in, configures interview context and assistant mode, then asks questions or captures a screenshot for AI analysis; the app also supports credit purchases and overlay controls. React coordinates the workflow, an API client connects to the separate backend, and Electron provides native window and capture capabilities. The excerpts do not show the full chat submission and screenshot handlers, so those links are grounded in README statements rather than inferred calls.

Main entry points: [`src/App.tsx`](https://github.com/nikhil-69/rag-chat/blob/main/src/App.tsx) (Assistant workflow), [`electron/main.js`](https://github.com/nikhil-69/rag-chat/blob/main/electron/main.js) (Window and IPC runtime), [`src/main.tsx`](https://github.com/nikhil-69/rag-chat/blob/main/src/main.tsx) (React entry), [`electron/preload.cjs`](https://github.com/nikhil-69/rag-chat/blob/main/electron/preload.cjs) (IPC bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_renderer["Assistant interface"]
  node_renderer_entry["React entry<br/>[main.tsx]"]
  node_assistant["Assistant workflow<br/>[App.tsx]"]
end

subgraph group_desktop["Desktop capabilities"]
  node_preload["IPC bridge<br/>[preload.cjs]"]
  node_desktop_main["Window and IPC runtime<br/>[main.js]"]
  node_screen_capture["Screenshot capture<br/>[main.js]"]
end

subgraph group_service["Backend services"]
  node_api["Backend API client<br/>[api.ts]"]
  node_backend{{"Interview Helper backend"}}
end

subgraph group_preferences["User preferences"]
  node_settings_ui["Settings panel<br/>[SettingsPanel.tsx]"]
  node_settings["Settings persistence<br/>[settings.ts]"]
end

subgraph group_updates["App updates"]
  node_github{{"GitHub releases"}}
  node_updater["Update handling<br/>[main.js]"]
end

node_user(("Interview user"))
node_os{{"Operating system"}}
node_browser{{"System browser"}}

node_user -->|"opens app"| node_renderer_entry
node_renderer_entry -->|"renders"| node_assistant
node_assistant -->|"requests services"| node_api
node_api -->|"calls API"| node_backend
node_assistant -->|"sends chat and screenshots"| node_backend
node_assistant -->|"shows settings"| node_settings_ui
node_assistant -->|"loads and saves"| node_settings
node_settings_ui -->|"uses settings"| node_settings
node_assistant -->|"invokes desktop controls"| node_preload
node_preload -->|"invokes IPC handlers"| node_desktop_main
node_desktop_main -->|"captures screen"| node_screen_capture
node_screen_capture -->|"uses capture APIs"| node_os
node_desktop_main -.->|"registers global shortcut"| node_os
node_assistant -->|"requests and displays updates"| node_updater
node_updater -->|"checks releases"| node_github
node_assistant -.->|"opens payment link"| node_browser

click node_renderer_entry "https://github.com/nikhil-69/rag-chat/blob/main/src/main.tsx"
click node_assistant "https://github.com/nikhil-69/rag-chat/blob/main/src/App.tsx"
click node_api "https://github.com/nikhil-69/rag-chat/blob/main/src/api.ts"
click node_settings_ui "https://github.com/nikhil-69/rag-chat/blob/main/src/components/SettingsPanel.tsx"
click node_settings "https://github.com/nikhil-69/rag-chat/blob/main/src/settings.ts"
click node_preload "https://github.com/nikhil-69/rag-chat/blob/main/electron/preload.cjs"
click node_desktop_main "https://github.com/nikhil-69/rag-chat/blob/main/electron/main.js"
click node_screen_capture "https://github.com/nikhil-69/rag-chat/blob/main/electron/main.js"
click node_updater "https://github.com/nikhil-69/rag-chat/blob/main/electron/main.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_renderer_entry,node_assistant,node_user,node_browser toneBlue
class node_preload,node_desktop_main,node_screen_capture toneAmber
class node_api,node_backend toneMint
class node_settings_ui,node_settings toneRose
class node_github,node_updater,node_os toneIndigo
```

## Components

### Assistant interface

- [React entry](https://github.com/nikhil-69/rag-chat/blob/main/src/main.tsx): `src/main.tsx`
- [Assistant workflow](https://github.com/nikhil-69/rag-chat/blob/main/src/App.tsx): `src/App.tsx`

### Desktop capabilities

- [IPC bridge](https://github.com/nikhil-69/rag-chat/blob/main/electron/preload.cjs): `electron/preload.cjs`
- [Window and IPC runtime](https://github.com/nikhil-69/rag-chat/blob/main/electron/main.js): `electron/main.js`
- [Screenshot capture](https://github.com/nikhil-69/rag-chat/blob/main/electron/main.js): `electron/main.js`

### Backend services

- [Backend API client](https://github.com/nikhil-69/rag-chat/blob/main/src/api.ts): `src/api.ts`
- **Interview Helper backend**

### User preferences

- [Settings panel](https://github.com/nikhil-69/rag-chat/blob/main/src/components/SettingsPanel.tsx): `src/components/SettingsPanel.tsx`
- [Settings persistence](https://github.com/nikhil-69/rag-chat/blob/main/src/settings.ts): `src/settings.ts`

### App updates

- **GitHub releases**
- [Update handling](https://github.com/nikhil-69/rag-chat/blob/main/electron/main.js): `electron/main.js`

### Other components

- **Interview user**
- **Operating system**
- **System browser**

## Connections

- Interview user → React entry: opens app (evidence: `README.md`)
- React entry → Assistant workflow: renders (evidence: `src/main.tsx`)
- Assistant workflow → Backend API client: requests services (evidence: `src/App.tsx`)
- Backend API client → Interview Helper backend: calls API (evidence: `src/api.ts`)
- Assistant workflow → Interview Helper backend: sends chat and screenshots (evidence: `README.md`)
- Assistant workflow → Settings panel: shows settings (evidence: `src/App.tsx`)
- Assistant workflow → Settings persistence: loads and saves (evidence: `src/App.tsx`)
- Settings panel → Settings persistence: uses settings (evidence: `src/components/SettingsPanel.tsx`)
- Assistant workflow → IPC bridge: invokes desktop controls (evidence: `src/App.tsx`)
- IPC bridge → Window and IPC runtime: invokes IPC handlers (evidence: `electron/preload.cjs`)
- Window and IPC runtime → Screenshot capture: captures screen (evidence: `electron/main.js`)
- Screenshot capture → Operating system: uses capture APIs (evidence: `electron/main.js`)
- Window and IPC runtime → Operating system: registers global shortcut
- Assistant workflow → Update handling: requests and displays updates
- Update handling → GitHub releases: checks releases (evidence: `electron/main.js`)
- Assistant workflow → System browser: opens payment link
