Initial commit: LlamaLink Go rewrite

Complete rewrite from Python/FastAPI to Go/Gin:
- Go backend: auth (API keys + bcrypt), llama.cpp subprocess manager,
  hot-swap multi-model, rate limiting, quota system, webhooks
- Vue 3 SPA admin panel (src/) with Tailwind CSS
- Deployment: Docker multi-stage, docker-compose, nginx, systemd
- GORM/SQLite models: ApiKey, Model, UsageLog, Quota, Webhook
- REST API: /api/v1/admin/* (keys, models, chat, usage, health)
- Embedded frontend via go:embed (build output at web/dist/)

Removed legacy Python artifacts (app/, tests/, pyproject.toml, etc.)
This commit is contained in:
2026-07-30 10:58:55 -04:00
commit 4c9ed3c24b
52 changed files with 5105 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
package db
import (
"log/slog"
"golang.org/x/crypto/bcrypt"
"github.com/google/uuid"
"gorm.io/gorm"
)
func SeedAdminKey(db *gorm.DB, adminToken string) error {
var count int64
db.Model(&ApiKey{}).Count(&count)
if count > 0 {
slog.Info("admin key already exists, skipping seed")
return nil
}
hash, err := bcrypt.GenerateFromPassword([]byte(adminToken), bcrypt.DefaultCost)
if err != nil {
return err
}
admin := ApiKey{
ID: uuid.New(),
Name: "admin",
KeyHash: string(hash),
KeyPrefix: "admin-",
Scopes: StringArray{"chat", "models", "usage", "admin"},
IsActive: true,
IsAdmin: true,
}
if err := db.Create(&admin).Error; err != nil {
return err
}
slog.Info("admin key seeded", "prefix", admin.KeyPrefix)
slog.Warn("ADMIN TOKEN: " + adminToken + " (save this!)")
return nil
}