# NexusGuard SD-WAN — Phase 4.5: Multi-Node Architecture & Production Readiness **Goal**: Transform the system from a single-node mockup into a true Multi-Server (WGDashboard-style) architecture, and harden the database startup mechanisms for production environments. ## Task 4.5.1: Multi-Server Database & API - **Files**: `models.go`, `001_init.sql`, `api/servers.go`, `main.go` - **Actions**: - Add `WgServerID` foreign key to the `Device` model. - Implement full CRUD REST API for `WgServer` (`/api/v1/servers`) to allow Admin to register multiple public WireGuard nodes. ## Task 4.5.2: Provisioning API Multi-Node Fix - **Files**: `api/provisioning.go`, `api/provisioning_test.go` - **Actions**: - Remove the hardcoded `127.0.0.1:51820` fallback. - During provisioning, fetch the exact `WgServer` related to the device. - Return the true `Endpoint` and `PublicKey` of that specific node to the connecting agent. ## Task 4.5.3: Dashboard UI - Nodes Management - **Files**: `src/views/Servers.vue`, `src/views/Devices.vue`, `src/api/servers.ts`, `src/App.vue` - **Actions**: - Build the "Nodes" page to manage external WireGuard servers. - Update the "Add Device" form to include a required dropdown where the Admin selects which Node the device will connect to. - Update the Sidebar to reflect the new navigation. ## Task 4.5.4: Production Readiness (Install Detection) - **Files**: `main.go` - **Actions**: - Add logic to verify if the DB is empty on startup. - Add `-migrate-prod` flag that uses the `goose` library to apply `001_init.sql` automatically in production without needing AutoMigrate.