Self-Hosted AI for Enterprise: Architecture and Deployment Guide
TL;DR — Self-hosted enterprise AI deploys LLM inference, vector search, and knowledge graphs on your own infrastructure. No data leaves your network. The stack: LLM (Llama 3 or Mistral via vLLM/Ollama), vector database (pgvector or Qdrant), knowledge graph (FalkorDB or Neo4j), RAG pipeline (FastAPI + LangChain), embeddings (BGE or E5), reranking (BGE-Reranker), and source connectors (Nango). Self-host when data sovereignty is required, cost at scale exceeds API costs (break-even: ~75-100 users or 100K+ queries/month), or compliance demands on-premise processing (EU AI Act, GDPR, HIPAA). Hardware: 1-2 GPUs for 70B models, 32-128GB RAM for vector search and knowledge graph. Deploy in 1-2 days (basic) or 2-4 weeks (production-grade with ACLs, citations, and audit logging). All components are open-source.
The question isn't "cloud or on-prem?" — it's "what are we protecting, and what does the organization need?" Enterprise AI architecture should be driven by data sensitivity, compliance requirements, and cost at scale, not by vendor convenience.
Self-hosted AI means every component — LLM inference, vector search, knowledge graph, RAG pipeline — runs on your infrastructure. No data leaves your network. No per-query API costs. No vendor lock-in. Full control over retrieval, generation, and permissions.
Self-Hosted vs Cloud API: When to Choose Each
| Factor | Self-Hosted | Cloud API (OpenAI, Anthropic) |
|---|---|---|
| Data sovereignty | ✅ Full control | ❌ Data leaves your network |
| Cost at scale | ✅ Infrastructure only | ❌ Per-query pricing |
| Setup time | Days to weeks | Minutes |
| Model quality | Good (Llama 3, Mistral) | Best (GPT-4o, Claude 3.5) |
| Maintenance | Your team | Vendor handles |
| Compliance | ✅ Full control | Depends on vendor certs |
| Customization | ✅ Full control | Limited to API features |
| Break-even point | ~75-100 users | N/A |
| Vendor lock-in | ✅ None | ❌ High |
The Self-Hosted AI Stack
(vector + BM25)"] FalkorDB["FalkorDB
(knowledge graph)"] Reranker["BGE-Reranker
(cross-encoder)"] end subgraph Pipeline["RAG Pipeline"] FastAPI["FastAPI
(orchestration)"] LangChain["LangChain / LlamaIndex"] Embedder["BGE Embeddings"] end subgraph Data["Data Layer"] Connectors["Nango Connectors
(Google Drive, Slack, Confluence)"] PostgreSQL["PostgreSQL
(metadata, ACLs, audit)"] end subgraph Ops["Operations"] Prometheus["Prometheus"] Grafana["Grafana"] Docker["Docker Compose / K8s"] end Connectors --> Pipeline Pipeline --> Retrieval Retrieval --> Inference Inference --> Answer["Source-Cited Answer"] PostgreSQL --> Pipeline Ops -.-> Inference Ops -.-> Retrieval Ops -.-> Pipeline
Component Selection
| Layer | Technology | Why | Alternative |
|---|---|---|---|
| LLM inference | vLLM | Highest throughput, PagedAttention | Ollama (easier setup), TGI |
| LLM model | Llama 3 70B | Best open-weight model | Mistral Large, Qwen 2.5 |
| Vector store | pgvector | Vectors + SQL + ACLs in one DB | Qdrant, Weaviate |
| Knowledge graph | FalkorDB | Redis-compatible, fast graph traversal | Neo4j, Apache AGE |
| Embeddings | BGE-large-en-v1.5 | Best open-source embeddings | E5-large, GTE |
| Reranker | BGE-Reranker-v2-m3 | Best open-source cross-encoder | mxbai-rerank, FlashRank |
| RAG framework | FastAPI + LangChain | Python-native, async, typed | LlamaIndex, Haystack |
| Source connectors | Nango | Open-source, 100+ connectors | Custom OAuth, Airbyte |
| Database | PostgreSQL | Metadata, ACLs, audit logs | MySQL, CockroachDB |
| Monitoring | Prometheus + Grafana | Industry standard | Datadog, OpenTelemetry |
| Deployment | Docker Compose → K8s | Start simple, scale when needed | Helm, Nomad |
Hardware Requirements
| Scale | LLM | Vector Store | Graph | Total RAM | GPU | Est. Cost |
|---|---|---|---|---|---|---|
| Small (<100 users) | Llama 3 8B (quantized) | 1M vectors | 100K nodes | 64GB | 1x L40S | $500-1,500/mo |
| Medium (100-500 users) | Llama 3 70B (quantized) | 5M vectors | 1M nodes | 128GB | 1x A100 80GB | $2,000-4,000/mo |
| Large (500+ users) | Llama 3 70B (full precision) | 50M vectors | 10M nodes | 256GB+ | 2x A100 80GB | $5,000-10,000/mo |
Deployment Architecture
Docker Compose (Small to Medium)
version: "3.9"
services:
# LLM inference
ollama:
image: ollama/ollama:latest
ports: ["11434:11434"]
volumes: ["ollama_data:/root/.ollama"]
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
# PostgreSQL + pgvector
postgres:
image: pgvector/pgvector:pg16
ports: ["5432:5432"]
environment:
POSTGRES_DB: aidb
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes: ["pg_data:/var/lib/postgresql/data"]
# Knowledge graph (FalkorDB)
falkordb:
image: falkordb/falkordb:latest
ports: ["6379:6379"]
volumes: ["falkor_data:/data"]
# RAG API
rag-api:
build: .
ports: ["8000:8000"]
environment:
OLLAMA_URL: http://ollama:11434
DATABASE_URL: postgresql://postgres:${DB_PASSWORD}@postgres/aidb
FALKORDB_URL: redis://falkordb:6379
depends_on: [ollama, postgres, falkordb]
# Monitoring
prometheus:
image: prom/prometheus:latest
ports: ["9090:9090"]
volumes: ["./prometheus.yml:/etc/prometheus/prometheus.yml"]
volumes:
ollama_data:
pg_data:
falkor_data:
Production Considerations
| Concern | Solution |
|---|---|
| High availability | Deploy multiple API instances behind load balancer |
| Model updates | Blue-green deployment for LLM model swaps |
| Backup | PostgreSQL point-in-time recovery + vector index snapshots |
| Security | Zero-trust network, mTLS between services |
| Audit logging | Log all queries, retrievals, and answers to PostgreSQL |
| ACL enforcement | Row-level security in PostgreSQL |
| Monitoring | Prometheus metrics: latency, cache hit rate, hallucination rate |
| Scaling | Vertical (bigger GPU) before horizontal (multiple GPUs) |
Cost Comparison: Self-Hosted vs Cloud API
| Scenario | Self-Hosted (monthly) | Cloud API (monthly) | Savings |
|---|---|---|---|
| 100 users, 10K queries | $1,500 (infra) | $500 (API) | -$1,000 |
| 200 users, 50K queries | $2,500 (infra) | $2,500 (API) | Break-even |
| 500 users, 250K queries | $4,000 (infra) | $12,500 (API) | $8,500 |
| 1000 users, 500K queries | $6,000 (infra) | $25,000 (API) | $19,000 |
Break-even point: ~200 users or ~50K queries/month. Below that, cloud APIs are cheaper. Above that, self-hosting saves dramatically.
Self-Hosted AI Deployment Checklist
- [ ] Assess data sensitivity: does data need to stay on-premise?
- [ ] Calculate break-even: compare API costs vs infrastructure costs at your scale
- [ ] Choose LLM: Llama 3 70B (quality) or 8B (cost), Mistral as alternative
- [ ] Choose inference engine: vLLM (throughput) or Ollama (simplicity)
- [ ] Choose vector database: pgvector (PostgreSQL) or Qdrant
- [ ] Choose knowledge graph: FalkorDB (lightweight) or Neo4j (feature-rich)
- [ ] Set up Docker Compose for development, Kubernetes for production
- [ ] Configure GPU access for LLM inference (NVIDIA driver + CUDA)
- [ ] Implement hybrid retrieval (BM25 + vector + RRF)
- [ ] Add cross-encoder reranking (BGE-Reranker)
- [ ] Set up source connectors with Nango
- [ ] Implement content hash deduplication in ingestion
- [ ] Configure document-level ACLs in PostgreSQL
- [ ] Implement AI citations with source verification
- [ ] Add hallucination prevention: confidence threshold, faithfulness check
- [ ] Set up semantic answer caching for cost reduction
- [ ] Configure Prometheus + Grafana monitoring
- [ ] Set up audit logging for EU AI Act Article 12 compliance
- [ ] Implement backup and recovery (PostgreSQL PITR + vector snapshots)
- [ ] Configure zero-trust security between services
- [ ] Test with real enterprise queries from different departments
- [ ] Plan model update strategy (blue-green deployment)
- [ ] Consider temporal knowledge graphs for versioned facts
- [ ] Document the architecture for company brain integration
- [ ] Set up alerting: latency p99, error rate, cache hit rate, hallucination rate
FAQ
What is self-hosted enterprise AI?
Self-hosted enterprise AI is AI infrastructure deployed on your own servers or private cloud, where all data processing, LLM inference, vector search, and knowledge graph operations happen within your network. No data leaves your infrastructure. The stack typically includes: an LLM (Llama, Mistral via Ollama or vLLM), a vector database (pgvector, Qdrant), a knowledge graph (FalkorDB, Neo4j), a RAG pipeline (FastAPI + LangChain), and source connectors. Self-hosted AI provides data sovereignty, no per-user costs, full control over retrieval and generation, and compliance with EU AI Act, GDPR, and HIPAA.
Why self-host AI instead of using cloud APIs?
Self-host AI when: (1) data sovereignty is required — sensitive data cannot leave your network, (2) cost at scale — API costs for 500K+ queries/month exceed infrastructure costs, (3) compliance — EU AI Act, GDPR, HIPAA, or SOC 2 require on-premise processing, (4) customization — you need full control over retrieval, reranking, and generation, (5) vendor lock-in avoidance — you don't want dependency on OpenAI, Anthropic, or Google. The break-even point is typically 75-100 users or 100K+ queries/month.
What hardware do you need for self-hosted AI?
For LLM inference: 1-2 GPUs (NVIDIA A100 80GB or L40S) for 70B parameter models, or a single GPU for 8B-13B models. For CPU-only inference: 64-128GB RAM with quantized models (GGUF format). For vector search: CPU with 32-64GB RAM is sufficient for up to 10M vectors. For knowledge graph: 16-32GB RAM. Total infrastructure: $2,000-10,000/month for cloud instances, or $15,000-50,000 one-time for on-premise hardware. A single A100 instance costs ~$3-4/hour on cloud providers.
What is the best open-source AI stack for enterprise?
The recommended open-source enterprise AI stack: LLM inference with vLLM or Ollama (Llama 3 or Mistral), vector database with pgvector (PostgreSQL extension) or Qdrant, knowledge graph with FalkorDB or Neo4j, RAG orchestration with FastAPI + LangChain or LlamaIndex, embeddings with BGE or E5 models, reranking with BGE-Reranker-v2-m3, source connectors with Nango, and monitoring with Prometheus + Grafana. All components are open-source and self-hostable.
How long does it take to deploy self-hosted AI?
A basic self-hosted RAG system can be deployed in 1-2 days using Docker Compose with Ollama, pgvector, and a FastAPI wrapper. A production-grade enterprise deployment with hybrid retrieval, cross-encoder reranking, ACL enforcement, citation verification, audit logging, and multiple source connectors takes 2-4 weeks. The longest phase is typically the ingestion pipeline — connecting to data sources, chunking, embedding, and ACL tagging. Start with a single source (e.g., company wiki) and expand.
Want a self-hosted AI company brain that does all of this out of the box?
Book a demo →