Zero-knowledge privacy proxy for LLMs - Enterprise-grade middleware that strips PII before sending data to LLMs and restores it on the way back.
cd cli && cargo build --release
sudo cp cli/target/release/saferoute /usr/local/bin/
saferoute install
saferoute start -dgit clone https://github.com/saferoute/saferoute.git
cd saferoute
make build
make upgit clone https://github.com/saferoute/saferoute.git
cd saferouter
docker compose up -dAccess at:
- Main App: http://localhost (Caddy reverse proxy)
- Proxy: http://localhost:8080
- Dashboard: http://localhost:3000
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3001
# Development build
cd cli && cargo build
# Release build (optimized)
cd cli && cargo build --release
# Run tests
cd cli && cargo test
# Cross-platform builds
cargo build --release --target x86_64-unknown-linux-gnu
cargo build --release --target aarch64-apple-darwin
cargo build --release --target x86_64-pc-windows-msvc# All services
make build
# Individual services
cd services/ner-service && uv build
cd services/proxy && go build ./...
cd services/vault && cargo build --release
cd services/dashboard && bun run build# Run all tests
make test
# Individual service tests
cd cli && cargo test
cd services/ner-service && uv run pytest
cd services/proxy && go test ./...
cd services/vault && cargo test# Install CLI
cd cli && cargo build --release
sudo cp cli/target/release/saferoute /usr/local/bin/
# Development workflow
saferoute install
saferoute start -d
saferoute logs -f
saferoute health
# Run tests
make test
# Stop services
saferoute stopSafeRoute is a zero-knowledge privacy proxy with four core components:
- High-performance request router
- 50,000+ req/sec throughput
- <5ms latency overhead
- Prometheus metrics
- Ultra-fast PII detection (<10ms)
- 99.2% accuracy
- Regex-based pattern matching
- Medical & legal domain support
- AES-256-GCM encryption
- Memory-only storage
- 60-second auto-purge TTL
- Zero persistent logs
- Modern UI with shadcn/ui
- Live demo interface
- Real-time metrics
- Vite + React 19 + TypeScript
Client Request
↓
[1] Proxy receives request
↓
[2] NER detects PII entities (SSN, email, phone, etc.)
↓
[3] Vault stores encrypted entities
↓
[4] Proxy tokenizes request ([SSN_001], [EMAIL_001])
↓
[5] Forward to LLM provider (tokenized, no PII)
↓
[6] LLM processes request
↓
[7] Vault retrieves entities
↓
[8] Proxy restores original PII
↓
Client Response (with original PII)
saferoute install
saferoute start
saferoute start --detached
saferoute stop
saferoute status
saferoute logs
saferoute logs --follow
saferoute uninstallhttp://localhost:8080
POST /v1/chat/completions
Process chat completion with automatic PII protection.
Request:
{
"model": "claude-sonnet-4-20250514",
"messages": [{
"role": "user",
"content": "Patient John Doe, SSN 123-45-6789, needs medication"
}],
"temperature": 0.7,
"max_tokens": 1000
}Response:
{
"id": "msg_123",
"object": "chat.completion",
"created": 1704067200,
"model": "claude-sonnet-4-20250514",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "I can help John Doe with medication..."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 50,
"total_tokens": 70
}
}Headers:
X-Request-ID: Unique request identifierX-Latency-Ms: Total processing time
POST /v1/anonymize
Detect and anonymize PII in text.
Request:
{
"text": "Contact John Doe at john@example.com or 555-123-4567"
}Response:
{
"request_id": "550e8400-e29b-41d4-a716-446655440000",
"anonymized_text": "Contact [PERSON_001] at [EMAIL_001] or [PHONE_001]",
"entities_count": 3
}POST /v1/restore
Restore original PII from anonymized text.
Request:
{
"request_id": "550e8400-e29b-41d4-a716-446655440000",
"text": "Contact [PERSON_001] at [EMAIL_001]"
}Response:
{
"restored_text": "Contact John Doe at john@example.com"
}GET /health
{
"status": "healthy",
"service": "proxy",
"version": "1.0.0"
}GET /metrics
Prometheus metrics endpoint.
- SSN:
\b\d{3}-\d{2}-\d{4}\b - Phone:
\b\d{3}-\d{3}-\d{4}\b - Email:
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b - Credit Card:
\b\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b - Date:
\b\d{1,2}/\d{1,2}/\d{4}\b - Person Name:
\b[A-Z][a-z]+ [A-Z][a-z]+\b - ZIP Code:
\b\d{5}(?:-\d{4})?\b - IP Address:
\b(?:\d{1,3}\.){3}\d{1,3}\b
- MRN:
\bMRN[:\s]+\d{6,10}\b - Patient ID:
\b(?:Patient|PT)[-\s]?ID[:\s]+[\w-]+\b - ICD Diagnosis:
\bICD[-\s]?\d{1,2}[:\s]+[\w.-]+\b
- Case Number:
\b\d{2}-\w+-\d{4,6}\b - Bar Number:
\bBar[#\s]+\d{6,8}\b - Docket:
\bDocket[#\s]+[\w-]+\b
- Algorithm: AES-256-GCM
- Key Management: Per-request unique keys
- Nonce: Cryptographically secure random (12 bytes)
- Authentication: AEAD (Authenticated Encryption with Associated Data)
- Storage: Memory-only (no disk writes)
- TTL: 60 seconds default
- Purge: Automatic background task every 10s
- Logs: Zero PII in logs
- HIPAA compliant
- GDPR compliant
- SOC 2 ready
- Zero-knowledge architecture
- Data breaches (encrypted storage)
- Insider threats (no persistent logs)
- Man-in-the-middle (TLS 1.3)
- Replay attacks (unique request IDs)
- Side-channel attacks (constant-time crypto)
- NER Detection: 5-10ms
- Vault Store: 1-2ms
- LLM Processing: Variable (provider-dependent)
- Vault Retrieve: 1-2ms
- Response Restoration: <1ms
Total Overhead: 15-20ms average
- Proxy: 50,000 req/sec
- NER: 10,000 req/sec
- Vault: 100,000 req/sec
# Setup
make setup
# Edit .env with your API keys
nano .env
# Build services
make build
# Start
make up
# View logs
make logs
# Stop
make down# Deploy
make deploy
# Or manually:
kubectl apply -f infrastructure/kubernetes/namespace.yaml
kubectl apply -f infrastructure/kubernetes/secrets.yaml
kubectl apply -f infrastructure/kubernetes/proxy-deployment.yaml
kubectl apply -f infrastructure/kubernetes/ner-deployment.yaml
kubectl apply -f infrastructure/kubernetes/vault-deployment.yaml
kubectl apply -f infrastructure/kubernetes/ingress.yamlCheck status:
kubectl get pods -n saferoute
kubectl get services -n saferoute
kubectl get ingress -n saferouteHorizontal scaling:
kubectl scale deployment proxy -n saferoute --replicas=5
kubectl scale deployment ner-service -n saferoute --replicas=4
kubectl scale deployment vault -n saferoute --replicas=3Auto-scaling (HPA):
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: proxy-hpa
namespace: saferoute
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: proxy
minReplicas: 3
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70# LLM Provider
LLM_PROVIDER_URL=https://api.anthropic.com
LLM_API_KEY=your-api-key-here
# Vault
VAULT_MASTER_KEY=your-32-byte-secure-key-here
TTL_SECONDS=60
# Monitoring
GRAFANA_PASSWORD=admin
# Optional
REDIS_URL=redis://redis:6379
LOG_LEVEL=infoGenerate a secure 32-byte key:
openssl rand -base64 32# Generate new key
NEW_KEY=$(openssl rand -base64 32)
# Update Kubernetes secret
kubectl create secret generic saferoute-secrets \
--from-literal=vault-master-key="$NEW_KEY" \
--dry-run=client -o yaml | kubectl apply -f -
# Rolling restart
kubectl rollout restart deployment/vault -n saferouteAvailable at http://localhost:9090
Key metrics:
http_requests_total- Total HTTP requestshttp_request_duration_seconds- Request latencyvault_entries_stored- Vault storage countner_entities_detected- NER detection count
Available at http://localhost:3001 (admin/admin)
Dashboards:
- Proxy metrics (request rate, latency, errors)
- NER metrics (detection rate, accuracy)
- Vault metrics (storage, TTL, purge rate)
- alert: HighErrorRate
expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.05
for: 5m
annotations:
summary: "High error rate detected"
- alert: VaultStorageHigh
expr: vault_entries_stored > 9000
for: 1m
annotations:
summary: "Vault storage approaching limit"- Go 1.25+ - Proxy gateway
- Python 3.11+ with UV - NER service (fast dependency management)
- Rust 1.88+ - Encrypted vault
- React 19 + TypeScript + Vite - Dashboard
- Tailwind CSS v4 + shadcn/ui - UI components
- Docker & Kubernetes - Deployment
- Prometheus & Grafana - Monitoring
saferoute/
├── cli/ # Rust CLI tool
│ ├── src/main.rs
│ └── Cargo.toml
├── services/
│ ├── proxy/ # Go Gateway (Port 8080)
│ ├── ner-service/ # Python JAX NER (Port 8081)
│ ├── vault/ # Rust Vault (Port 8082)
│ └── dashboard/ # React Dashboard (Port 3000)
├── infrastructure/
│ ├── kubernetes/ # K8s manifests
│ └── monitoring/ # Prometheus & Grafana
├── install.sh # One-command installer
├── docker-compose.yml
├── Makefile
└── README.md
- Docker 24.0+
- Docker Compose 2.20+
- Go 1.25+
- Python 3.11+
- Rust 1.88+
- Node.js 18+
# Clone
git clone https://github.com/saferoute/saferoute
cd saferoute
# Build CLI
cd cli && cargo build --release
# Build services
docker-compose build
# Start
docker-compose up# Go tests
cd services/proxy && go test ./...
# Python tests
cd services/ner-service && uv run pytest
# Rust tests
cd services/vault && cargo test
# Dashboard tests
cd services/dashboard && npm test- Check Docker is running:
docker ps - Check ports aren't in use:
lsof -i :8080 - View logs:
docker-compose logs
- Verify API key in
.env - Check service health:
curl http://localhost:8080/health - View proxy logs:
docker-compose logs proxy
- Check resource usage:
docker stats - Scale services:
docker-compose up --scale proxy=3 - Monitor metrics: http://localhost:9090
- Fork the repository
- Create a branch:
git checkout -b feature/your-feature - Make changes and test
- Commit:
git commit -m "Add feature" - Push:
git push origin feature/your-feature - Open a Pull Request
Code standards:
- Go: Follow Effective Go
- Python: Follow PEP 8, use
blackandruff - Rust: Follow Rust API Guidelines
- React: Follow Airbnb React Style Guide
Report vulnerabilities: security@saferoute.io
Do not open public issues for security vulnerabilities.
MIT License - Copyright (c) 2026 SafeRoute
- Documentation: https://docs.saferoute.io
- GitHub Issues: https://github.com/saferoute/saferoute/issues
- Email: support@saferoute.io
- Discord: https://discord.gg/saferoute
Built with ❤️ for privacy-conscious developers