jarvis-assist/Claude outputs/JARVIS_SETUP.md

320 lines
8.6 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 🤖 JARVIS - KI-Assistent + Business Automation
**Vollständiges Docker-Stack für JARVIS: KI-Backend + Datenbanken + Workflow-Automation**
## Architektur-Übersicht
```
┌─────────────────────────────────────────────────────────┐
│ JARVIS CORE (VPS) │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ TRAEFIK (Reverse Proxy / Load Balancer) │ │
│ │ Ports: 80, 443, 8080 │ │
│ └─────────────────────────────────────────────────┘ │
│ ▼ │
│ ┌──────────────────┬──────────────────┬──────────────┐ │
│ │ WEB │ API │ n8n │ │
│ │ (Frontend) │ (FastAPI) │ (Automation) │ │
│ │ Port: 3000 │ Port: 8000 │ Port: 5678 │ │
│ └──────────────────┴──────────────────┴──────────────┘ │
│ ▼ │
│ ┌──────────────────┬──────────────────┬──────────────┐ │
│ │ PostgreSQL │ Redis │ Milvus │ │
│ │ Port: 5432 │ Port: 6379 │ Port: 19530 │ │
│ │ (Structured) │ (Cache) │ (Vector DB) │ │
│ └──────────────────┴──────────────────┴──────────────┘ │
│ ▼ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ OLLAMA (Local LLM - Optional) │ │
│ │ Port: 11434 │ │
│ │ Alternative: Claude API (via Python) │ │
│ └─────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────┘
```
## Schnelstart
### 1⃣ SSH-Zugriff einrichten
```bash
# Speichern der Private Key
# Putty: key → jarvis_ed25519.ppk
# SSH: ssh -i jarvis_ed25519 jarvis-core@72.61.186.98
```
### 2⃣ Setup-Script ausführen
```bash
ssh -i jarvis_ed25519 jarvis-core@72.61.186.98
# Download setup script
curl -o setup-jarvis-complete.sh https://path/to/setup-jarvis-complete.sh
chmod +x setup-jarvis-complete.sh
# Run with domain
./setup-jarvis-complete.sh jarvis.mbo-tech-it.de
```
### 3⃣ Konfigurieren
```bash
cd /home/jarvis-core/jarvis
# Edit .env - WICHTIG: API-Keys eintragen!
nano .env
# Erforderlich:
# - CLAUDE_API_KEY (für Claude API)
# - DB_PASSWORD (wird generiert, aber prüfe es)
# - Alle anderen Keys werden auto-generiert
```
### 4⃣ Docker-Stack starten
```bash
# Starten
docker-compose up -d
# Logs prüfen
docker-compose logs -f
# Status
docker-compose ps
```
## Services & Ports
| Service | URL | Port | Beschreibung |
|---------|-----|------|-------------|
| **Web Dashboard** | http://localhost:3000 | 3000 | Frontend UI |
| **API Backend** | http://localhost:8000 | 8000 | FastAPI Server |
| **n8n Workflows** | http://localhost:5678 | 5678 | Automatisierung |
| **Traefik Dashboard** | http://localhost:8080 | 8080 | Proxy Management |
| **PostgreSQL** | localhost | 5432 | Hauptdatenbank |
| **Redis** | localhost | 6379 | Cache/Sessions |
| **Milvus** | localhost | 19530 | Vector Search |
| **Ollama** | http://localhost:11434 | 11434 | Local LLM (opt.) |
## Datenbankstruktur
### PostgreSQL (jarvis)
- **users** - Benutzer & Authentifizierung
- **conversations** - Chat-Verlauf
- **messages** - Einzelne Nachrichten
- **tasks** - Automatisierungsaufgaben
- **documents** - Knowledge Base
- **audit_logs** - Audit Trail
### Milvus (Vector DB)
- Semantic Search in Dokumenten
- Embeddings für RAG (Retrieval-Augmented Generation)
### Redis
- Session Management
- Caching
- Job Queue (für n8n)
## API Endpoints
### Chat
```bash
POST /api/v1/chat
{
"conversation_id": 1,
"message": "Deine Frage",
"context": {}
}
GET /api/v1/conversations/{id}
```
### Tasks
```bash
POST /api/v1/tasks
{
"title": "Task Name",
"description": "Beschreibung",
"task_type": "automation",
"priority": 1
}
GET /api/v1/tasks?status=pending
```
### Documents (Knowledge Base)
```bash
POST /api/v1/documents
{
"title": "Dokument",
"content": "...",
"document_type": "manual"
}
GET /api/v1/documents?query=search+term
```
### Workflows (n8n)
```bash
POST /api/v1/workflows/trigger
{
"workflow_id": "workflow_name",
"data": {}
}
```
## Umgebungsvariablen (.env)
```bash
# Domain
DOMAIN=jarvis.mbo-tech-it.de
# Database
DB_PASSWORD=SecurePassword123!
# KI / LLM
CLAUDE_API_KEY=sk-ant-...
OLLAMA_MODEL=mistral
# Security
JWT_SECRET=random-secret-key
API_KEY_ADMIN=admin-api-key
# Logging
LOG_LEVEL=info
```
## Häufige Befehle
```bash
cd /home/jarvis-core/jarvis
# Alle Container starten
docker-compose up -d
# Spezifischen Service neu starten
docker-compose restart jarvis-api
# Logs ansehen
docker-compose logs -f jarvis-api
# In Container gehen
docker-compose exec jarvis-api bash
# Database mit psql verbinden
docker-compose exec postgres psql -U jarvis -d jarvis
# Alle Container stoppen
docker-compose down
# Mit Daten löschen (Vorsicht!)
docker-compose down -v
```
## Integration mit Claude API
### Python-Client Beispiel
```python
import os
import anthropic
client = anthropic.Anthropic(api_key=os.getenv("CLAUDE_API_KEY"))
message = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
messages=[
{"role": "user", "content": "Deine Frage"}
]
)
print(message.content[0].text)
```
## n8n Workflows
### Beispiel-Automation: Kundenbericht generieren
1. Trigger: Zeitplan (täglich)
2. Node: PostgreSQL - Daten abrufen
3. Node: Claude API - Bericht generieren
4. Node: PDF generieren
5. Node: Email versenden
## Security Best Practices
**Production Ready:**
- [ ] HTTPS/SSL konfigurieren (Let's Encrypt)
- [ ] Firewall-Regeln (nur erlaubte IPs)
- [ ] Secrets in .env nicht in Git
- [ ] Regelmäßige DB-Backups
- [ ] Monitoring & Alerts einrichten
- [ ] Rate Limiting aktivieren
- [ ] API-Keys rotieren
⚠️ **Aktuell (Test):**
- HTTP nur lokal/intern
- Standard-Passwörter (ÄNDERN!)
- Keine Authentifizierung erzwungen
## Troubleshooting
### Container startet nicht
```bash
docker-compose logs jarvis-api
# → Fehlerlog prüfen
```
### Datenbank nicht erreichbar
```bash
docker-compose exec postgres psql -U jarvis -d jarvis -c "SELECT 1"
```
### Redis Cache Fehler
```bash
docker-compose exec redis redis-cli ping
# → PONG = OK
```
### Milvus Vector DB Fehler
```bash
docker-compose exec milvus curl http://localhost:9091/healthz
```
## Monitoring
```bash
# System-Stats
docker stats
# Container Logs (real-time)
docker-compose logs -f
# Health Check
curl http://localhost:8000/health
curl http://localhost:8000/api/v1/admin/health/detailed
```
## Nächste Schritte
1. ✅ Docker-Stack deployed
2. ⏳ Claude API Integration (Python)
3. ⏳ Web-Frontend (React/Vue)
4. ⏳ n8n Workflows konfigurieren
5. ⏳ Knowledge Base aufbauen
6. ⏳ Production Deployment (SSL, Backups, etc.)
## Support & Dokumentation
- [FastAPI Docs](http://localhost:8000/docs) - Swagger UI
- [n8n Docs](https://docs.n8n.io)
- [PostgreSQL Docs](https://www.postgresql.org/docs/)
- [Milvus Docs](https://milvus.io/docs)
- [Claude API Docs](https://docs.anthropic.com)
---
🚀 **JARVIS ist bereit für die KI-Integration!**