Skip to content

Phase 2: .NET 10 backend core#1

Open
amtocbot-droid wants to merge 1 commit intousers/krk/20260315_initial_setupfrom
users/krk/20260315_phase2_backend
Open

Phase 2: .NET 10 backend core#1
amtocbot-droid wants to merge 1 commit intousers/krk/20260315_initial_setupfrom
users/krk/20260315_phase2_backend

Conversation

@amtocbot-droid
Copy link
Owner

Summary

  • Complete ASP.NET Core 10 Web API with all entities, services, controllers, hubs, and background services
  • 12 EF Core entities with pgvector, AES-256 channel token encryption
  • DockerService (Docker.DotNet) for OpenClaw container lifecycle management
  • 3 SignalR hubs: InstanceHub, KanbanHub, ChatHub
  • Background services: MetricsPollingService (5s), ModelSwitchScheduler (1m), QueueRetryWorker
  • Keycloak JWT auth with role-based authorization

Test plan

  • docker compose up manager-db redis then dotnet run → API starts, migrations run
  • GET /api/health returns 200
  • Create instance → container appears in docker ps
  • SignalR connection from browser with Keycloak token succeeds

🤖 Generated with Claude Code

Complete ASP.NET Core 10 Web API for AmtocBots Manager:

Entities & Data:
- AppDbContext with pgvector extension, AES-256 value converter for
  channel token encryption at rest, all EF Core entity configurations
- Entities: BotInstance, ChannelConfig, ModelSwitchRule, TokenUsageRecord,
  KanbanBoard/Column/Card, ChatRoom/Member/Message, BotLearning, AppUser

Services:
- DockerService (Docker.DotNet): create/start/stop/remove OpenClaw
  containers, stats polling, config volume writing via busybox helper
- OpenClawClient: typed HTTP client for /hooks/wake and /hooks/agent
- OpenClawConfigBuilder: generates JSON5 config from DB state
- TokenTracker: upserts daily token usage records per instance+model
- ModelSwitchingService: evaluates threshold rules, switches model,
  rewrites config volume, restarts container
- RedisMessageQueueService: LPUSH/BRPOP main queue + sorted-set delay queue
- OllamaService: list models, pull, health, generate embeddings

Controllers & Endpoints:
- InstancesController: full CRUD + start/stop/restart/logs/config
- ModelsController: available models, token usage, switch rules CRUD
- KanbanController: boards/columns/cards + bot-webhook endpoint (API key auth)
- ChatController: rooms, paginated messages, bot-message endpoint
- WebhookController: receives token-usage and event callbacks from OpenClaw
- ChannelEndpoints: GET/PUT channel configs, WhatsApp QR proxy
- OllamaEndpoints: list/pull/status
- HealthEndpoints: /api/health

SignalR Hubs: InstanceHub, KanbanHub, ChatHub

Background Services:
- MetricsPollingService: Docker stats → InstanceHub every 5s
- ModelSwitchScheduler: NCrontab + threshold evaluation every 1m
- QueueRetryWorker: Redis queue retry with exponential backoff

Program.cs: full DI registration, Keycloak JWT auth (role claims from
realm_access.roles), CORS, SignalR, auto-migration on startup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant