PrivaDoc AI is a secure, self-hosted Document Retrieval-Augmented Generation (RAG) assistant. It allows teams to upload sensitive documents, automatically parse them with high-fidelity layout analysis, store vector embeddings in a pgvector database, and perform context-aware private Q&A using locally-running Large Language Models (LLMs) via Ollama.
- 🔒 Complete Data Privacy: Operates entirely offline using local LLMs (via Ollama) and self-hosted databases. No document content ever leaves your infrastructure.
- 📂 Multi-Modal Document Parsing: Leverages the high-resolution parsing capabilities of the Unstructured API to ingest multi-format files (PDFs, TXT, DOCX, etc.) while preserving structural context (like section titles).
- ⚡ Contextual Vector Search: Chunks documents dynamically and stores their mathematical representations inside PostgreSQL with the
pgvectorextension using thenomic-embed-textembedding model. - 👥 Tenant-like Collaboration Groups: Organize documents and chats into Groups. Access control is enforced at the database level so users can only chat with documents in groups they are active members of.
- 💬 History-Aware Q&A: Automatically reformulates follow-up chat messages into standalone queries by analyzing the context of recent conversation history before performing similarity search.
- 🚀 Modern SPA Dashboard: A responsive Angular 21 Single Page Application featuring group managers, member role management, real-time ingestion status indicators, and an interactive chat interface.
PrivaDoc AI uses a modern multi-tier microservices architecture designed to prioritize privacy and scalability:
graph TD
subgraph Frontend [Client Tier]
A[Angular 21 SPA]
end
subgraph Backend [Application Tier]
B[Spring Boot App]
C[Spring Security + JWT]
D[Spring AI Core]
end
subgraph Infrastructure [Data & Inference Tier]
E[(PostgreSQL + pgvector)]
F[Unstructured API Service]
G[Ollama Local Inference]
end
A -->|REST API + JWT| B
B --> C
B -->|Ingest/Retrieve| E
B -->|Parse Layouts| F
D -->|Embeddings / Chat| G
- Frontend (Angular 21): Captures user interaction, handles upload streams, and renders markdown answers with reference citations.
- Backend (Spring Boot 3.5): Orchestrates authentication (JWT), file storage, and the RAG pipeline. It leverages Spring AI to interface with Ollama.
- Vector Database (PostgreSQL + pgvector): Acts as both the relational database (for users, groups, sessions, and messages) and the semantic storage for document vector chunks.
- Document Parser (Unstructured API): Analyzes document layouts to separate titles, text, tables, and headers for smarter chunking.
- Local LLM Engine (Ollama): Generates embeddings using
nomic-embed-textand processes Q&A answers using local models (default configured:gemma4).
Follow these steps to run PrivaDoc AI on your local machine.
Make sure you have the following installed on your machine:
- Install and start Ollama on your machine.
- Download the required embedding and chat models by running the following commands in your terminal:
(Note: You can change the models by updating
ollama pull nomic-embed-text ollama pull gemma4
spring.ai.ollama.chat.options.modelandspring.ai.ollama.embedding.options.modelinsideprivadocai/src/main/resources/application.properties.)
We use Docker Compose to run PostgreSQL (with pgvector) and the unstructured-api container.
From the root directory of the project, run:
docker-compose up -d postgres-vector unstructured-apiThis command starts:
- Postgres Database on port
5432with usernamepriva-admin, passwordLdwpe30idn03@#, and databasepriva-db. - Unstructured API on port
8001(internally port8000).
- Navigate to the backend directory:
cd privadocai - Run the application using Gradle:
- On Windows (PowerShell/CMD):
./gradlew.bat bootRun
- On Linux/macOS:
./gradlew bootRun
- On Windows (PowerShell/CMD):
The backend server will start running on http://localhost:8080. The database tables and VectorStore schema will be initialized automatically on the first startup.
- Navigate to the client directory:
cd ../client - Install the frontend dependencies:
npm install
- Start the Angular development server:
(Or run
npm run dev
npx ng serve)
Open your browser and navigate to http://localhost:4200 to access the application.
If you prefer not to install Node.js and Java locally, you can run the entire application inside Docker containers.
- Ensure Ollama is running on your host machine and accessible.
- From the root directory, run:
docker-compose up --build -d
- The frontend will be accessible at
http://localhost:4200and the backend api athttp://localhost:8080.
- All endpoints under
/api/chat/**and/api/document/**require a valid JWT header (Authorization: Bearer <TOKEN>). - User permissions are validated to ensure users cannot upload, delete, ingest documents, or initiate chats in groups where they are not active members.
- Document files are stored locally in the directory specified by
app.storage.upload-dir(default:./documents).