# PROJECT KNOWLEDGE BASE **Generated:** 2026-05-22 **Commit:** `92051d5` **Branch:** `main` ## OVERVIEW NexusGuard SD-WAN Suite — Enterprise Zero-Trust SD-WAN with WireGuard tunneling, centralized IPAM, and real-time nftables network isolation. Monorepo with 3 git submodules: Go backend (Gin), Vue 3 dashboard, Go device agent. ## STRUCTURE ``` ./ ├── apps/ │ ├── server-core/ # Go/Gin API backend (submodule) │ ├── dashboard-ui/ # Vue 3 + Vite frontend (submodule) │ └── device-agent/ # Go stealth daemon + system tray (submodule) ├── docker-compose.yml # Production orchestration ├── docker-compose.dev.yml # Dev (air hot-reload) ├── Makefile # up/down/dev/migrate/reset-db ├── setup.sh # First-run: generate .env + random keys ├── update.sh # Docker update: pull/build/migrate ├── nexusguard-install.sh # Native install (systemd + nginx) ├── nexusguard-uninstall.sh # Native uninstall ├── .env.example # DB/JWT/SALT/VITE config template ├── .gitmodules # 3 submodules → git.datadunia.com └── .opencode/ # IDE agent config (tooling, not project code) ``` **CRITICAL**: `apps/*` are **git submodules** — clone with `--recurse-submodules`. ## WHERE TO LOOK | Task | Location | Notes | |------|----------|-------| | API handlers | `apps/server-core/api/` | 17 files: auth, devices, peers, rules, share, provisioning, servers, wg | | Backend core | `apps/server-core/internal/` | auth, config, firewall, heartbeat, ipam, models, wgmanager | | Dev migration | `apps/server-core/main_dev.go` | GORM AutoMigrate (build tag `dev`) | | Firewall rules | `apps/server-core/internal/firewall/` | nftables Linux rules | | Dashboard views | `apps/dashboard-ui/src/views/` | Vue SFC pages | | Dashboard API client | `apps/dashboard-ui/src/api/` | Axios API modules | | Dashboard stores | `apps/dashboard-ui/src/stores/` | Pinia state stores | | Agent client | `apps/device-agent/internal/client/` | Provisioning + heartbeat | | Agent tunnel | `apps/device-agent/internal/tunnel/` | Memory-injected WireGuard | | Shared crypto | `apps/*/shared/crypto/encryptor.go` | AES-256-GCM (duplicated identical) | | CI workflows | `apps/*/.gitea/workflows/build.yml` | Gitea Actions per submodule | | Build config | `apps/dashboard-ui/vite.config.ts` | Vite 8 + Vue + TailwindCSS v4 | | Source of truth | `apps/server-core/docs/` | API_SPEC, KEY_ROTATION, PEER_DISCOVERY | | Plan guardrails | `.sisyphus/plans/` | Anti-patterns, "Must NOT do" rules | ## CODE MAP | Symbol | Type | Location | Role | |--------|------|----------|------| | `main()` (server-core) | func | `apps/server-core/main.go` | Entry: CLI flags + Gin init | | `main()` (device-agent) | func | `apps/device-agent/main.go` | Entry: systray + agent daemon lifecycle | | `onReady()` / `onExit()` | func | `apps/device-agent/main.go` | System tray setup and cleanup | | `startAgent()` / `stopAgent()` | func | `apps/device-agent/main.go` | Agent connect/disconnect lifecycle | | `generateIcon()` | func | `apps/device-agent/icon.go` | 16x16 shield icon for tray | | `config.Load()` | func | `apps/server-core/internal/config/` | Env-based config loader | | `config.LoadConfFile()` | func | `apps/server-core/internal/config/config_loader.go` | Config file parser (.env / nexusguard.conf) | | `auth.Init()` | func | `apps/server-core/internal/auth/` | JWT sign/verify init | | `firewall.InitNetwork()` | func | `apps/server-core/internal/firewall/` | nftables table/set creation | | `ipam.AllocateIP()` | func | `apps/server-core/internal/ipam/` | IP pool allocation from CIDR | | `wgmanager.SetConfig()` | func | `apps/server-core/internal/wgmanager/` | WireGuard config push | | `models.AutoMigrate()` | func | `apps/server-core/internal/models/` | GORM schema migration | | `encrypt()` / `decrypt()` | func | `apps/*/shared/crypto/encryptor.go` | AES-256-GCM (identical) | ## CONVENTIONS - **Go**: Standard layout (`main.go` in root, `internal/`, `api/`) - **Vue 3**: Composition API + `