From bf1b1cdd824ce78c4a0a75bccf1fc718f784e1d3 Mon Sep 17 00:00:00 2001 From: m Date: Mon, 30 Mar 2026 14:01:19 +0200 Subject: [PATCH] refactor: remove YouPCDatabaseURL, use same DB connection for case finder Now that KanzlAI is on the youpc.org Supabase instance, the separate YouPCDatabaseURL connection is unnecessary. The main database connection can query mlex.* tables directly since they're on the same Postgres. - Remove YouPCDatabaseURL from config - Remove separate sqlx.Connect block in main.go - Pass main database handle as youpcDB parameter to router - Update CLAUDE.md: mgmt schema in youpc.org (was kanzlai in flexsiebels) --- CLAUDE.md | 2 +- backend/cmd/server/main.go | 18 +----------------- backend/internal/config/config.go | 2 -- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 2acecb7..66dde0f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -18,7 +18,7 @@ frontend/ Next.js 15 (TypeScript, Tailwind CSS, App Router) - **Frontend:** Next.js 15 with TypeScript, Tailwind CSS v4, App Router, Bun - **Backend:** Go (standard library HTTP server) -- **Database:** Supabase (PostgreSQL) — `kanzlai` schema in flexsiebels instance +- **Database:** Supabase (PostgreSQL) — `mgmt` schema in youpc.org instance - **Deploy:** Dokploy on mLake, domain: kanzlai.msbls.de ## Development diff --git a/backend/cmd/server/main.go b/backend/cmd/server/main.go index fbe14bd..8b4996f 100644 --- a/backend/cmd/server/main.go +++ b/backend/cmd/server/main.go @@ -5,7 +5,6 @@ import ( "net/http" "os" - "github.com/jmoiron/sqlx" _ "github.com/lib/pq" "mgit.msbls.de/m/KanzlAI-mGMT/internal/auth" @@ -34,21 +33,6 @@ func main() { authMW := auth.NewMiddleware(cfg.SupabaseJWTSecret, database) - // Optional: connect to youpc.org database for similar case finder - var youpcDB *sqlx.DB - if cfg.YouPCDatabaseURL != "" { - youpcDB, err = sqlx.Connect("postgres", cfg.YouPCDatabaseURL) - if err != nil { - slog.Warn("failed to connect to youpc.org database — similar case finder disabled", "error", err) - youpcDB = nil - } else { - youpcDB.SetMaxOpenConns(5) - youpcDB.SetMaxIdleConns(2) - defer youpcDB.Close() - slog.Info("connected to youpc.org database for similar case finder") - } - } - // Start CalDAV sync service calDAVSvc := services.NewCalDAVService(database) calDAVSvc.Start() @@ -59,7 +43,7 @@ func main() { notifSvc.Start() defer notifSvc.Stop() - handler := router.New(database, authMW, cfg, calDAVSvc, notifSvc, youpcDB) + handler := router.New(database, authMW, cfg, calDAVSvc, notifSvc, database) slog.Info("starting KanzlAI API server", "port", cfg.Port) if err := http.ListenAndServe(":"+cfg.Port, handler); err != nil { diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go index ad8500f..620a7f4 100644 --- a/backend/internal/config/config.go +++ b/backend/internal/config/config.go @@ -14,7 +14,6 @@ type Config struct { SupabaseJWTSecret string AnthropicAPIKey string FrontendOrigin string - YouPCDatabaseURL string // read-only connection to youpc.org Supabase for similar case finder } func Load() (*Config, error) { @@ -27,7 +26,6 @@ func Load() (*Config, error) { SupabaseJWTSecret: os.Getenv("SUPABASE_JWT_SECRET"), AnthropicAPIKey: os.Getenv("ANTHROPIC_API_KEY"), FrontendOrigin: getEnv("FRONTEND_ORIGIN", "https://kanzlai.msbls.de"), - YouPCDatabaseURL: os.Getenv("YOUPC_DATABASE_URL"), } if cfg.DatabaseURL == "" {