# raghav-sharma03/ai-chatbot-springboot architecture

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

- Interactive diagram: https://gitdiagram.com/raghav-sharma03/ai-chatbot-springboot
- Repository: https://github.com/raghav-sharma03/ai-chatbot-springboot

## Overview

NovaMind AI is a Spring Boot chatbot with a browser chat interface, session-aware conversation memory, and multiple AI-provider routes. A user submits a message through the UI to the REST endpoint; the controller calls the chat service, which selects a provider by message length and falls back to Ollama on provider failure. The response includes the session ID and timestamps. The README documents UI themes and structured errors as well. Provider wiring and memory setup are visible in AppConfig; exception-handler dispatch is implicit in the excerpts, so that relationship is marked unverified.

Main entry points: [`src/main/java/project/chatbot/controller/Chat_Controller.java`](https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/controller/Chat_Controller.java) (Chat endpoint), [`src/main/java/project/chatbot/service/ChatService.java`](https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/service/ChatService.java) (Provider router), [`src/main/java/project/chatbot/AppConfig.java`](https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/AppConfig.java) (AI configuration), [`src/main/resources/static/index.html`](https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/resources/static/index.html) (Chat UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Chat interface"]
  node_ui["Chat UI<br/>[index.html]"]
  node_api["Chat endpoint"]
  node_request["Chat request<br/>[ChatRequest.java]"]
  node_response["Chat response<br/>[ChatResponse.java]"]
  node_errors["Error handling"]
  node_error_response["Error response<br/>[ErrorResponse.java]"]
end

subgraph group_conversation["Conversation handling"]
  node_service["Provider router<br/>[ChatService.java]"]
  node_memory[("Session memory<br/>[AppConfig.java]")]
end

subgraph group_providers["AI providers"]
  node_gemini{{"Gemini"}}
  node_openrouter{{"OpenRouter"}}
  node_ollama{{"Ollama"}}
end

subgraph group_runtime["Runtime and state"]
  node_config["AI configuration<br/>[AppConfig.java]"]
  node_app["Spring Boot app"]
end

node_user(("Chat user"))

node_user -->|"uses"| node_ui
node_ui -->|"posts message"| node_api
node_api -->|"accepts"| node_request
node_api -->|"calls"| node_service
node_api -->|"returns"| node_response
node_service -->|"uses session history"| node_memory
node_service -->|"routes short messages"| node_gemini
node_service -->|"routes long messages"| node_openrouter
node_service -->|"falls back"| node_ollama
node_config -->|"configures"| node_memory
node_config -->|"configures client"| node_gemini
node_config -->|"configures client"| node_openrouter
node_config -->|"configures client"| node_ollama
node_errors -->|"creates"| node_error_response
node_api -.->|"handles exceptions"| node_errors

click node_ui "https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/resources/static/index.html"
click node_api "https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/controller/Chat_Controller.java"
click node_request "https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/controller/ChatRequest.java"
click node_response "https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/controller/ChatResponse.java"
click node_errors "https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/exception/GlobalExceptionHandler.java"
click node_error_response "https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/exception/ErrorResponse.java"
click node_service "https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/service/ChatService.java"
click node_memory "https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/AppConfig.java"
click node_config "https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/AppConfig.java"
click node_app "https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/ChatbotApplication.java"

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_ui,node_api,node_request,node_response,node_errors,node_error_response,node_user toneBlue
class node_service,node_memory toneAmber
class node_gemini,node_openrouter,node_ollama toneMint
class node_config,node_app toneRose
```

## Components

### Chat interface

- [Chat UI](https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/resources/static/index.html): `src/main/resources/static/index.html`
- [Chat endpoint](https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/controller/Chat_Controller.java): `src/main/java/project/chatbot/controller/Chat_Controller.java`
- [Chat request](https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/controller/ChatRequest.java): `src/main/java/project/chatbot/controller/ChatRequest.java`
- [Chat response](https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/controller/ChatResponse.java): `src/main/java/project/chatbot/controller/ChatResponse.java`
- [Error handling](https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/exception/GlobalExceptionHandler.java): `src/main/java/project/chatbot/exception/GlobalExceptionHandler.java`
- [Error response](https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/exception/ErrorResponse.java): `src/main/java/project/chatbot/exception/ErrorResponse.java`

### Conversation handling

- [Provider router](https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/service/ChatService.java): `src/main/java/project/chatbot/service/ChatService.java`
- [Session memory](https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/AppConfig.java): `src/main/java/project/chatbot/AppConfig.java`

### AI providers

- **Gemini**
- **OpenRouter**
- **Ollama**

### Runtime and state

- [AI configuration](https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/AppConfig.java): `src/main/java/project/chatbot/AppConfig.java`
- [Spring Boot app](https://github.com/raghav-sharma03/ai-chatbot-springboot/blob/main/src/main/java/project/chatbot/ChatbotApplication.java): `src/main/java/project/chatbot/ChatbotApplication.java`

### Other components

- **Chat user**

## Connections

- Chat user → Chat UI: uses (evidence: `README.md`)
- Chat UI → Chat endpoint: posts message (evidence: `README.md`)
- Chat endpoint → Chat request: accepts (evidence: `src/main/java/project/chatbot/controller/Chat_Controller.java`)
- Chat endpoint → Provider router: calls (evidence: `src/main/java/project/chatbot/controller/Chat_Controller.java`)
- Chat endpoint → Chat response: returns (evidence: `src/main/java/project/chatbot/controller/Chat_Controller.java`)
- Provider router → Session memory: uses session history (evidence: `src/main/java/project/chatbot/service/ChatService.java`)
- Provider router → Gemini: routes short messages (evidence: `src/main/java/project/chatbot/service/ChatService.java`)
- Provider router → OpenRouter: routes long messages (evidence: `src/main/java/project/chatbot/service/ChatService.java`)
- Provider router → Ollama: falls back (evidence: `src/main/java/project/chatbot/service/ChatService.java`)
- AI configuration → Session memory: configures (evidence: `src/main/java/project/chatbot/AppConfig.java`)
- AI configuration → Gemini: configures client (evidence: `src/main/java/project/chatbot/AppConfig.java`)
- AI configuration → OpenRouter: configures client (evidence: `src/main/java/project/chatbot/AppConfig.java`)
- AI configuration → Ollama: configures client (evidence: `src/main/java/project/chatbot/AppConfig.java`)
- Error handling → Error response: creates (evidence: `src/main/java/project/chatbot/exception/GlobalExceptionHandler.java`)
- Chat endpoint → Error handling: handles exceptions
