# prathmeshd-k/ai-agent_springai architecture

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

- Interactive diagram: https://gitdiagram.com/prathmeshd-k/ai-agent_springai
- Repository: https://github.com/prathmeshd-k/ai-agent_springai

## Overview

This Spring Boot/Spring AI application accepts chat requests through a Thymeleaf interface or REST endpoint, uses a memory-enabled AI chat client to answer, and exposes travel and store-support tools for model-selected actions. Tool implementations include sample in-memory data and a placeholder weather forecast, rather than external booking or inventory systems. The README documents the overall flow and capabilities; source excerpts confirm controller delegation, client configuration, tool registration, and selected tool/model relationships.

Main entry points: [`src/main/java/com/substring/agent/backend/config/AiConfig.java`](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/config/AiConfig.java) (Chat client), [`src/main/resources/templates/chat.html`](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/resources/templates/chat.html) (Chat page), [`src/main/java/com/substring/agent/backend/tools/FlightTools.java`](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/tools/FlightTools.java) (Flight search), [`src/main/java/com/substring/agent/backend/tools/HotelTools.java`](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/tools/HotelTools.java) (Hotel search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_chat_ui["Chat page<br/>[chat.html]"]
  node_view_controller["View controller"]
  node_chat_controller["Chat endpoint"]
end

subgraph group_orchestration["AI orchestration"]
  node_chat_service["Chat service<br/>[ChatService.java]"]
  node_ai_config["AI configuration<br/>[AiConfig.java]"]
  node_chat_client["Chat client<br/>[AiConfig.java]"]
  node_chat_memory["Conversation memory<br/>[AiConfig.java]"]
end

subgraph group_travel["Travel tools"]
  node_flight_tools["Flight search<br/>[FlightTools.java]"]
  node_hotel_tools["Hotel search<br/>[HotelTools.java]"]
  node_weather_tools["Weather forecast<br/>[WeatherTools.java]"]
end

subgraph group_support["Store support"]
  node_order_tools["Order management<br/>[OrderTools.java]"]
  node_inventory_tools["Inventory lookup"]
end

subgraph group_domain["Domain models"]
  node_flight_model["Flight data<br/>[Flight.java]"]
  node_hotel_model["Hotel data<br/>[Hotel.java]"]
end

node_user(("User"))
node_openai["OpenAI API"]

node_user -->|"uses"| node_chat_ui
node_chat_ui -->|"requests page"| node_view_controller
node_view_controller -->|"returns view"| node_chat_ui
node_user -->|"sends chat"| node_chat_controller
node_chat_controller -->|"delegates chat"| node_chat_service
node_chat_service -->|"prompts"| node_chat_client
node_ai_config -->|"configures"| node_chat_client
node_ai_config -->|"configures"| node_chat_memory
node_chat_client -->|"uses"| node_chat_memory
node_chat_client -->|"sends prompt"| node_openai
node_chat_client -->|"registers tool"| node_flight_tools
node_chat_client -->|"registers tool"| node_hotel_tools
node_chat_client -->|"registers tool"| node_weather_tools
node_chat_client -->|"registers tool"| node_order_tools
node_chat_client -->|"registers tool"| node_inventory_tools
node_openai -->|"selects and calls"| node_flight_tools
node_openai -->|"selects and calls"| node_hotel_tools
node_openai -->|"selects and calls"| node_weather_tools
node_openai -->|"selects and calls"| node_order_tools
node_openai -->|"selects and calls"| node_inventory_tools
node_flight_tools -->|"uses data"| node_flight_model
node_hotel_tools -->|"uses data"| node_hotel_model

click node_chat_ui "https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/resources/templates/chat.html"
click node_view_controller "https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/controller/ViewController.java"
click node_chat_controller "https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/controller/ChatController.java"
click node_chat_service "https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/service/ChatService.java"
click node_ai_config "https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/config/AiConfig.java"
click node_chat_client "https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/config/AiConfig.java"
click node_chat_memory "https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/config/AiConfig.java"
click node_flight_tools "https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/tools/FlightTools.java"
click node_hotel_tools "https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/tools/HotelTools.java"
click node_weather_tools "https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/tools/WeatherTools.java"
click node_order_tools "https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/tools/OrderTools.java"
click node_inventory_tools "https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/tools/InventoryTools.java"
click node_flight_model "https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/model/Flight.java"
click node_hotel_model "https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/model/Hotel.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_chat_ui,node_view_controller,node_chat_controller,node_user toneBlue
class node_chat_service,node_ai_config,node_chat_client,node_chat_memory toneAmber
class node_flight_tools,node_hotel_tools,node_weather_tools,node_openai toneMint
class node_order_tools,node_inventory_tools toneRose
class node_flight_model,node_hotel_model toneIndigo
```

## Components

### User interface

- [Chat page](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/resources/templates/chat.html): `src/main/resources/templates/chat.html`
- [View controller](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/controller/ViewController.java): `src/main/java/com/substring/agent/backend/controller/ViewController.java`
- [Chat endpoint](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/controller/ChatController.java): `src/main/java/com/substring/agent/backend/controller/ChatController.java`

### AI orchestration

- [Chat service](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/service/ChatService.java): `src/main/java/com/substring/agent/backend/service/ChatService.java`
- [AI configuration](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/config/AiConfig.java): `src/main/java/com/substring/agent/backend/config/AiConfig.java`
- [Chat client](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/config/AiConfig.java): `src/main/java/com/substring/agent/backend/config/AiConfig.java`
- [Conversation memory](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/config/AiConfig.java): `src/main/java/com/substring/agent/backend/config/AiConfig.java`

### Travel tools

- [Flight search](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/tools/FlightTools.java): `src/main/java/com/substring/agent/backend/tools/FlightTools.java`
- [Hotel search](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/tools/HotelTools.java): `src/main/java/com/substring/agent/backend/tools/HotelTools.java`
- [Weather forecast](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/tools/WeatherTools.java): `src/main/java/com/substring/agent/backend/tools/WeatherTools.java`

### Store support

- [Order management](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/tools/OrderTools.java): `src/main/java/com/substring/agent/backend/tools/OrderTools.java`
- [Inventory lookup](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/tools/InventoryTools.java): `src/main/java/com/substring/agent/backend/tools/InventoryTools.java`

### Domain models

- [Flight data](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/model/Flight.java): `src/main/java/com/substring/agent/backend/model/Flight.java`
- [Hotel data](https://github.com/prathmeshd-k/ai-agent_springai/blob/main/src/main/java/com/substring/agent/backend/model/Hotel.java): `src/main/java/com/substring/agent/backend/model/Hotel.java`

### Other components

- **User**
- **OpenAI API**

## Connections

- User → Chat page: uses (evidence: `README.md`)
- Chat page → View controller: requests page (evidence: `README.md`)
- View controller → Chat page: returns view (evidence: `src/main/java/com/substring/agent/backend/controller/ViewController.java`)
- User → Chat endpoint: sends chat (evidence: `README.md`)
- Chat endpoint → Chat service: delegates chat (evidence: `src/main/java/com/substring/agent/backend/controller/ChatController.java`)
- Chat service → Chat client: prompts (evidence: `src/main/java/com/substring/agent/backend/service/ChatService.java`)
- AI configuration → Chat client: configures (evidence: `src/main/java/com/substring/agent/backend/config/AiConfig.java`)
- AI configuration → Conversation memory: configures (evidence: `src/main/java/com/substring/agent/backend/config/AiConfig.java`)
- Chat client → Conversation memory: uses (evidence: `src/main/java/com/substring/agent/backend/config/AiConfig.java`)
- Chat client → OpenAI API: sends prompt (evidence: `README.md`)
- Chat client → Flight search: registers tool (evidence: `src/main/java/com/substring/agent/backend/config/AiConfig.java`)
- Chat client → Hotel search: registers tool (evidence: `src/main/java/com/substring/agent/backend/config/AiConfig.java`)
- Chat client → Weather forecast: registers tool (evidence: `src/main/java/com/substring/agent/backend/config/AiConfig.java`)
- Chat client → Order management: registers tool (evidence: `src/main/java/com/substring/agent/backend/config/AiConfig.java`)
- Chat client → Inventory lookup: registers tool (evidence: `src/main/java/com/substring/agent/backend/config/AiConfig.java`)
- OpenAI API → Flight search: selects and calls (evidence: `README.md`)
- OpenAI API → Hotel search: selects and calls (evidence: `README.md`)
- OpenAI API → Weather forecast: selects and calls (evidence: `README.md`)
- OpenAI API → Order management: selects and calls (evidence: `README.md`)
- OpenAI API → Inventory lookup: selects and calls (evidence: `README.md`)
- Flight search → Flight data: uses data (evidence: `src/main/java/com/substring/agent/backend/tools/FlightTools.java`)
- Hotel search → Hotel data: uses data (evidence: `src/main/java/com/substring/agent/backend/tools/HotelTools.java`)
