Act as an Expert Spring Boot Developer.
Generated Prompt
```markdown
## APPLICATION OVERVIEW
This application is a web-based College Chatbot designed to assist students and faculty by providing accurate answers to queries based on approved public college documents. Utilizing the Retrieval-Augmented Generation (RAG) pattern via the Spring AI framework, the chatbot ensures secure interactions by strictly adhering to contextual information without revealing sensitive management data.
## CORE FEATURES
1. **Secure Data Handling**: Ensures that the chatbot only responds based on approved public documents, safeguarding sensitive information.
2. **Intelligent Query Processing**: Leverages the RAG pattern to provide accurate and contextually relevant answers to user questions.
3. **PDF Document Ingestion**: Automatically reads and processes college documents in PDF format to keep the knowledge base updated.
4. **RESTful API Integration**: Offers a straightforward REST API for seamless integration with front-end applications or other services.
5. **User-Friendly Interface**: Minimalist design focused on clarity and accessibility, enhancing user experience during interactions.
## DESIGN SPECIFICATIONS
- **Visual Style**: Minimalist - Clean, simple design with plenty of white space and a minimal color palette that emphasizes typography.
- **Color Mode**: Light theme with dark text on light backgrounds for easy readability.
- **Layout**: A single-column layout with a centered input field for user questions and a clear display area for chatbot responses. Ample padding and margins to enhance focus on content.
- **Typography**: Use a sans-serif font (like Arial or Helvetica) with a clear hierarchy (e.g., headers in bold, larger sizes for emphasis, standard text in regular weight).
## TECHNICAL REQUIREMENTS
- **Framework**: Spring Boot 3.x for server-side logic.
- **Database**: PostgreSQL with pgvector for vector storage.
- **Dependencies**:
- Spring Boot Web
- Spring AI Starter (OpenAI)
- Spring AI Vector Store
- Spring AI PDF Document Reader
- **Java Version**: Java 17 or 21
## IMPLEMENTATION STEPS
1. **Setup Maven Project**:
- Create a new Spring Boot project with the required dependencies in `pom.xml`:
```xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-openai-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-vector-store-postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-pdf-document-reader</artifactId>
</dependency>
</dependencies>
```
2. **Configure Application Properties**:
- Set up `application.yml` with OpenAI API key and PostgreSQL connection:
```yaml
spring:
datasource:
url: jdbc:postgresql://localhost:5432/college
username: your_username
password: your_password
ai:
openai:
api-key: your_openai_api_key
model: gpt-4o-mini
```
3. **Create Data Ingestion Service**:
- Implement `CollegeDataLoader.java` to load PDF documents into the VectorStore:
```java
@Component
public class CollegeDataLoader implements CommandLineRunner {
@Autowired
private PagePdfDocumentReader pdfReader;
@Autowired
private VectorStore vectorStore;
@Override
public void run(String... args) throws Exception {
// Load and process PDF
List<String> chunks = pdfReader.read("classpath:mock-college-doc.pdf");
for (String chunk : chunks) {
vectorStore.add(chunk);
}
}
}
```
4. **Build Chatbot Service**:
- Create `CollegeChatbotService.java`:
```java
@Service
public class CollegeChatbotService {
@Autowired
private ChatClient chatClient;
@Autowired
private VectorStore vectorStore;
public String askQuestion(String question) {
String response = chatClient.ask(new Question(question, "You are the official AI assistant for the college. You MUST ONLY answer questions based on the retrieved context."));
return response != null ? response : "I don't have access to that information.";
}
}
```
5. **Set Up REST Controller**:
- Implement `ChatController.java`:
```java
@RestController
@RequestMapping("/api/chat")
public class ChatController {
@Autowired
private CollegeChatbotService chatbotService;
@PostMapping
public ResponseEntity<String> chat(@RequestBody String question) {
String answer = chatbotService.askQuestion(question);
return ResponseEntity.ok(answer);
}
}
```
## USER EXPERIENCE
Users will interact with the chatbot through a simple web interface where they can type their questions into an input field. The chatbot processes the input via the REST API, retrieves relevant information from the VectorStore, and provides answers in a clear and concise manner. The design ensures that users can easily view interactions, maintaining focus on the dialogue without distractions.
```Loved by thousands of makers from
From early prototypes to real products, they started here.







































Generate optimized prompts for your vibe coding projects
Generate prompt
Enter a brief description of the app you want to build and get an optimized prompt
Review and use your prompt
Review (and edit if necessary) the generated prompt, then copy it or open it directly in your chosen platform
Get inspired with new ideas
Get AI-generated suggestions to expand your product with features that will surprise your users
Frequently Asked Questions
Everything you need to know about creating better prompts for your Lovable projects
Still have questions?
Can't find what you're looking for? We're here to help!
