Here are all the file contents you requested:
1. /home/gperry/Documents/GitHub/KNIRV/KNIRV_NETWORK/packages/KNIRVSERVER/backend/internal/web/api_router.go
371 lines — The unified API router (APIRouter) using gorilla/mux. Key structure:
- Routes all under
/api/v1/ prefix
- Sub-routers: DVE, Plugin, Agent, Payments, KNIRVSHELL, Onboarding, Cognitive Engine, Knowledge Base
- Optional auth middleware applied to most sub-routers
- Backward-compatibility redirects from old API paths (e.g.,
/api/dve-nodes/ → /api/v1/dve/nodes/, /api/fabric-management/ → /api/v1/knowledge-base/)
- Browser DVE WebSocket endpoint at
/api/dve/browser/ws
- Health endpoint at
/api/v1/health and info endpoint at /api/v1/info
2. /home/gperry/Documents/GitHub/KNIRV/KNIRV_NETWORK/packages/KNIRVSERVER/backend/internal/storage/memory_store.go
149 lines — MemoryStore unifying three backends:
- Markdown (
mdstorage.MarkdownStorageDriver) — primary document store
- GraphRAG (
memory.GraphRAGInterface) — semantic index (auto-sync on save)
- Ontology (
memory.OntologyManager) — entity/relation knowledge graph (upserts on ERROR/SOLUTION documents)
Provides SaveDocument, LoadDocument, ListDocuments, SyncAll, and Stats.
3. Glob results — Storage files
Found 9 files under internal/storage/:
| File | Description |
|---|
internal/storage/memory_store.go | Unified memory store (above) |
internal/storage/mdstorage/driver.go | Markdown storage driver |
internal/storage/jsonstorage/jsonstorage.go | JSON storage driver |
internal/storage/pqc/encryption.go | PQC encryption manager |
internal/storage/pqc/kyber.go | Kyber KEM implementation |
internal/storage/pqc/dilithium.go | Dilithium signature implementation |
internal/storage/pqc/keys.go | PQC key management |
internal/storage/pqc/solution_node_validator.go | Solution node validator |
internal/storage/pqc/key_rotation.go | Key rotation manager |
4. /home/gperry/Documents/GitHub/KNIRV/KNIRV_NETWORK/packages/KNIRVSERVER/backend/cmd/backend_server/main.go
3181 lines — The monolithic entry point. Key sections:
Server struct (line 102-202): Holds every service — DVE manager, P2P, eBPF, blockchain chains, cognitive engine, active memory, ICME, hasher, arena, oracle, gateway, graph, guardrails, etc.
loadSecretsFromKeyFile (line 422-488): Loads root.key with ORACLE_KEY_PASSWORD env or interactive password prompt. Extracts JWT, API keys (Gemini, DeepSeek, Cerebras), TLS certs, SMTP, Cloudflare tokens.
NewServer (line 603-1649): Massive constructor that initializes every service in dependency order — DB → eBPF → P2P → DVE → plugins → data engine → inference → TEE → containers → DNS → PQC/markdown → Cognitive → KNIRVAGENT → GraphRAG → Anchoring → ICME → Guardrails → Hasher → Arena → Oracle → Rollup. Calls server.setupRoutes().
setupRoutes (line 1779-2241): Registers ~30 handler groups to the mux router, including the unified APIRouter, auth routes, DVE CRUD, WebSocket, workflow, guardrails, secrets, anchoring, validation, TEE, system health, cognitive engine, active memory, ICME, KNIRVSHELL, badges, hasher bridge, onboarding, KNIRVARENA proxy, rollup, and KNIRVGRAPH routes.
Start (line 2361-2719): Starts all embedded subprocesses (graph, chain, gateway, hasher, arena), services, and the HTTP server (TCP or Unix socket with CORS middleware).
Stop (line 2722-2978): Graceful reverse-order shutdown of all services.
run/main (line 3061-3181): Entry point — loads config, loads root.key secrets, creates server, starts, waits for SIGINT/SIGTERM, shuts down.
5. /home/gperry/Documents/GitHub/KNIRV/KNIRV_NETWORK/packages/KNIRVSERVER/backend/go.mod
228 lines — Go 1.25.7 module with dependencies including:
- Routing/HTTP:
gorilla/mux, gin-gonic/gin, prometheus/client_golang
- P2P/Networking:
libp2p, go-libp2p-kad-dht, go-libp2p-pubsub, webrtc, turn
- Database:
tidwall/buntdb, apache/arrow/go/v14
- Security:
cloudflare/circl (PQC), golang-jwt/jwt, seccomp, cilium/ebpf
- LLM/AI:
guiperry/gollm_cerebras, guiperry/text-embedder, pkoukk/tiktoken-go
- Internal packages (replace directives):
KNIRVGATEWAY, KNIRVORACLE, KNIRVSHELL, KNIRVCHAIN, KNIRVGRAPH, knirvhasher, knirvarena, backend_server/pkg/knirvagent — all resolved to ../pkg/ paths
- Kafka, Wazero (WASM runtime), gRPC, Blake3, zap logging, viper config