Table of Contents 8 Sections
Overview
This blueprint details how to build a 100% private, on-premise Retrieval-Augmented Generation (RAG) agent. It connects a local Ollama instance running DeepSeek-R1 (or Llama 3.3) with a self-hosted Qdrant vector database and n8n orchestration. No customer data or internal company documents ever leave your private server network.
This blueprint is autonomously synthesized and validated against Workflow Vault's Astro Content Collections schema. Review prerequisites and test against sandbox credentials prior to production deployment.
Glossary
- RAG (Retrieval-Augmented Generation)
- An architecture where an LLM is provided with relevant factual context retrieved from a private database before generating an answer, preventing hallucinations.
- DeepSeek-R1
- An open-weights reasoning model that uses reinforcement learning to produce verifiable, step-by-step chain-of-thought logic before answering.
- Qdrant
- An open-source vector similarity search engine written in Rust, optimized for fast semantic filtering and payload storage.
- Ollama
- A lightweight CLI and API server that downloads, optimizes, and runs open-source language models locally on your GPU or CPU.
Prerequisites
- [You'll need this already] A Linux server (VPS or local workstation) with at least 16 GB RAM (NVIDIA GPU recommended for sub-second inference, or modern CPU for 8B quantized models).
- [You'll need this already] Docker Engine 24+ and Docker Compose v2 installed.
- [You'll need this already] Basic familiarity with running shell commands over SSH.
- [Optional, not required] Cloudflare Tunnel or Caddy if exposing the n8n webhook endpoint to external Slack/Discord bots.
Where to Run This Automation
Where should you run this automation?
Don't have 24/7 hardware at home? Choose the setup that fits your budget and technical comfort.
Best for Freelancers, Agencies, and 24/7 Client Pipelines
If you don't have a dedicated server running at home, a Virtual Private Server (VPS) gives you a dedicated Linux server in the cloud that stays online 24/7 even when your personal laptop is closed.
- Cost: ~$4 to $6 / month (predictable flat fee, no per-execution surprises).
- Providers: Hetzner Cloud, DigitalOcean, Linode / Akamai, Railway, or OVH.
- Key advantage: You get a permanent public IP address and free SSL certificates, which are essential for receiving incoming Stripe, Airtable, or GitHub webhooks reliably.
curl -fsSL https://get.docker.com | sh && sudo usermod -aG docker $USER Best for Hobbyists, Testing & Zero-Cost Experimentation
You can run this automation completely free on your everyday computer (Mac, Windows, or Linux) or on low-cost home hardware like a Raspberry Pi 4/5 or repurposed mini PC.
- Cost: $0 / month (100% free).
- Software needed: Docker Desktop (free for personal use) or native Node.js / Python.
- Consideration: Automations will only execute while your computer is powered on and awake. To receive incoming webhooks locally, use tools like
ngrokorCloudflare Tunnelsfor secure local tunneling.
Best for Zero-Maintenance 1-Click Operations
If you don't want to manage Docker containers or terminal commands, you can run automations directly on managed serverless platforms or official SaaS plans:
- Cloudflare Workers: Free tier includes 100,000 requests per day with 0ms cold starts.
- n8n Cloud / Make / Zapier: Fully managed hosted platforms with automated backups and visual scenario builders.
- Railway / Render: 1-click Git container deploys with auto-healing and managed PostgreSQL databases.
Step 1: Define the Unified Multi-Container Compose Stack
Create a dedicated directory `ai-rag-stack` and define `docker-compose.yml` declaring n8n, Ollama with GPU acceleration (or CPU fallback), and Qdrant storage.
services:
ollama:
image: ollama/ollama:latest
container_name: ollama_llm
restart: unless-stopped
volumes:
- ollama_data:/root/.ollama
ports:
- "127.0.0.1:11434:11434"
qdrant:
image: qdrant/qdrant:latest
container_name: qdrant_db
restart: unless-stopped
ports:
- "127.0.0.1:6333:6333"
volumes:
- qdrant_data:/qdrant/storage
n8n:
image: n8nio/n8n:latest
container_name: n8n_rag_engine
restart: unless-stopped
ports:
- "127.0.0.1:5678:5678"
environment:
- N8N_HOST=localhost
- N8N_PORT=5678
- N8N_PROTOCOL=http
- WEBHOOK_URL=http://localhost:5678/
volumes:
- n8n_data:/home/node/.n8n
depends_on:
- ollama
- qdrant
volumes:
ollama_data:
qdrant_data:
n8n_data: Running n8n, Ollama, and Qdrant in the same Docker network provides high-speed internal socket communication and eliminates public exposure of the database.
All 3 containers start cleanly without port conflicts.
Step 2: Pull the DeepSeek-R1 Model & Embedding Model
Execute the Ollama CLI inside the running container to pull the quantized reasoning model and a high-speed embedding model.
# Pull DeepSeek-R1 (8B distilled reasoning model)
docker exec -it ollama_llm ollama run deepseek-r1:8b
# Pull high-performance BGE embedding model for vector indexing
docker exec -it ollama_llm ollama pull bge-m3 The LLM needs weights downloaded to disk before the n8n agent node can establish inference sessions.
Ollama downloads model weights and responds with a success status.
Step 3: Configure the n8n RAG Chain & Vector Store Connector
Open n8n at `http://localhost:5678`, add an `AI Agent` node, configure `Ollama Chat Model` (Host: `http://ollama:11434`, Model: `deepseek-r1:8b`), attach the `Qdrant Vector Store` tool, and set top-k retrieval to 4.
{
"nodes": [
{
"name": "Ollama DeepSeek-R1",
"type": "@n8n/n8n-nodes-langchain.lmChatOllama",
"parameters": {
"model": "deepseek-r1:8b",
"baseURL": "http://ollama:11434"
}
},
{
"name": "Qdrant Vector Store",
"type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
"parameters": {
"qdrantUrl": "http://qdrant:6333",
"collectionName": "company_docs"
}
}
]
} Connecting the vector retriever node to Ollama ensures n8n queries Qdrant first, injects relevant document chunks into memory, and passes the augmented prompt to DeepSeek-R1.
n8n verifies the connection to both internal containers.
Workflow architecture
Webhook / Slack Trigger -> n8n AI Agent Node -> Ollama (DeepSeek-R1 Reasoner) <-> Qdrant Vector DB (Dense Embeddings) -> Synthesized Response with Citations
Final result
A private, zero-subscription RAG pipeline processing sensitive queries locally with step-by-step reasoning and semantic document retrieval.
Troubleshooting
Ollama returns HTTP 500 or out-of-memory error
The selected model size exceeds available system RAM or VRAM.
Switch to a smaller quantized model such as deepseek-r1:1.5b or allocate swap space on Linux (`sudo fallocate -l 8G /swapfile`).
n8n cannot connect to http://ollama:11434
Docker containers are running on separate bridge networks or using localhost instead of container hostnames.
Use the internal Docker service name `http://ollama:11434` rather than `http://localhost:11434` inside n8n.