Personal Retrieval-Augmented Generation app: knowledge ingestion (text / URL / PDF) plus streaming chat over your own data.
This implementation is built entirely on free and open-source models (Ollama language/embedding models, Apache OpenNLP, and an ONNX reranker — no paid APIs). I wrote all the code by hand, without any AI agent, in order to learn the RAG system properly end to end.
personal-rag-backend/– Spring Boot API (Java 21, Maven). Serveshttp://localhost:8080. See its README for module details.personal-rag-frontend/– static chat UI (no build step). Served vianpm startonhttp://localhost:3000, talks to the backend.
- Java 21 and Maven 3.9+
- Node.js 18+ (for serving the frontend)
- PostgreSQL 16+ with the
pgvectorextension - Ollama (serving on
http://localhost:11434) - Internet access (frontend loads
marked,highlight.jsand Google Fonts from CDN)
git clone https://github.com/zakaria5729/personal-rag-fullstack.git
cd personal-rag-fullstackCreate the database (tables are migrated automatically by Flyway on startup):
createdb static_ragDefault connection (see personal-rag-backend/app-module/src/main/resources/application-app.yml):
host localhost:5432, db static_rag, user postgres, password password.
To use your own credentials, export env vars before starting the backend:
export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/static_rag
export SPRING_DATASOURCE_USERNAME=<your-user>
export SPRING_DATASOURCE_PASSWORD=<your-password>ollama pull phi4-mini:latest
ollama pull nomic-embed-text:137m-v1.5-fp16The backend loads two ML models from disk. Download them, then place them at the configured paths
(configured in personal-rag-backend/rag-module/src/main/resources/application-rag.yml):
| File(s) | Place at | Get it from |
|---|---|---|
opennlp-en-ud-ewt-sentence-1.3-2.5.4.bin |
<sentence-split.model-path> (exact file path) |
https://opennlp.apache.org/models.html |
model.onnx + model.onnx_data + tokenizer.json |
<reranker.models-base-path>/ (all three side by side) |
any compatible ONNX cross-encoder reranker export |
mkdir -p /path/to/sentence-split /path/to/reranker
cp opennlp-en-ud-ewt-sentence-1.3-2.5.4.bin /path/to/sentence-split/
cp model.onnx model.onnx_data tokenizer.json /path/to/reranker/Then point the app at your paths (no code change needed — env vars override the yml):
export SENTENCE_SPLIT_MODEL_PATH=/path/to/sentence-split/opennlp-en-ud-ewt-sentence-1.3-2.5.4.bin
export RERANKER_MODELS_BASE_PATH=/path/to/rerankerNotes:
- The sentence model is required — the app fails fast at startup if it is missing.
- The reranker is optional — without it the app still starts but falls back to keyword scoring, so answer quality drops.
cd personal-rag-backend
mvn -pl rag-module,app-module -am compile
mvn -pl app-module -am spring-boot:runAPI base: http://localhost:8080/knowledge/*. Logs: ~/logfiles/static-rag/.
cd personal-rag-frontend
npm startOpen http://localhost:3000. The UI calls the backend URL set in js/config.js (BASE_URL, default http://localhost:8080) — change it there if your backend runs elsewhere.
Ingest text:
curl -X POST localhost:8080/knowledge/create \
-H 'Content-Type: application/json' \
-d '{"content":"RAG stands for Retrieval-Augmented Generation.","type":"TEXT"}'Ingest a web page (the backend scrapes it):
curl -X POST localhost:8080/knowledge/create \
-H 'Content-Type: application/json' \
-d '{"content":"https://example.com/article","type":"URL"}'Ingest a PDF:
curl -X POST localhost:8080/knowledge/create/pdf \
-F pdf_file=@document.pdfAsk (streams the answer as SSE):
curl -N -X POST localhost:8080/knowledge/ask \
-H 'Content-Type: application/json' \
-d '{"query":"What does RAG stand for?"}'Manage knowledge (id is the numeric knowledge id, hash_id comes from create responses):
curl -X PUT 'localhost:8080/knowledge/update?id=1' \
-H 'Content-Type: application/json' \
-d '{"content":"Updated content."}'
curl 'localhost:8080/knowledge/id?id=1'
curl 'localhost:8080/knowledge/all?size=20'
curl 'localhost:8080/knowledge/vector?hash_id=<hash_id>'
curl -X DELETE 'localhost:8080/knowledge/delete?id=1'Ask a question:
- Type a question in the input box, e.g.
What does RAG stand for?, and hit send. - Watch the status chips (
analyzing-query→retrieving-info→reranking-info→generating-response) while the answer streams in. - Use the stop button to cancel a running answer,
New Queryto start a fresh session, or the mic button to dictate instead of typing. Answers can be read aloud. - Past sessions appear in the sidebar; you can rename (update query) or delete them.
Ingest knowledge — click Ingest Knowledge (sidebar) and pick a tab:
- TEXT tab: paste plain text, e.g.
RAG stands for Retrieval-Augmented Generation., thenIngest Knowledge. - URL tab: enter a page URL, e.g.
https://example.com/article— the backend scrapes and ingests it. - PDF tab: click or drag-and-drop a
.pdffile, then ingest.
Manage knowledge — open the Knowledge Management view:
- Browse ingested items (
Load Morepages through history). - Click an item to see its full content (copy button included).
- Open
Knowledge Vector Content Chunksto inspect the stored embedding chunks. - Update an item's text or delete items you no longer need.