How aadityauohyd/springboot-ai-rag-ollama-demo works
Main Components
• Frontend/API Layer: Although this project does not include a typical client-side UI, the REST API endpoint (handled by ChatController) serves as the primary interface for users.
• Application Core & Business Logic: The Spring Boot application as a whole, emphasizing the RAG implementation. Key subcomponents include:
• ChatController (REST API endpoints for interactions).
• DocumentIngestionService (ingests and processes the Spring Boot PDF documentation using Apache Tika and text splitting).
• External Service Integration (LLM):
• Ollama: Provides the language model (deepseek-r1:8b) running on http://localhost:11434.
• Data Storage Layer:
• PGVector Database: A PostgreSQL database enhanced with PGVector to store and retrieve vector embeddings.
• Supporting Components:
• Maven build configuration (pom.xml, maven wrapper).
• Docker Compose (compose.yml) for running the PGVector-enabled PostgreSQL container.
Relationships and Interactions
• REST API Requests: Clients send HTTP requests to the ChatController, which parses and forwards the requests to the RAG processing pipeline.
• RAG Pipeline Interaction:
• ChatController interacts with the DocumentIngestionService, which handles document parsing (using Apache Tika), text splitting, and vector embedding creation.
• Integration with Ollama:
• Data Storage:
• Docker Container:
• A note for the Docker Compose orchestration that runs the PGVector-enabled database.
Architectural Patterns and Design Principles
• Layered Architecture: Separate layers include the REST controller, service layer (business logic & document ingestion), integration adapters (to Ollama and PGVector), and supporting configuration (application.properties).
• Modular Design: The project structure hints at clear separation of concerns (API handling vs. ingestion vs. testing) which should be clearly represented.
• Microservice/Integration Style: Although this is a monolithic Spring Boot application, the distinct external dependencies (Ollama, PGVector) should be shown as separate services.
Relevant Technologies
• Java 21 and Spring Boot 3.4.3 as the core framework.
• Maven as the build and dependency management tool.
• PGVector and PostgreSQL (with container management via Docker Compose).
• Apache Tika for PDF ingestion.
• Ollama for LLM functionality (model deepseek-r1:8b).
• Spring AI for RAG implementation.