An AI-powered backend system that allows users to upload PDF documents and ask questions about them using a Large Language Model.
The application extracts text from documents, converts it into vector embeddings, stores them in a vector database, and retrieves relevant information to answer user questions.
This project demonstrates a Retrieval Augmented Generation (RAG) architecture built using modern AI backend technologies.
- Upload PDF documents
- Extract text from uploaded PDFs
- Split documents into smaller chunks
- Generate vector embeddings
- Store embeddings in a vector database
- Perform semantic search using vector similarity
- Ask questions about uploaded documents
- AI generates answers using relevant document context
- Streaming AI responses using Server-Sent Events
- JWT based authentication
This system uses Retrieval Augmented Generation to answer questions from documents.
User Question
↓
Generate Question Embedding
↓
Vector Similarity Search
↓
Retrieve Relevant Document Chunks
↓
Send Context + Question to LLM
↓
Generate AI Answer
flowchart TD
User[User]
User -->|Upload PDF| API[Spring Boot API]
User -->|Ask Question| API
API --> PDF[PDF Extraction - PDFBox]
PDF --> Chunk[Text Chunking]
Chunk --> Embed[Embedding Model]
Embed --> VectorDB[(PostgreSQL + pgvector)]
VectorDB --> Search[Vector Similarity Search]
Search --> Context[Build Context]
Context --> LLM[Ollama LLM]
LLM --> Answer[Streaming AI Response]
Answer --> User
- Spring Boot
- Spring AI
- Ollama
- Llama 3 (LLM)
- nomic-embed-text (embedding model)
- PostgreSQL
- pgvector (Vector search extension)
- Apache PDFBox
- Docker
- IntelliJ IDEA
POST /api/auth/register
POST /api/auth/login
POST /api/doc_assistant/upload
GET /api/doc_assistant/file
GET /api/doc_assistant/download
GET /api/doc_assistant/extract
POST /api/doc_assistant/prompt
{
"prompt": "What is spring boot?"
}
AI response is streamed using Server-Sent Events (SSE)
git clone https://github.com/Shweta-281/Doc-Assistant.git
Start Ollama:
ollama run llama3.2
Pull Embedding Model:
ollama pull nomic-embed-text
Using Docker:
docker run -d \
-p 5432:5432 \
-e POSTGRES_PASSWORD=postgres \
ankane/pgvector
Enable extension:
CREATE EXTENSION vector;
Update application.properties
spring.datasource.url=jdbc:postgresql://localhost:5432/docassistant
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.ai.ollama.base-url=http://localhost:11434
spring.ai.ollama.chat.model=llama3.2
spring.ai.ollama.embedding.options.model=nomic-embed-text
./mvnw spring-boot:run
Server runs on:
http://localhost:8080
- Multi-document intelligent search
- Document source citations
- Chat memory
- Web UI for document chat
- Hybrid search (keyword + vector)
- Documenet summarization
Shweta S.