- Any-LLM Gateway setup with Docker Compose - Laravel 11 admin interface with Livewire - Dashboard with usage statistics and charts - Gateway Users management with budget tracking - API Keys management with revocation - Budget templates with assignment - Usage Logs with filtering and CSV export - Model Pricing management with calculator - PostgreSQL database integration - Complete authentication system for admins
372 lines
7.5 KiB
Markdown
372 lines
7.5 KiB
Markdown
# Any-LLM Gateway + Laravel Admin
|
|
|
|
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)
|
|
|
|
---
|
|
|
|
## 🚀 Quick Start
|
|
|
|
### Voraussetzungen
|
|
- Docker & Docker Compose installiert
|
|
- Ports 80, 8000, 8080, 8081 verfügbar
|
|
|
|
### Installation
|
|
|
|
```bash
|
|
cd /opt/any-llm
|
|
./setup-laravel.sh
|
|
```
|
|
|
|
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**
|
|
|
|
---
|
|
|
|
## 🌐 URLs & Zugangsdaten
|
|
|
|
### Services
|
|
|
|
| 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 |
|
|
|
|
### Login-Daten
|
|
|
|
#### Laravel Admin
|
|
```
|
|
Email: admin@example.com
|
|
Password: password123
|
|
```
|
|
|
|
#### Adminer (PostgreSQL)
|
|
```
|
|
System: PostgreSQL
|
|
Server: postgres
|
|
Username: gateway
|
|
Password: gateway
|
|
Database: gateway
|
|
```
|
|
|
|
---
|
|
|
|
## 📁 Projekt-Struktur
|
|
|
|
```
|
|
/opt/any-llm/
|
|
├── config.yml # Gateway Konfiguration
|
|
├── docker-compose.yml # Docker Services
|
|
├── setup-laravel.sh # Setup Script
|
|
│
|
|
├── laravel/ # Laravel Docker Config
|
|
│ ├── Dockerfile
|
|
│ ├── nginx.conf
|
|
│ ├── supervisord.conf
|
|
│ └── php.ini
|
|
│
|
|
├── laravel-app/ # Laravel Projekt (wird generiert)
|
|
│ ├── app/
|
|
│ ├── database/
|
|
│ ├── resources/
|
|
│ └── ...
|
|
│
|
|
├── web/ # Gateway Tester
|
|
│ ├── index.html
|
|
│ └── default.conf
|
|
│
|
|
└── LARAVEL_IMPLEMENTATION.md # Detailliertes Implementierungskonzept
|
|
```
|
|
|
|
---
|
|
|
|
## 🔧 Docker Commands
|
|
|
|
### Container Management
|
|
|
|
```bash
|
|
# Alle Container starten
|
|
docker compose up -d
|
|
|
|
# Alle 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
|
|
docker compose exec laravel bash
|
|
docker compose exec postgres psql -U gateway -d gateway
|
|
```
|
|
|
|
### Laravel Commands (im Container)
|
|
|
|
```bash
|
|
# Artisan Commands
|
|
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
|
|
|
|
# NPM
|
|
docker compose exec laravel npm install
|
|
docker compose exec laravel npm run dev
|
|
docker compose exec laravel npm run build
|
|
|
|
# Tinker (Laravel REPL)
|
|
docker compose exec laravel php artisan tinker
|
|
```
|
|
|
|
---
|
|
|
|
## 🗄️ 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
|
|
|
|
# Beispiel-Queries
|
|
SELECT * FROM users;
|
|
SELECT * FROM usage_logs ORDER BY timestamp DESC LIMIT 10;
|
|
```
|
|
|
|
---
|
|
|
|
## 🛠️ Entwicklung
|
|
|
|
### Laravel Development
|
|
|
|
```bash
|
|
# In Laravel Container einloggen
|
|
docker compose exec laravel bash
|
|
|
|
# Routes anzeigen
|
|
php artisan route:list
|
|
|
|
# Model erstellen
|
|
php artisan make:model MyModel -m
|
|
|
|
# Controller erstellen
|
|
php artisan make:controller MyController --resource
|
|
|
|
# Livewire Component erstellen
|
|
php artisan make:livewire MyComponent
|
|
```
|
|
|
|
### Frontend Development
|
|
|
|
```bash
|
|
# NPM Dev Server (mit Hot Reload)
|
|
docker compose exec laravel npm run dev
|
|
|
|
# Production Build
|
|
docker compose exec laravel npm run build
|
|
|
|
# Tailwind JIT Mode
|
|
# → Läuft automatisch mit npm run dev
|
|
```
|
|
|
|
---
|
|
|
|
## 📝 Nächste Schritte
|
|
|
|
### 1. Models erstellen
|
|
|
|
Folge dem Implementierungskonzept in `LARAVEL_IMPLEMENTATION.md`:
|
|
|
|
```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
|
|
```
|
|
|
|
### 2. Controllers implementieren
|
|
|
|
```bash
|
|
docker compose exec laravel php artisan make:controller DashboardController
|
|
docker compose exec laravel php artisan make:controller GatewayUserController --resource
|
|
```
|
|
|
|
### 3. Views erstellen
|
|
|
|
Die Views werden in `laravel-app/resources/views/` erstellt.
|
|
|
|
Struktur:
|
|
```
|
|
resources/views/
|
|
├── layouts/
|
|
│ ├── app.blade.php
|
|
│ └── navigation.blade.php
|
|
├── dashboard.blade.php
|
|
├── gateway-users/
|
|
│ ├── index.blade.php
|
|
│ ├── show.blade.php
|
|
│ └── ...
|
|
└── ...
|
|
```
|
|
|
|
---
|
|
|
|
## 🐛 Troubleshooting
|
|
|
|
### Container startet nicht
|
|
|
|
```bash
|
|
# Logs prüfen
|
|
docker compose logs laravel
|
|
|
|
# Container neu bauen
|
|
docker compose down
|
|
docker compose up -d --build
|
|
```
|
|
|
|
### Permissions Fehler
|
|
|
|
```bash
|
|
# Storage Permissions setzen
|
|
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
|
|
# Assets neu kompilieren
|
|
docker compose exec laravel npm run build
|
|
|
|
# Storage Link neu erstellen
|
|
docker compose exec laravel php artisan storage:link
|
|
```
|
|
|
|
---
|
|
|
|
## 🔐 Sicherheit
|
|
|
|
### 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
|
|
```
|
|
|
|
---
|
|
|
|
## 📚 Dokumentation
|
|
|
|
- **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
|
|
|
|
---
|
|
|
|
## 🆘 Support
|
|
|
|
Bei Fragen oder Problemen:
|
|
|
|
1. Logs prüfen: `docker compose logs -f`
|
|
2. Container Status: `docker compose ps`
|
|
3. Implementierungskonzept lesen: `LARAVEL_IMPLEMENTATION.md`
|
|
|
|
---
|
|
|
|
## 📋 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! 🚀**
|