core: initial Go module skeleton (config, db pool, tenant registry migration)

This commit is contained in:
sysops
2026-08-27 17:27:59 +02:00
parent 72261cc69f
commit c895a67c4b
7 changed files with 136 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
*.log
.env
+46
View File
@@ -0,0 +1,46 @@
# code Dev Log
## 2026-08-27 17:17 17:18 (0m)
**Beschreibung:** Claude Code Session
**Projekt:** nexarch
### Commits
Keine Commits in dieser Session.
### Geänderte Dateien
Keine Änderungen ermittelbar.
---
## 2026-08-27 17:21 17:21 (0m)
**Beschreibung:** Claude Code Session
**Projekt:** code
### Commits
Keine Commits in dieser Session.
### Geänderte Dateien
Keine Änderungen ermittelbar.
---
## 2026-08-27 17:22 17:22 (0m)
**Beschreibung:** Claude Code Session
**Projekt:** code
### Commits
Keine Commits in dieser Session.
### Geänderte Dateien
Keine Änderungen ermittelbar.
---
## 2026-08-27 17:23 17:25 (2m)
**Beschreibung:** Claude Code Session
**Projekt:** code
### Commits
Keine Commits in dieser Session.
### Geänderte Dateien
Keine Änderungen ermittelbar.
---
+33
View File
@@ -0,0 +1,33 @@
package main
import (
"context"
"log"
"net/http"
"gitea.perlbach24.de/scripte/nexarch/internal/config"
"gitea.perlbach24.de/scripte/nexarch/internal/db"
)
func main() {
cfg, err := config.Load()
if err != nil {
log.Fatalf("config: %v", err)
}
pool, err := db.Connect(context.Background(), cfg.RegistryDSN)
if err != nil {
log.Fatalf("db: %v", err)
}
defer pool.Close()
mux := http.NewServeMux()
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})
log.Printf("nexarch-core listening on %s", cfg.ListenAddr)
if err := http.ListenAndServe(cfg.ListenAddr, mux); err != nil {
log.Fatalf("server: %v", err)
}
}
+5
View File
@@ -0,0 +1,5 @@
module gitea.perlbach24.de/scripte/nexarch
go 1.22
require github.com/jackc/pgx/v5 v5.6.0
+29
View File
@@ -0,0 +1,29 @@
package config
import (
"fmt"
"os"
)
// Config holds startup configuration for the core module.
// RegistryDSN points at the control-plane registry DB (tenant list,
// connection info, superadmin accounts) — see nexarch-state.json
// multi_tenancy: Modell C (physisch getrennte DB pro Mandant).
type Config struct {
ListenAddr string
RegistryDSN string
}
func Load() (Config, error) {
dsn := os.Getenv("NEXARCH_REGISTRY_DSN")
if dsn == "" {
return Config{}, fmt.Errorf("NEXARCH_REGISTRY_DSN not set")
}
addr := os.Getenv("NEXARCH_LISTEN_ADDR")
if addr == "" {
addr = ":8080"
}
return Config{ListenAddr: addr, RegistryDSN: dsn}, nil
}
+11
View File
@@ -0,0 +1,11 @@
package db
import (
"context"
"github.com/jackc/pgx/v5/pgxpool"
)
func Connect(ctx context.Context, dsn string) (*pgxpool.Pool, error) {
return pgxpool.New(ctx, dsn)
}
+10
View File
@@ -0,0 +1,10 @@
-- Control-plane registry: tenant list + connection info (Modell C).
-- Core TEN-01 (siehe core-kanban).
CREATE TABLE tenants (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
slug TEXT NOT NULL UNIQUE,
name TEXT NOT NULL,
db_dsn TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'active',
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);