Rename project from any-llm to laravel-llm
- Remove old any-llm related files (Dockerfile, config.yml, web/, setup-laravel.sh) - Update README.md with new Laravel LLM Gateway documentation - Keep docker-compose.yml with laravel-llm container names - Clean project structure for Laravel-only implementation
This commit is contained in:
440
README.md
440
README.md
@@ -1,11 +1,16 @@
|
||||
# Any-LLM Gateway + Laravel Admin
|
||||
# Laravel LLM Gateway
|
||||
|
||||
Vollständiges Docker-Setup mit:
|
||||
- **Any-LLM Gateway** (API Gateway für LLMs)
|
||||
- **Laravel Admin Panel** (Verwaltungsoberfläche)
|
||||
- **PostgreSQL** (Datenbank)
|
||||
- **Adminer** (Datenbank-Management-Tool)
|
||||
- **Gateway Tester** (Test-Oberfläche)
|
||||
Ein umfassendes Laravel-basiertes LLM Gateway System mit Multi-Provider-Support, Kosten-Tracking, Budget-Management und Admin-Interface.
|
||||
|
||||
## 🎯 Hauptfeatures
|
||||
|
||||
- **Multi-Provider Support**: OpenAI, Anthropic, DeepSeek, Google Gemini, Mistral AI
|
||||
- **Per-User API Keys**: Verschlüsselte Speicherung von Provider-Credentials pro Benutzer
|
||||
- **Kosten-Tracking**: Detaillierte Verfolgung von Token-Nutzung und Kosten
|
||||
- **Budget-Management**: Flexible Budget-Limits und Benachrichtigungen
|
||||
- **Rate Limiting**: Schutz vor Überlastung
|
||||
- **Admin-Interface**: Umfassende Verwaltungsoberfläche mit Laravel/Livewire
|
||||
- **OpenAI-kompatible API**: Standard-konforme Endpoints
|
||||
|
||||
---
|
||||
|
||||
@@ -13,24 +18,19 @@ Vollständiges Docker-Setup mit:
|
||||
|
||||
### Voraussetzungen
|
||||
- Docker & Docker Compose installiert
|
||||
- Ports 80, 8000, 8080, 8081 verfügbar
|
||||
- Port 80 und 8081 verfügbar
|
||||
|
||||
### Installation
|
||||
|
||||
```bash
|
||||
cd /opt/any-llm
|
||||
./setup-laravel.sh
|
||||
cd /opt/laravel-llm
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Das Setup-Script führt automatisch aus:
|
||||
1. ✅ Laravel Installation
|
||||
2. ✅ Livewire & Breeze Setup
|
||||
3. ✅ Docker Container Build & Start
|
||||
4. ✅ Datenbank-Migrationen
|
||||
5. ✅ Admin-User Erstellung
|
||||
6. ✅ Assets-Kompilierung
|
||||
|
||||
**⏱️ Dauer: ca. 5-10 Minuten**
|
||||
Das System startet automatisch:
|
||||
- Laravel Anwendung auf Port 80
|
||||
- MariaDB 11.4 Datenbank
|
||||
- phpMyAdmin auf Port 8081
|
||||
|
||||
---
|
||||
|
||||
@@ -40,25 +40,22 @@ Das Setup-Script führt automatisch aus:
|
||||
|
||||
| Service | URL | Beschreibung |
|
||||
|---------|-----|--------------|
|
||||
| **Laravel Admin** | http://localhost:80 | Verwaltungsoberfläche |
|
||||
| **Gateway API** | http://localhost:8000 | Any-LLM Gateway |
|
||||
| **Gateway Tester** | http://localhost:8080 | Test-Interface |
|
||||
| **Adminer** | http://localhost:8081 | PostgreSQL Management |
|
||||
| **Laravel Admin** | http://localhost:80 | Admin-Interface |
|
||||
| **phpMyAdmin** | http://localhost:8081 | Datenbank-Management |
|
||||
|
||||
### Login-Daten
|
||||
|
||||
#### Laravel Admin
|
||||
```
|
||||
Email: admin@example.com
|
||||
Password: password123
|
||||
Email: admin@laravel-llm.local
|
||||
Password: [Dein Admin-Passwort]
|
||||
```
|
||||
|
||||
#### Adminer (PostgreSQL)
|
||||
#### phpMyAdmin (MariaDB)
|
||||
```
|
||||
System: PostgreSQL
|
||||
Server: postgres
|
||||
Username: gateway
|
||||
Password: gateway
|
||||
Server: mariadb
|
||||
Username: root
|
||||
Password: rootpass
|
||||
Database: gateway
|
||||
```
|
||||
|
||||
@@ -67,28 +64,63 @@ Database: gateway
|
||||
## 📁 Projekt-Struktur
|
||||
|
||||
```
|
||||
/opt/any-llm/
|
||||
├── config.yml # Gateway Konfiguration
|
||||
├── docker-compose.yml # Docker Services
|
||||
├── setup-laravel.sh # Setup Script
|
||||
/opt/laravel-llm/
|
||||
├── docker-compose.yml # Docker Services Definition
|
||||
├── backup_*.sql # Datenbank-Backups
|
||||
│
|
||||
├── laravel/ # Laravel Docker Config
|
||||
│ ├── Dockerfile
|
||||
│ ├── nginx.conf
|
||||
│ ├── supervisord.conf
|
||||
│ └── php.ini
|
||||
│ ├── Dockerfile # PHP 8.3 + Nginx
|
||||
│ ├── nginx.conf # Webserver Config
|
||||
│ ├── supervisord.conf # Process Manager
|
||||
│ └── php.ini # PHP Einstellungen
|
||||
│
|
||||
├── laravel-app/ # Laravel Projekt (wird generiert)
|
||||
│ ├── app/
|
||||
│ ├── database/
|
||||
│ ├── resources/
|
||||
│ └── ...
|
||||
│
|
||||
├── web/ # Gateway Tester
|
||||
│ ├── index.html
|
||||
│ └── default.conf
|
||||
│
|
||||
└── LARAVEL_IMPLEMENTATION.md # Detailliertes Implementierungskonzept
|
||||
└── laravel-app/ # Laravel Anwendung
|
||||
├── app/
|
||||
│ ├── Http/Controllers/ # Admin Controllers
|
||||
│ ├── Models/ # Eloquent Models
|
||||
│ ├── Services/LLM/ # Provider Services
|
||||
│ └── ...
|
||||
├── database/
|
||||
│ └── migrations/ # Datenbank Schema
|
||||
├── resources/
|
||||
│ └── views/ # Blade Templates
|
||||
└── routes/
|
||||
└── web.php # Admin Routes
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🗄️ Datenbank-Schema
|
||||
|
||||
### Haupttabellen
|
||||
|
||||
| Tabelle | Beschreibung |
|
||||
|---------|--------------|
|
||||
| `admins` | Admin-Benutzer für das Interface |
|
||||
| `users` | Gateway-Benutzer (API-Nutzer) |
|
||||
| `user_provider_keys` | Verschlüsselte Provider API-Keys |
|
||||
| `usage_logs` | Request-Tracking und Kosten |
|
||||
| `budgets` | Budget-Definitionen |
|
||||
| `budget_reset_logs` | Budget-Historie |
|
||||
| `model_pricing` | Modell-Kosten-Konfiguration |
|
||||
|
||||
### Datenbank-Zugriff
|
||||
|
||||
**Via phpMyAdmin:**
|
||||
```
|
||||
http://localhost:8081
|
||||
Server: mariadb
|
||||
User: root
|
||||
Password: rootpass
|
||||
```
|
||||
|
||||
**Via CLI:**
|
||||
```bash
|
||||
docker compose exec mariadb mysql -u gateway -pgateway gateway
|
||||
|
||||
# Beispiel-Queries
|
||||
SELECT * FROM users;
|
||||
SELECT * FROM usage_logs ORDER BY created_at DESC LIMIT 10;
|
||||
```
|
||||
|
||||
---
|
||||
@@ -98,157 +130,158 @@ Database: gateway
|
||||
### Container Management
|
||||
|
||||
```bash
|
||||
# Alle Container starten
|
||||
# Container starten
|
||||
docker compose up -d
|
||||
|
||||
# Alle Container stoppen
|
||||
# Container stoppen
|
||||
docker compose down
|
||||
|
||||
# Logs anzeigen
|
||||
docker compose logs -f
|
||||
|
||||
# Logs eines bestimmten Services
|
||||
docker compose logs -f laravel
|
||||
docker compose logs -f gateway
|
||||
|
||||
# Container neu bauen
|
||||
docker compose up -d --build
|
||||
|
||||
# In Container einloggen
|
||||
# In Laravel Container einloggen
|
||||
docker compose exec laravel bash
|
||||
docker compose exec postgres psql -U gateway -d gateway
|
||||
```
|
||||
|
||||
### Laravel Commands (im Container)
|
||||
### Laravel Artisan Commands
|
||||
|
||||
```bash
|
||||
# Artisan Commands
|
||||
# Migrationen
|
||||
docker compose exec laravel php artisan migrate
|
||||
docker compose exec laravel php artisan make:model ModelName
|
||||
docker compose exec laravel php artisan make:controller ControllerName
|
||||
|
||||
# Composer
|
||||
docker compose exec laravel composer install
|
||||
docker compose exec laravel composer require package-name
|
||||
# Cache leeren
|
||||
docker compose exec laravel php artisan cache:clear
|
||||
docker compose exec laravel php artisan config:clear
|
||||
|
||||
# NPM
|
||||
docker compose exec laravel npm install
|
||||
docker compose exec laravel npm run dev
|
||||
docker compose exec laravel npm run build
|
||||
# Queue Worker starten
|
||||
docker compose exec laravel php artisan queue:work
|
||||
|
||||
# Tinker (Laravel REPL)
|
||||
docker compose exec laravel php artisan tinker
|
||||
```
|
||||
|
||||
---
|
||||
### Asset Compilation
|
||||
|
||||
## 🗄️ Datenbank
|
||||
|
||||
### Schema
|
||||
|
||||
Die Gateway-Datenbank enthält folgende Tabellen:
|
||||
|
||||
```
|
||||
users → Gateway API Users
|
||||
api_keys → Virtual Keys
|
||||
usage_logs → Request Tracking
|
||||
budgets → Budget Definitions
|
||||
budget_reset_logs → Budget History
|
||||
model_pricing → Model Cost Configuration
|
||||
admins → Laravel Admin Users (neu)
|
||||
```
|
||||
|
||||
### Zugriff
|
||||
|
||||
**Via Adminer Web-Interface:**
|
||||
- http://localhost:8081
|
||||
- Login mit oben genannten Credentials
|
||||
|
||||
**Via CLI:**
|
||||
```bash
|
||||
docker compose exec postgres psql -U gateway -d gateway
|
||||
# Development (mit Hot Reload)
|
||||
docker compose exec laravel npm run dev
|
||||
|
||||
# Beispiel-Queries
|
||||
SELECT * FROM users;
|
||||
SELECT * FROM usage_logs ORDER BY timestamp DESC LIMIT 10;
|
||||
# Production Build
|
||||
docker compose exec laravel npm run build
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Entwicklung
|
||||
|
||||
### Laravel Development
|
||||
### Admin-Interface Features
|
||||
|
||||
```bash
|
||||
# In Laravel Container einloggen
|
||||
docker compose exec laravel bash
|
||||
Das Admin-Interface unter http://localhost:80 bietet:
|
||||
|
||||
# Routes anzeigen
|
||||
php artisan route:list
|
||||
1. **Dashboard**
|
||||
- Übersicht über Nutzungsstatistiken
|
||||
- Kosten-Trends (Chart.js)
|
||||
- Provider-Verteilung
|
||||
- Aktive Benutzer
|
||||
|
||||
# Model erstellen
|
||||
php artisan make:model MyModel -m
|
||||
2. **Gateway Users**
|
||||
- Benutzerverwaltung
|
||||
- API-Key Management
|
||||
- Pro-User Provider-Credentials
|
||||
|
||||
# Controller erstellen
|
||||
php artisan make:controller MyController --resource
|
||||
3. **API Keys**
|
||||
- Virtual Keys erstellen/löschen
|
||||
- Key-Testing
|
||||
- Nutzungsstatistiken
|
||||
|
||||
# Livewire Component erstellen
|
||||
php artisan make:livewire MyComponent
|
||||
```
|
||||
4. **Budgets**
|
||||
- Budget-Limits definieren
|
||||
- Reset-Zeiträume (täglich/wöchentlich/monatlich)
|
||||
- Benachrichtigungen
|
||||
|
||||
### Frontend Development
|
||||
5. **Usage Logs**
|
||||
- Request-Historie
|
||||
- Filter & Export (CSV)
|
||||
- Kosten-Analyse
|
||||
|
||||
```bash
|
||||
# NPM Dev Server (mit Hot Reload)
|
||||
docker compose exec laravel npm run dev
|
||||
6. **Model Pricing**
|
||||
- Preis-Konfiguration
|
||||
- Dynamische Model-Liste
|
||||
- Kosten-Rechner
|
||||
|
||||
# Production Build
|
||||
docker compose exec laravel npm run build
|
||||
### LLM Provider Services
|
||||
|
||||
# Tailwind JIT Mode
|
||||
# → Läuft automatisch mit npm run dev
|
||||
```
|
||||
Das System unterstützt folgende Provider mit dynamischer Model-Discovery:
|
||||
|
||||
- **OpenAI**: GPT-3.5, GPT-4, GPT-4 Turbo
|
||||
- **Anthropic**: Claude 3 (Haiku, Sonnet, Opus)
|
||||
- **DeepSeek**: DeepSeek Chat Modelle
|
||||
- **Google Gemini**: Gemini Pro, Flash
|
||||
- **Mistral AI**: Mistral Large, Medium, Small
|
||||
|
||||
Alle Provider-Services befinden sich in `app/Services/LLM/`.
|
||||
|
||||
---
|
||||
|
||||
## 📝 Nächste Schritte
|
||||
## 🔐 Sicherheit
|
||||
|
||||
### 1. Models erstellen
|
||||
### Production Checklist
|
||||
|
||||
Folge dem Implementierungskonzept in `LARAVEL_IMPLEMENTATION.md`:
|
||||
Vor dem Production-Einsatz:
|
||||
|
||||
```bash
|
||||
docker compose exec laravel php artisan make:model GatewayUser
|
||||
docker compose exec laravel php artisan make:model ApiKey
|
||||
docker compose exec laravel php artisan make:model UsageLog
|
||||
docker compose exec laravel php artisan make:model Budget
|
||||
docker compose exec laravel php artisan make:model ModelPricing
|
||||
```
|
||||
1. ✅ `.env` Konfiguration:
|
||||
```env
|
||||
APP_ENV=production
|
||||
APP_DEBUG=false
|
||||
APP_KEY=... (sicher generieren!)
|
||||
```
|
||||
|
||||
### 2. Controllers implementieren
|
||||
2. ✅ Admin-Passwort ändern
|
||||
|
||||
```bash
|
||||
docker compose exec laravel php artisan make:controller DashboardController
|
||||
docker compose exec laravel php artisan make:controller GatewayUserController --resource
|
||||
```
|
||||
3. ✅ MariaDB Root-Passwort ändern
|
||||
|
||||
### 3. Views erstellen
|
||||
4. ✅ phpMyAdmin deaktivieren oder absichern
|
||||
|
||||
Die Views werden in `laravel-app/resources/views/` erstellt.
|
||||
5. ✅ SSL/TLS einrichten
|
||||
|
||||
Struktur:
|
||||
```
|
||||
resources/views/
|
||||
├── layouts/
|
||||
│ ├── app.blade.php
|
||||
│ └── navigation.blade.php
|
||||
├── dashboard.blade.php
|
||||
├── gateway-users/
|
||||
│ ├── index.blade.php
|
||||
│ ├── show.blade.php
|
||||
│ └── ...
|
||||
└── ...
|
||||
```
|
||||
6. ✅ Laravel Caches aktivieren:
|
||||
```bash
|
||||
php artisan config:cache
|
||||
php artisan route:cache
|
||||
php artisan view:cache
|
||||
php artisan optimize
|
||||
```
|
||||
|
||||
### API-Key Verschlüsselung
|
||||
|
||||
Provider API-Keys werden verschlüsselt in der Datenbank gespeichert:
|
||||
- Verwendung von Laravel's Encryption
|
||||
- Basiert auf APP_KEY
|
||||
- Automatische Ver-/Entschlüsselung
|
||||
|
||||
---
|
||||
|
||||
## 📊 Monitoring & Analytics
|
||||
|
||||
### Dashboard Metriken
|
||||
|
||||
- Gesamte Requests
|
||||
- Token-Nutzung (Input/Output)
|
||||
- Gesamtkosten
|
||||
- Requests pro Provider
|
||||
- Top-Nutzer
|
||||
- Kosten-Trends (Chart.js Visualisierung)
|
||||
|
||||
### Export Funktionen
|
||||
|
||||
Usage Logs können als CSV exportiert werden mit:
|
||||
- Zeitraum-Filter
|
||||
- Provider-Filter
|
||||
- Benutzer-Filter
|
||||
- Kosten-Zusammenfassung
|
||||
|
||||
---
|
||||
|
||||
@@ -259,12 +292,23 @@ resources/views/
|
||||
```bash
|
||||
# Logs prüfen
|
||||
docker compose logs laravel
|
||||
docker compose logs mariadb
|
||||
|
||||
# Container neu bauen
|
||||
docker compose down
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
### Datenbank Connection Fehler
|
||||
|
||||
```bash
|
||||
# MariaDB Status prüfen
|
||||
docker compose ps mariadb
|
||||
|
||||
# Connection testen
|
||||
docker compose exec laravel php artisan migrate:status
|
||||
```
|
||||
|
||||
### Permissions Fehler
|
||||
|
||||
```bash
|
||||
@@ -272,25 +316,6 @@ docker compose up -d --build
|
||||
docker compose exec laravel chmod -R 777 storage bootstrap/cache
|
||||
```
|
||||
|
||||
### Port bereits belegt
|
||||
|
||||
Ports in `docker-compose.yml` anpassen:
|
||||
```yaml
|
||||
laravel:
|
||||
ports:
|
||||
- "8001:80" # Statt 80:80
|
||||
```
|
||||
|
||||
### Datenbank Connection Fehler
|
||||
|
||||
```bash
|
||||
# Prüfe ob PostgreSQL läuft
|
||||
docker compose ps postgres
|
||||
|
||||
# Teste Connection
|
||||
docker compose exec laravel php artisan migrate:status
|
||||
```
|
||||
|
||||
### Assets werden nicht geladen
|
||||
|
||||
```bash
|
||||
@@ -303,69 +328,50 @@ docker compose exec laravel php artisan storage:link
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Sicherheit
|
||||
## 📚 Technologie-Stack
|
||||
|
||||
### Production Checklist
|
||||
|
||||
Vor dem Production-Deployment:
|
||||
|
||||
1. ✅ `.env` Werte ändern:
|
||||
```
|
||||
APP_ENV=production
|
||||
APP_DEBUG=false
|
||||
APP_KEY=... (neu generieren!)
|
||||
```
|
||||
|
||||
2. ✅ Starkes Admin-Passwort setzen
|
||||
|
||||
3. ✅ PostgreSQL Passwort ändern
|
||||
|
||||
4. ✅ Adminer auf localhost beschränken oder deaktivieren
|
||||
|
||||
5. ✅ SSL/TLS einrichten (Let's Encrypt)
|
||||
|
||||
6. ✅ Laravel Caches aktivieren:
|
||||
```bash
|
||||
php artisan config:cache
|
||||
php artisan route:cache
|
||||
php artisan view:cache
|
||||
```
|
||||
- **Framework**: Laravel 11.x
|
||||
- **Frontend**: Livewire 3.x + Tailwind CSS 3.x
|
||||
- **Datenbank**: MariaDB 11.4
|
||||
- **Webserver**: Nginx + PHP-FPM 8.3
|
||||
- **Charts**: Chart.js
|
||||
- **Container**: Docker + Docker Compose
|
||||
|
||||
---
|
||||
|
||||
## 📚 Dokumentation
|
||||
## 🔗 Nützliche Links
|
||||
|
||||
- **Implementierungskonzept**: `LARAVEL_IMPLEMENTATION.md`
|
||||
- **Any-LLM Gateway**: https://github.com/mozilla-ai/any-llm
|
||||
- **Laravel Docs**: https://laravel.com/docs
|
||||
- **Livewire Docs**: https://livewire.laravel.com
|
||||
- **Tailwind CSS**: https://tailwindcss.com
|
||||
- **Chart.js**: https://www.chartjs.org
|
||||
|
||||
---
|
||||
|
||||
## 🆘 Support
|
||||
## 📝 System-Status
|
||||
|
||||
Bei Fragen oder Problemen:
|
||||
### ✅ Implementiert
|
||||
|
||||
1. Logs prüfen: `docker compose logs -f`
|
||||
2. Container Status: `docker compose ps`
|
||||
3. Implementierungskonzept lesen: `LARAVEL_IMPLEMENTATION.md`
|
||||
- [x] Docker-Setup (Laravel + MariaDB + phpMyAdmin)
|
||||
- [x] Admin-Authentifizierung
|
||||
- [x] Gateway User Management
|
||||
- [x] API Key Management mit Testing
|
||||
- [x] Budget-System mit Limits
|
||||
- [x] Usage Logs mit CSV Export
|
||||
- [x] Model Pricing Management
|
||||
- [x] Dashboard mit Statistiken
|
||||
- [x] Multi-Provider Support (5 Provider)
|
||||
- [x] Verschlüsselte Credential-Speicherung
|
||||
- [x] Dynamische Model-Discovery
|
||||
|
||||
### 🚧 Geplant
|
||||
|
||||
- [ ] API Gateway Endpoints (OpenAI-kompatibel)
|
||||
- [ ] Rate Limiting Implementation
|
||||
- [ ] Email-Benachrichtigungen
|
||||
- [ ] Erweiterte Analytics
|
||||
- [ ] API-Dokumentation
|
||||
|
||||
---
|
||||
|
||||
## 📋 Checkliste
|
||||
|
||||
- [ ] Setup Script ausgeführt
|
||||
- [ ] Laravel läuft auf http://localhost:80
|
||||
- [ ] Admin-Login funktioniert
|
||||
- [ ] Adminer erreichbar (http://localhost:8081)
|
||||
- [ ] Gateway API funktioniert (http://localhost:8000)
|
||||
- [ ] Models erstellt (siehe Implementierungskonzept)
|
||||
- [ ] Controllers implementiert
|
||||
- [ ] Dashboard Views erstellt
|
||||
- [ ] Statistiken funktionieren
|
||||
- [ ] Production-ready gemacht
|
||||
|
||||
---
|
||||
|
||||
**Viel Erfolg mit der Entwicklung! 🚀**
|
||||
**Entwickelt von Wilfried Trinkl | Laravel LLM Gateway** 🚀
|
||||
Reference in New Issue
Block a user