feat(infra+ui): deploy script v2, schema push, SyncIndicator component

Deploy scripts for new architecture + floating sync status pill UI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-03-28 18:02:06 +01:00
parent 7dd8fa869f
commit 899f615f40
4 changed files with 302 additions and 0 deletions

View file

@ -0,0 +1,114 @@
<!--
SyncIndicator — Shows sync status as a small floating pill.
Displays:
- Nothing when synced (no visual clutter)
- "Offline" pill when disconnected
- "Syncing..." pill with spinner when actively syncing
- "X pending" pill when changes haven't synced yet
- "Synced ✓" briefly after sync completes (fades out)
Usage:
```svelte
<SyncIndicator status="synced" pendingCount={0} />
<SyncIndicator status="offline" pendingCount={3} />
<SyncIndicator status="syncing" pendingCount={1} />
```
-->
<script lang="ts">
type SyncStatus = 'idle' | 'synced' | 'syncing' | 'offline' | 'error';
let {
status = 'idle',
pendingCount = 0,
position = 'bottom-right',
}: {
status?: SyncStatus;
pendingCount?: number;
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
} = $props();
let showSynced = $state(false);
let prevStatus = $state<SyncStatus>('idle');
// Show "Synced ✓" briefly when transitioning from syncing → synced
$effect(() => {
if (
prevStatus === 'syncing' &&
(status === 'synced' || status === 'idle') &&
pendingCount === 0
) {
showSynced = true;
setTimeout(() => {
showSynced = false;
}, 2000);
}
prevStatus = status;
});
let visible = $derived(
status === 'offline' ||
status === 'syncing' ||
status === 'error' ||
pendingCount > 0 ||
showSynced
);
let positionClass = $derived(
{
'bottom-right': 'bottom-20 right-4',
'bottom-left': 'bottom-20 left-4',
'top-right': 'top-4 right-4',
'top-left': 'top-4 left-4',
}[position]
);
</script>
{#if visible}
{@const colorClass =
status === 'offline'
? 'bg-amber-500 text-amber-50'
: status === 'syncing'
? 'bg-blue-500 text-blue-50'
: status === 'error'
? 'bg-red-500 text-red-50'
: showSynced
? 'bg-green-500 text-green-50'
: 'bg-slate-700 text-slate-100'}
<div
class="fixed {positionClass} z-40 flex items-center gap-2 rounded-full px-3 py-1.5 text-xs font-medium shadow-lg backdrop-blur-sm transition-all duration-300 {colorClass}"
>
{#if status === 'offline'}
<svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M18.364 5.636a9 9 0 010 12.728M5.636 5.636a9 9 0 000 12.728"
/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 1l22 22" />
</svg>
<span>Offline{pendingCount > 0 ? ` · ${pendingCount} ausstehend` : ''}</span>
{:else if status === 'syncing'}
<svg class="h-3 w-3 animate-spin" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" />
<path
class="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
/>
</svg>
<span>Synchronisiere...</span>
{:else if status === 'error'}
<span>Sync-Fehler</span>
{:else if showSynced}
<svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg>
<span>Synchronisiert</span>
{:else if pendingCount > 0}
<span>{pendingCount} ausstehend</span>
{/if}
</div>
{/if}

View file

@ -203,6 +203,7 @@ export type {
// Immersive Mode
export { default as ImmersiveModeToggle } from './components/ImmersiveModeToggle.svelte';
export { default as DevBuildBadge } from './components/DevBuildBadge.svelte';
export { default as SyncIndicator } from './components/SyncIndicator.svelte';
// Toast & Global Error Handling
export {

148
scripts/mac-mini/deploy-v2.sh Executable file
View file

@ -0,0 +1,148 @@
#!/bin/bash
#
# Mac Mini Deployment Script v2 — New Architecture (Hono + Bun + Go)
#
# Deploys the complete ManaCore stack:
# - Infrastructure: PostgreSQL, Redis, MinIO, SearXNG
# - Core Services: mana-auth, mana-credits, mana-user, mana-subscriptions, mana-analytics
# - Go Services: mana-sync, mana-search, mana-crawler, mana-api-gateway, mana-notify, mana-matrix-bot
# - Python AI: mana-llm, mana-stt, mana-tts, mana-image-gen
# - App Frontends: 19 SvelteKit web apps
#
# Usage:
# ./scripts/mac-mini/deploy-v2.sh # Full deploy
# ./scripts/mac-mini/deploy-v2.sh --quick # Skip builds, just restart
# ./scripts/mac-mini/deploy-v2.sh --status # Just show status
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
COMPOSE_FILE="$PROJECT_ROOT/docker-compose.macmini.yml"
ENV_FILE="$PROJECT_ROOT/.env.macmini"
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m'
cd "$PROJECT_ROOT"
# ─── Helper Functions ────────────────────────────────────────
check_health() {
local name=$1
local url=$2
local status
status=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 3 "$url" 2>/dev/null || echo "000")
if [ "$status" = "200" ]; then
echo -e " ${GREEN}${NC} $name"
else
echo -e " ${RED}${NC} $name ($status)"
fi
}
# ─── Status Only ─────────────────────────────────────────────
if [ "$1" = "--status" ]; then
echo -e "${BLUE}=== ManaCore Service Status ===${NC}"
echo ""
echo "Core (Hono + Bun):"
check_health "mana-auth (3001)" "http://localhost:3001/health"
check_health "mana-credits (3061)" "http://localhost:3061/health"
check_health "mana-user (3062)" "http://localhost:3062/health"
check_health "mana-subscriptions (3063)" "http://localhost:3063/health"
check_health "mana-analytics (3064)" "http://localhost:3064/health"
echo ""
echo "Go Services:"
check_health "mana-sync (3050)" "http://localhost:3050/health"
check_health "mana-search (3021)" "http://localhost:3021/health"
check_health "mana-api-gateway (3060)" "http://localhost:3060/health"
echo ""
echo "Infrastructure:"
check_health "PostgreSQL (5432)" "http://localhost:5432" # Won't return 200, but tests connectivity
docker compose -f "$COMPOSE_FILE" ps --format "table {{.Name}}\t{{.Status}}" 2>/dev/null | head -30
exit 0
fi
# ─── Pre-flight Checks ──────────────────────────────────────
echo -e "${BLUE}=== ManaCore Deployment v2 ===${NC}"
echo ""
if [ ! -f "$ENV_FILE" ]; then
echo -e "${RED}Missing $ENV_FILE — copy from .env.macmini.example${NC}"
exit 1
fi
# ─── Pull Latest Code ───────────────────────────────────────
echo -e "${YELLOW}Pulling latest code...${NC}"
git pull --rebase origin main 2>/dev/null || echo "Pull skipped (not on main or no remote)"
echo ""
# ─── Create Databases ───────────────────────────────────────
echo -e "${YELLOW}Ensuring databases exist...${NC}"
# Start just postgres first
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" up -d postgres
sleep 5
# Create all needed databases
for db in mana_auth mana_credits mana_user mana_subscriptions mana_analytics mana_sync \
chat todo calendar contacts storage manadeck mukke nutriphi planta \
questions traces context citycorners photos presi skilltree; do
docker compose -f "$COMPOSE_FILE" exec -T postgres \
psql -U postgres -c "CREATE DATABASE $db;" 2>/dev/null || true
done
echo -e "${GREEN}Databases ready.${NC}"
echo ""
# ─── Build & Start Services ─────────────────────────────────
if [ "$1" != "--quick" ]; then
echo -e "${YELLOW}Building images...${NC}"
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" build --parallel 2>&1 | tail -5
echo ""
fi
echo -e "${YELLOW}Starting all services...${NC}"
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" up -d
echo ""
# ─── Wait & Health Check ────────────────────────────────────
echo -e "${YELLOW}Waiting for services to start (20s)...${NC}"
sleep 20
echo ""
echo -e "${BLUE}=== Health Checks ===${NC}"
echo ""
echo "Core (Hono + Bun):"
check_health "mana-auth" "http://localhost:3001/health"
check_health "mana-credits" "http://localhost:3061/health"
check_health "mana-user" "http://localhost:3062/health"
check_health "mana-subscriptions" "http://localhost:3063/health"
check_health "mana-analytics" "http://localhost:3064/health"
echo ""
echo "Go Services:"
check_health "mana-sync" "http://localhost:3050/health"
check_health "mana-search" "http://localhost:3021/health"
check_health "mana-api-gateway" "http://localhost:3060/health"
echo ""
echo "Infrastructure:"
check_health "PostgreSQL" "http://localhost:5432"
check_health "Redis" "http://localhost:6379"
check_health "MinIO" "http://localhost:9000/minio/health/live"
echo ""
echo -e "${GREEN}=== Deployment complete ===${NC}"
echo ""
echo "Useful commands:"
echo " ./scripts/mac-mini/deploy-v2.sh --status # Check health"
echo " docker compose -f docker-compose.macmini.yml logs -f mana-auth # View logs"
echo " docker compose -f docker-compose.macmini.yml restart mana-auth # Restart service"

View file

@ -0,0 +1,39 @@
#!/bin/bash
#
# Push Drizzle schemas to all service databases
# Run after databases are created (deploy-v2.sh handles this)
#
# Usage: ./scripts/mac-mini/push-schemas.sh
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
echo "=== Push Drizzle Schemas ==="
echo ""
push_schema() {
local name=$1
local dir=$2
echo -n " $name... "
if (cd "$PROJECT_ROOT/$dir" && bun run db:push 2>/dev/null); then
echo -e "${GREEN}OK${NC}"
else
echo -e "${RED}FAILED${NC}"
fi
}
echo "Core Services:"
push_schema "mana-auth" "services/mana-auth"
push_schema "mana-credits" "services/mana-credits"
push_schema "mana-user" "services/mana-user"
push_schema "mana-subscriptions" "services/mana-subscriptions"
push_schema "mana-analytics" "services/mana-analytics"
echo ""
echo "Done. mana-sync creates its schema automatically on startup."