How gautamkr538/springai-bots works
Project Type and Purpose
• Type: Backend microservice (Spring Boot) with REST APIs.
• Purpose: Provide chat and weather endpoints, perform web-data crawling, extract/enrich content, compute AI embeddings (RAG), and return structured responses.
File Structure
• Top-level artifacts: compose.yaml (Docker Compose), pom.xml (Maven), src/main/java (code), src/main/resources/application.properties.
• Config packages: EmbeddingConfig, SwaggerConfig.
• Controllers: ChatController, WeatherController.
• DTOs: WebDataRequest, BlogPostResponseDTO, ErrorResponse.
• Services (interfaces & implementations): ChatService(+Impl), WebDataService(+Impl), WeatherServiceImpl, plus utility WebDataUtils.
• Exception handling: custom exceptions + GlobalExceptionHandler.
README
• Confirms multimedia features with Spring AI and web crawling.
• No explicit DB layer shown, but DatabaseException exists—reserve space for data persistence or future extension.
Main Components & Interactions
a. API Layer (REST Controllers)
• ChatController (POST /chat)
• WeatherController (GET/POST /weather)
• (Optionally) endpoints under WebDataService if exposed.
b. Service Layer
• ChatServiceImpl: orchestrates RAG flow—calls WebDataService, EmbeddingConfig’s vector store, OpenAI client.
• WebDataServiceImpl: performs web crawling, content extraction (WebDataUtils).
• WeatherServiceImpl & WeatherTools: calls third-party weather APIs and transforms results.
c. Config Layer
• EmbeddingConfig: sets up embedding/vector store bean.
• SwaggerConfig: configures Swagger UI for API docs.
d. Utility Layer
• WebDataUtils: low-level HTML parsing, cleaning.
e. Exception Layer
• GlobalExceptionHandler: maps exceptions (ChatServiceException, CrawlException, DatabaseException) to HTTP error responses using ErrorResponse DTO.
f. External Systems
• External websites to crawl.
• OpenAI (or other AI provider) for embeddings and chat completions.
• Third-party weather API.
• (Future) Database or vector store for persistence.
Architectural Patterns & Design Principles
• Layered architecture: Controller → Service → Utility/External.
• Dependency Injection for Config and Services.
• Exception translation via GlobalExceptionHandler.
• Externalized config via application.properties and Docker Compose.
• API documentation via Swagger.