# ansukhan164-rgb/nexus-ai-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/ansukhan164-rgb/nexus-ai-chatbot
- Repository: https://github.com/ansukhan164-rgb/nexus-ai-chatbot

## Overview

NEXUS is a browser-based chatbot backed by Flask and Gemini. A user enters a prompt in the interface; the frontend sends it with recent conversation history to the chat endpoint, which delegates generation to the AI service and returns the reply for display and local history. Separate health reporting exposes model configuration. The README also describes responsive presentation, themes, and context-aware chat; voice input is visible in the sampled frontend. Unsampled template and styling details are represented only at their tree paths, so their internal behavior is not inferred.

Main entry points: [`static/js/script.js`](https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/static/js/script.js) (Chat interface), [`app/routes/chat_routes.py`](https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/app/routes/chat_routes.py) (Chat endpoint), [`app/__init__.py`](https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/app/__init__.py) (App factory), [`app/services/ai_service.py`](https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/app/services/ai_service.py) (AI service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat interface"]
  node_frontend["Chat interface<br/>[script.js]"]
  node_chat_view["Chat page<br/>[index.html]"]
  node_styling["Responsive styling<br/>[style.css]"]
end

subgraph group_server["Flask application"]
  node_app_factory["App factory<br/>[__init__.py]"]
  node_chat_endpoint["Chat endpoint<br/>[chat_routes.py]"]
  node_health_endpoint["Health endpoint<br/>[system_routes.py]"]
end

subgraph group_intelligence["AI integration"]
  node_ai_service["AI service<br/>[ai_service.py]"]
  node_gemini["Gemini API"]
end

subgraph group_operations["Configuration and status"]
  node_configuration["App configuration<br/>[config.py]"]
end

node_user(("Chat user"))
node_browser_speech["Speech recognition"]
node_browser_storage[("Local storage")]
node_environment["Environment variables"]

node_user -->|"enters prompts"| node_frontend
node_frontend -->|"posts message"| node_chat_endpoint
node_chat_endpoint -->|"requests response"| node_ai_service
node_ai_service -->|"generates reply"| node_gemini
node_chat_endpoint -->|"returns reply"| node_frontend
node_frontend -->|"stores history"| node_browser_storage
node_browser_storage -->|"loads history"| node_frontend
node_user -.->|"speaks prompt"| node_browser_speech
node_browser_speech -.->|"provides speech input"| node_frontend
node_frontend -.->|"uses page"| node_chat_view
node_chat_view -.->|"uses styles"| node_styling
node_app_factory -->|"registers route"| node_chat_endpoint
node_app_factory -->|"registers route"| node_health_endpoint
node_app_factory -->|"renders page"| node_chat_view
node_health_endpoint -->|"checks settings"| node_configuration
node_ai_service -->|"reads model settings"| node_configuration
node_configuration -->|"loads variables"| node_environment
node_frontend -->|"checks status"| node_health_endpoint

click node_frontend "https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/static/js/script.js"
click node_chat_view "https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/templates/index.html"
click node_styling "https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/static/css/style.css"
click node_app_factory "https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/app/__init__.py"
click node_chat_endpoint "https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/app/routes/chat_routes.py"
click node_health_endpoint "https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/app/routes/system_routes.py"
click node_ai_service "https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/app/services/ai_service.py"
click node_configuration "https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/app/config.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_frontend,node_chat_view,node_styling,node_user toneBlue
class node_app_factory,node_chat_endpoint,node_health_endpoint,node_browser_storage toneAmber
class node_ai_service,node_gemini toneMint
class node_configuration toneRose
class node_browser_speech,node_environment toneIndigo
```

## Components

### Chat interface

- [Chat interface](https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/static/js/script.js): `static/js/script.js`
- [Chat page](https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/templates/index.html): `templates/index.html`
- [Responsive styling](https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/static/css/style.css): `static/css/style.css`

### Flask application

- [App factory](https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/app/__init__.py): `app/__init__.py`
- [Chat endpoint](https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/app/routes/chat_routes.py): `app/routes/chat_routes.py`
- [Health endpoint](https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/app/routes/system_routes.py): `app/routes/system_routes.py`

### AI integration

- [AI service](https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/app/services/ai_service.py): `app/services/ai_service.py`
- **Gemini API**

### Configuration and status

- [App configuration](https://github.com/ansukhan164-rgb/nexus-ai-chatbot/blob/main/app/config.py): `app/config.py`

### Other components

- **Chat user**
- **Speech recognition**
- **Local storage**
- **Environment variables**

## Connections

- Chat user → Chat interface: enters prompts (evidence: `static/js/script.js`)
- Chat interface → Chat endpoint: posts message (evidence: `static/js/script.js`)
- Chat endpoint → AI service: requests response (evidence: `app/routes/chat_routes.py`)
- AI service → Gemini API: generates reply (evidence: `app/services/ai_service.py`)
- Chat endpoint → Chat interface: returns reply (evidence: `app/routes/chat_routes.py`)
- Chat interface → Local storage: stores history (evidence: `static/js/script.js`)
- Local storage → Chat interface: loads history (evidence: `static/js/script.js`)
- Chat user → Speech recognition: speaks prompt
- Speech recognition → Chat interface: provides speech input (evidence: `static/js/script.js`)
- Chat interface → Chat page: uses page
- Chat page → Responsive styling: uses styles
- App factory → Chat endpoint: registers route (evidence: `app/__init__.py`)
- App factory → Health endpoint: registers route (evidence: `app/__init__.py`)
- App factory → Chat page: renders page (evidence: `app/__init__.py`)
- Health endpoint → App configuration: checks settings (evidence: `app/routes/system_routes.py`)
- AI service → App configuration: reads model settings (evidence: `app/services/ai_service.py`)
- App configuration → Environment variables: loads variables (evidence: `app/config.py`)
- Chat interface → Health endpoint: checks status (evidence: `static/js/script.js`)
