{
  "schema": "codegraph-codewiki-agent-context/v1",
  "generatedAt": "2026-07-06T02:01:01.851Z",
  "repo": {
    "name": "nofx",
    "title": "nofx CodeGraph + CodeWiki 交互式参考文档",
    "path": "<LOCAL_PATH>",
    "language": "zh-CN",
    "codewikiRepoPath": "<LOCAL_PATH>"
  },
  "metrics": {
    "docs": 8,
    "modules": 8,
    "sourceRefs": 31,
    "codewikiComponents": 339,
    "codewikiLeafNodes": 116,
    "codewikiMaxDepth": 2,
    "diagrams": 7
  },
  "maturity": "mature",
  "artifactProfile": {
    "builder": "nofx-enhanced-builder",
    "status": "mature",
    "qualityTier": "mature",
    "genericFallback": false,
    "capabilities": {
      "repoSpecificRuntimeExtraction": true,
      "apiModelCatalogs": true,
      "focusedArchitectureDiagrams": true,
      "referenceProjectPublishing": true
    }
  },
  "recommendedReadOrder": [
    {
      "path": "overview.md",
      "purpose": "CodeWiki overview and source reference baseline."
    },
    {
      "path": "interactive/index.html",
      "purpose": "Primary visual navigation and search surface."
    },
    {
      "path": "runtime_orchestration.md",
      "purpose": "Startup, launch, manager, and runtime lifecycle."
    },
    {
      "path": "api_surface.md",
      "purpose": "Gin API and route registry orientation."
    },
    {
      "path": "trading_engine.md",
      "purpose": "AI trader decision loop and execution path."
    },
    {
      "path": "knowledge_pack/architecture_map.md",
      "purpose": "Agent-readable layer and relationship graph."
    },
    {
      "path": "knowledge_pack/api_catalog.md",
      "purpose": "Normalized entry surface for API/UI/runtime investigation."
    },
    {
      "path": "knowledge_pack/model_catalog.md",
      "purpose": "Persistence and runtime contracts."
    },
    {
      "path": "diagrams/index.html",
      "purpose": "Focused architecture, flow, data, state, contract, security, and entrypoint diagrams."
    }
  ],
  "usage": {
    "readOrder": [
      {
        "path": "overview.md",
        "purpose": "CodeWiki overview and source reference baseline."
      },
      {
        "path": "interactive/index.html",
        "purpose": "Primary visual navigation and search surface."
      },
      {
        "path": "runtime_orchestration.md",
        "purpose": "Startup, launch, manager, and runtime lifecycle."
      },
      {
        "path": "api_surface.md",
        "purpose": "Gin API and route registry orientation."
      },
      {
        "path": "trading_engine.md",
        "purpose": "AI trader decision loop and execution path."
      },
      {
        "path": "knowledge_pack/architecture_map.md",
        "purpose": "Agent-readable layer and relationship graph."
      },
      {
        "path": "knowledge_pack/api_catalog.md",
        "purpose": "Normalized entry surface for API/UI/runtime investigation."
      },
      {
        "path": "knowledge_pack/model_catalog.md",
        "purpose": "Persistence and runtime contracts."
      },
      {
        "path": "diagrams/index.html",
        "purpose": "Focused architecture, flow, data, state, contract, security, and entrypoint diagrams."
      }
    ]
  },
  "modules": [
    {
      "id": "bootstrap",
      "name": "Process bootstrap and local recovery CLI",
      "path": "main.go",
      "summary": "Loads config, initializes encryption and storage, restores trader runtime state, starts the Gin API server, and handles graceful shutdown. The same binary exposes local-only recovery subcommands in cli.go.",
      "docs": [
        "overview.md",
        "runtime_orchestration.md"
      ],
      "source": [
        {
          "path": "main.go",
          "line": 1
        },
        {
          "path": "cli.go",
          "line": 1
        }
      ]
    },
    {
      "id": "api",
      "name": "Gin HTTP API and route registry",
      "path": "api",
      "summary": "Owns /api routes for auth, trader lifecycle, exchange config, strategy market, wallet, public competition, klines, and launch preflight. route_registry.go documents registered API routes for LLM/tool prompts.",
      "docs": [
        "api_surface.md"
      ],
      "source": [
        {
          "path": "api/server.go",
          "line": 1
        },
        {
          "path": "api/route_registry.go",
          "line": 1
        }
      ]
    },
    {
      "id": "manager",
      "name": "Trader manager",
      "path": "manager/trader_manager.go",
      "summary": "Holds in-memory trader instances, loads persisted running traders, and coordinates start, stop, update, and runtime status transitions.",
      "docs": [
        "runtime_orchestration.md",
        "trading_engine.md"
      ],
      "source": [
        {
          "path": "manager/trader_manager.go",
          "line": 1
        }
      ]
    },
    {
      "id": "trader_kernel",
      "name": "Trader runtime and AI decision kernel",
      "path": "trader",
      "summary": "Combines exchange adapters, market context, prompt construction, AI model calls, position state, and order execution into the autonomous trading loop.",
      "docs": [
        "trading_engine.md"
      ],
      "source": [
        {
          "path": "trader/auto_trader_decision.go",
          "line": 1
        },
        {
          "path": "kernel/engine.go",
          "line": 1
        }
      ]
    },
    {
      "id": "market_provider",
      "name": "Market data and provider integrations",
      "path": "market",
      "summary": "Normalizes market data from CoinAnk, Hyperliquid, TwelveData, nofxos, and exchange adapters into kline, indicator, balance, and pricing inputs.",
      "docs": [
        "market_provider_integrations.md"
      ],
      "source": [
        {
          "path": "market/data.go",
          "line": 1
        },
        {
          "path": "provider/nofxos/client.go",
          "line": 1
        }
      ]
    },
    {
      "id": "store",
      "name": "Persistence and domain models",
      "path": "store",
      "summary": "Stores users, encrypted exchange credentials, strategies, AI model config, trader configs, decisions, orders, positions, equity history, and strategy tokens.",
      "docs": [
        "model_contracts.md"
      ],
      "source": [
        {
          "path": "store/store.go",
          "line": 1
        },
        {
          "path": "store/trader.go",
          "line": 1
        }
      ]
    },
    {
      "id": "security",
      "name": "Identity, crypto, wallet, and network boundaries",
      "path": "auth",
      "summary": "Enforces JWT authentication, password hashing, local-only account recovery, client-to-server credential encryption, URL validation, CORS allowlisting, and wallet authorization flows.",
      "docs": [
        "security_identity.md"
      ],
      "source": [
        {
          "path": "auth/auth.go",
          "line": 1
        },
        {
          "path": "crypto/crypto.go",
          "line": 1
        },
        {
          "path": "security/url_validator.go",
          "line": 1
        }
      ]
    },
    {
      "id": "web",
      "name": "React trading terminal",
      "path": "web/src",
      "summary": "Provides onboarding, auth context, launch preflight, strategy studio, dashboard telemetry, competition views, charting, wallet connection, and API clients.",
      "docs": [
        "web_terminal.md"
      ],
      "source": [
        {
          "path": "web/src/lib/launch/launchAutopilot.ts",
          "line": 1
        },
        {
          "path": "web/src/lib/api/data.ts",
          "line": 1
        }
      ]
    }
  ],
  "docs": [
    {
      "path": "overview.md",
      "title": "nofx overview",
      "excerpt": "CodeWiki overview generated from the current nofx repository.",
      "wordCount": 2692
    },
    {
      "path": "runtime_orchestration.md",
      "title": "Runtime orchestration",
      "excerpt": "nofx starts from `main.go`: configuration, encryption, store initialization, TraderManager loading, API server startup, and graceful shutdown are wired in one process. Local recovery commands are intercepted before server startup through `cli.go`. The runtime ",
      "wordCount": 70
    },
    {
      "path": "api_surface.md",
      "title": "API surface",
      "excerpt": "The Gin API is registered in `api/server.go` under `/api`. Public endpoints cover health, supported models and exchanges, public competition, top traders, kline data, public strategies, and wallet validation. Authenticated routes cover user state, exchange and",
      "wordCount": 80
    },
    {
      "path": "trading_engine.md",
      "title": "Trading engine",
      "excerpt": "The trading engine spans `manager/`, `trader/`, and `kernel/`. `TraderManager` owns lifecycle and in-memory trader instances; `trader/` owns exchange-facing runtime behavior; `kernel/` owns prompt construction, AI decision analysis, and typed decision formatti",
      "wordCount": 57
    },
    {
      "path": "market_provider_integrations.md",
      "title": "Market and provider integrations",
      "excerpt": "Market and provider inputs are normalized through `market/`, `provider/`, `wallet/`, and exchange-specific `trader/*` adapters. Recent nofx work emphasizes server-side launch preflight, runtime AI wallet health, real balance polling, and accurate running statu",
      "wordCount": 62
    },
    {
      "path": "model_contracts.md",
      "title": "Model contracts",
      "excerpt": "`store/` is the contract layer for users, strategies, trader configs, AI model config, exchange config, decisions, orders, positions, position history, equity, visibility, grid settings, and strategy tokens. API handlers and runtime loops should be read agains",
      "wordCount": 73
    },
    {
      "path": "security_identity.md",
      "title": "Security and identity",
      "excerpt": "nofx has several explicit security boundaries: JWT auth in `auth/`, CORS allowlisting in `api/server.go`, client-to-server credential encryption in `crypto/` and `api/crypto_handler.go`, URL validation in `security/`, wallet authorization in API and wallet hel",
      "wordCount": 64
    },
    {
      "path": "web_terminal.md",
      "title": "Web terminal",
      "excerpt": "The React terminal under `web/src` handles authentication, onboarding, launch preflight, strategy selection, trading dashboard telemetry, public competition, charting, wallet connection, and typed HTTP API clients. Important agent entrypoints include `web/src/",
      "wordCount": 43
    }
  ],
  "entrypoints": [
    {
      "group": "process_bootstrap",
      "path": "main.go",
      "symbol": "main",
      "method": "process",
      "purpose": "Production server startup and graceful shutdown."
    },
    {
      "group": "process_bootstrap",
      "path": "cli.go",
      "symbol": "runCLISubcommand",
      "method": "cli",
      "purpose": "Host-local recovery commands."
    },
    {
      "group": "http_api",
      "path": "api/server.go",
      "symbol": "setupRoutes",
      "method": "GET/POST/PUT/DELETE",
      "purpose": "Registers public and authenticated /api endpoints."
    },
    {
      "group": "http_api",
      "path": "api/route_registry.go",
      "symbol": "routeWithSchema",
      "method": "registry",
      "purpose": "Captures route documentation for prompts and docs."
    },
    {
      "group": "http_api",
      "path": "api/launch_preflight.go",
      "symbol": "Launch preflight handlers",
      "method": "POST",
      "purpose": "Validates launch readiness before starting autopilot."
    },
    {
      "group": "trading_runtime",
      "path": "manager/trader_manager.go",
      "symbol": "TraderManager",
      "method": "runtime",
      "purpose": "Lifecycle owner for active trader instances."
    },
    {
      "group": "trading_runtime",
      "path": "trader/auto_trader_decision.go",
      "symbol": "AutoTrader decision loop",
      "method": "loop",
      "purpose": "Builds AI decision context and routes execution."
    },
    {
      "group": "trading_runtime",
      "path": "kernel/engine.go",
      "symbol": "Engine",
      "method": "decision",
      "purpose": "Prompted AI trading decision engine."
    },
    {
      "group": "data_and_providers",
      "path": "market/data.go",
      "symbol": "Market data",
      "method": "provider",
      "purpose": "Kline and indicator inputs."
    },
    {
      "group": "data_and_providers",
      "path": "provider/nofxos/client.go",
      "symbol": "nofxos client",
      "method": "provider",
      "purpose": "External market/intelligence provider."
    },
    {
      "group": "data_and_providers",
      "path": "wallet/usdc.go",
      "symbol": "Wallet balance",
      "method": "wallet",
      "purpose": "Runtime wallet balance inputs."
    },
    {
      "group": "persistence_contracts",
      "path": "store/store.go",
      "symbol": "Store",
      "method": "repository",
      "purpose": "Top-level persistence facade."
    },
    {
      "group": "persistence_contracts",
      "path": "store/trader.go",
      "symbol": "Trader model",
      "method": "model",
      "purpose": "Trader configuration and runtime status contract."
    },
    {
      "group": "persistence_contracts",
      "path": "store/position.go",
      "symbol": "Position model",
      "method": "model",
      "purpose": "Position and PnL state."
    },
    {
      "group": "frontend_terminal",
      "path": "web/src/lib/launch/launchAutopilot.ts",
      "symbol": "launchAutopilot",
      "method": "client",
      "purpose": "Frontend launch orchestration."
    },
    {
      "group": "frontend_terminal",
      "path": "web/src/lib/launch/preflight.ts",
      "symbol": "preflight client",
      "method": "client",
      "purpose": "Launch readiness API adapter."
    },
    {
      "group": "frontend_terminal",
      "path": "web/src/components/terminal/OrchestrationTopology.tsx",
      "symbol": "OrchestrationTopology",
      "method": "ui",
      "purpose": "Runtime topology visualization."
    },
    {
      "group": "security_boundaries",
      "path": "api/server.go",
      "symbol": "corsMiddleware",
      "method": "middleware",
      "purpose": "Origin allowlist and request boundary."
    },
    {
      "group": "security_boundaries",
      "path": "crypto/crypto.go",
      "symbol": "CryptoService",
      "method": "crypto",
      "purpose": "Credential encryption boundary."
    },
    {
      "group": "security_boundaries",
      "path": "cli.go",
      "symbol": "reset-account",
      "method": "local",
      "purpose": "Destructive recovery restricted to host shell."
    }
  ],
  "architecture": {
    "relationshipGraph": {
      "schema": "reference-agent-wiki/relationship-graph/v1",
      "relationships": [
        {
          "type": "module_dependency",
          "from": "main.go",
          "to": "api.NewServer",
          "label": "process bootstrap constructs API server"
        },
        {
          "type": "module_dependency",
          "from": "api.Server",
          "to": "manager.TraderManager",
          "label": "handlers delegate lifecycle operations"
        },
        {
          "type": "module_dependency",
          "from": "api.Server",
          "to": "store.Store",
          "label": "handlers read and persist domain state"
        },
        {
          "type": "module_dependency",
          "from": "trader.AutoTrader",
          "to": "kernel.Engine",
          "label": "runtime asks AI engine for decisions"
        },
        {
          "type": "module_dependency",
          "from": "kernel.Engine",
          "to": "mcp/provider",
          "label": "LLM provider adapters execute model requests"
        },
        {
          "type": "call_chain",
          "from": "web launchAutopilot",
          "to": "api launch preflight",
          "label": "browser validates readiness before launch"
        },
        {
          "type": "call_chain",
          "from": "api trader handler",
          "to": "TraderManager.StartTrader",
          "label": "start request creates or resumes runtime"
        },
        {
          "type": "call_chain",
          "from": "AutoTrader loop",
          "to": "exchange adapter",
          "label": "decision loop places and reconciles orders"
        },
        {
          "type": "upstream_downstream",
          "from": "market/providers",
          "to": "kernel prompt builder",
          "label": "market inputs shape AI prompt context"
        },
        {
          "type": "upstream_downstream",
          "from": "store equity/position",
          "to": "web dashboard",
          "label": "persisted runtime state feeds telemetry UI"
        },
        {
          "type": "upstream_downstream",
          "from": "public competition API",
          "to": "competition page",
          "label": "public read model powers leaderboard"
        },
        {
          "type": "data_flow",
          "from": "encrypted frontend payload",
          "to": "crypto.CryptoService",
          "label": "credential ciphertext crosses server crypto boundary"
        },
        {
          "type": "data_flow",
          "from": "exchange account state",
          "to": "launch preflight",
          "label": "balance and auth checks gate launch"
        },
        {
          "type": "data_flow",
          "from": "AI decision",
          "to": "orders/positions/equity",
          "label": "runtime decisions become persisted trading state"
        },
        {
          "type": "data_flow",
          "from": "klines/providers",
          "to": "web charts",
          "label": "market data is normalized for terminal charts"
        }
      ],
      "byType": {
        "module_dependency": 5,
        "call_chain": 3,
        "upstream_downstream": 3,
        "data_flow": 4
      },
      "namedSubgraphs": {
        "stateMachines": [
          {
            "id": "trader-lifecycle",
            "states": [
              "configured",
              "preflight_checked",
              "starting",
              "running",
              "stopping",
              "stopped",
              "failed"
            ],
            "evidence": [
              {
                "path": "manager/trader_manager.go",
                "line": 1
              },
              {
                "path": "api/handler_trader_status.go",
                "line": 1
              }
            ]
          },
          {
            "id": "launch-preflight",
            "states": [
              "request",
              "config_check",
              "wallet_check",
              "provider_check",
              "ready_or_blocked"
            ],
            "evidence": [
              {
                "path": "api/launch_preflight.go",
                "line": 1
              },
              {
                "path": "web/src/lib/launch/preflight.ts",
                "line": 1
              }
            ]
          }
        ],
        "securityBoundaries": [
          {
            "id": "browser-to-api",
            "boundary": "CORS and JWT authenticated /api access",
            "evidence": [
              {
                "path": "api/server.go",
                "line": 1
              },
              {
                "path": "auth/auth.go",
                "line": 1
              }
            ]
          },
          {
            "id": "credential-crypto",
            "boundary": "Client encrypts credentials to server public key; server decrypts internally for config updates.",
            "evidence": [
              {
                "path": "api/crypto_handler.go",
                "line": 1
              },
              {
                "path": "crypto/crypto.go",
                "line": 1
              }
            ]
          },
          {
            "id": "local-recovery-cli",
            "boundary": "Reset subcommands are host-local and not exposed over HTTP.",
            "evidence": [
              {
                "path": "cli.go",
                "line": 1
              }
            ]
          }
        ]
      },
      "moduleDependencies": [
        {
          "type": "module_dependency",
          "from": "main.go",
          "to": "api.NewServer",
          "label": "process bootstrap constructs API server"
        },
        {
          "type": "module_dependency",
          "from": "api.Server",
          "to": "manager.TraderManager",
          "label": "handlers delegate lifecycle operations"
        },
        {
          "type": "module_dependency",
          "from": "api.Server",
          "to": "store.Store",
          "label": "handlers read and persist domain state"
        },
        {
          "type": "module_dependency",
          "from": "trader.AutoTrader",
          "to": "kernel.Engine",
          "label": "runtime asks AI engine for decisions"
        },
        {
          "type": "module_dependency",
          "from": "kernel.Engine",
          "to": "mcp/provider",
          "label": "LLM provider adapters execute model requests"
        }
      ],
      "callChains": [
        {
          "type": "call_chain",
          "from": "web launchAutopilot",
          "to": "api launch preflight",
          "label": "browser validates readiness before launch"
        },
        {
          "type": "call_chain",
          "from": "api trader handler",
          "to": "TraderManager.StartTrader",
          "label": "start request creates or resumes runtime"
        },
        {
          "type": "call_chain",
          "from": "AutoTrader loop",
          "to": "exchange adapter",
          "label": "decision loop places and reconciles orders"
        }
      ],
      "upstreamDownstream": [
        {
          "type": "upstream_downstream",
          "from": "market/providers",
          "to": "kernel prompt builder",
          "label": "market inputs shape AI prompt context"
        },
        {
          "type": "upstream_downstream",
          "from": "store equity/position",
          "to": "web dashboard",
          "label": "persisted runtime state feeds telemetry UI"
        },
        {
          "type": "upstream_downstream",
          "from": "public competition API",
          "to": "competition page",
          "label": "public read model powers leaderboard"
        }
      ],
      "dataFlows": [
        {
          "type": "data_flow",
          "from": "encrypted frontend payload",
          "to": "crypto.CryptoService",
          "label": "credential ciphertext crosses server crypto boundary"
        },
        {
          "type": "data_flow",
          "from": "exchange account state",
          "to": "launch preflight",
          "label": "balance and auth checks gate launch"
        },
        {
          "type": "data_flow",
          "from": "AI decision",
          "to": "orders/positions/equity",
          "label": "runtime decisions become persisted trading state"
        },
        {
          "type": "data_flow",
          "from": "klines/providers",
          "to": "web charts",
          "label": "market data is normalized for terminal charts"
        }
      ]
    },
    "layerRelationships": [
      {
        "from": "web",
        "to": "api",
        "kind": "http_client",
        "description": "React terminal calls Gin /api endpoints for launch, telemetry, config, wallet, and market data."
      },
      {
        "from": "api",
        "to": "manager",
        "kind": "lifecycle",
        "description": "API handlers start, stop, update, and inspect trader runtime through TraderManager."
      },
      {
        "from": "manager",
        "to": "trader_kernel",
        "kind": "runtime_ownership",
        "description": "TraderManager owns active AutoTrader instances and their lifecycle."
      },
      {
        "from": "trader_kernel",
        "to": "market_provider",
        "kind": "data_dependency",
        "description": "Trading decisions use market data, provider signals, exchange balances, and wallet state."
      },
      {
        "from": "trader_kernel",
        "to": "store",
        "kind": "state_persistence",
        "description": "Decisions, orders, positions, equity snapshots, and trader config are persisted through store repositories."
      },
      {
        "from": "api",
        "to": "security",
        "kind": "auth_crypto",
        "description": "API requests cross JWT, CORS, encrypted credential, and wallet authorization boundaries."
      },
      {
        "from": "bootstrap",
        "to": "api",
        "kind": "process_bootstrap",
        "description": "main.go wires config, crypto, persistence, TraderManager, and server startup."
      }
    ]
  },
  "surfaces": {
    "entrySurface": {
      "schema": "reference-agent-wiki/entry-surface/v1",
      "groups": {
        "process_bootstrap": [
          {
            "path": "main.go",
            "symbol": "main",
            "method": "process",
            "purpose": "Production server startup and graceful shutdown."
          },
          {
            "path": "cli.go",
            "symbol": "runCLISubcommand",
            "method": "cli",
            "purpose": "Host-local recovery commands."
          }
        ],
        "http_api": [
          {
            "path": "api/server.go",
            "symbol": "setupRoutes",
            "method": "GET/POST/PUT/DELETE",
            "purpose": "Registers public and authenticated /api endpoints."
          },
          {
            "path": "api/route_registry.go",
            "symbol": "routeWithSchema",
            "method": "registry",
            "purpose": "Captures route documentation for prompts and docs."
          },
          {
            "path": "api/launch_preflight.go",
            "symbol": "Launch preflight handlers",
            "method": "POST",
            "purpose": "Validates launch readiness before starting autopilot."
          }
        ],
        "trading_runtime": [
          {
            "path": "manager/trader_manager.go",
            "symbol": "TraderManager",
            "method": "runtime",
            "purpose": "Lifecycle owner for active trader instances."
          },
          {
            "path": "trader/auto_trader_decision.go",
            "symbol": "AutoTrader decision loop",
            "method": "loop",
            "purpose": "Builds AI decision context and routes execution."
          },
          {
            "path": "kernel/engine.go",
            "symbol": "Engine",
            "method": "decision",
            "purpose": "Prompted AI trading decision engine."
          }
        ],
        "data_and_providers": [
          {
            "path": "market/data.go",
            "symbol": "Market data",
            "method": "provider",
            "purpose": "Kline and indicator inputs."
          },
          {
            "path": "provider/nofxos/client.go",
            "symbol": "nofxos client",
            "method": "provider",
            "purpose": "External market/intelligence provider."
          },
          {
            "path": "wallet/usdc.go",
            "symbol": "Wallet balance",
            "method": "wallet",
            "purpose": "Runtime wallet balance inputs."
          }
        ],
        "persistence_contracts": [
          {
            "path": "store/store.go",
            "symbol": "Store",
            "method": "repository",
            "purpose": "Top-level persistence facade."
          },
          {
            "path": "store/trader.go",
            "symbol": "Trader model",
            "method": "model",
            "purpose": "Trader configuration and runtime status contract."
          },
          {
            "path": "store/position.go",
            "symbol": "Position model",
            "method": "model",
            "purpose": "Position and PnL state."
          }
        ],
        "frontend_terminal": [
          {
            "path": "web/src/lib/launch/launchAutopilot.ts",
            "symbol": "launchAutopilot",
            "method": "client",
            "purpose": "Frontend launch orchestration."
          },
          {
            "path": "web/src/lib/launch/preflight.ts",
            "symbol": "preflight client",
            "method": "client",
            "purpose": "Launch readiness API adapter."
          },
          {
            "path": "web/src/components/terminal/OrchestrationTopology.tsx",
            "symbol": "OrchestrationTopology",
            "method": "ui",
            "purpose": "Runtime topology visualization."
          }
        ],
        "security_boundaries": [
          {
            "path": "api/server.go",
            "symbol": "corsMiddleware",
            "method": "middleware",
            "purpose": "Origin allowlist and request boundary."
          },
          {
            "path": "crypto/crypto.go",
            "symbol": "CryptoService",
            "method": "crypto",
            "purpose": "Credential encryption boundary."
          },
          {
            "path": "cli.go",
            "symbol": "reset-account",
            "method": "local",
            "purpose": "Destructive recovery restricted to host shell."
          }
        ]
      }
    }
  },
  "dataAndModels": {
    "storeModels": [
      "User",
      "Trader",
      "Strategy",
      "AIModel",
      "Exchange",
      "Decision",
      "Order",
      "Position",
      "Equity"
    ],
    "runtimeContracts": [
      "TraderManager",
      "AutoTrader",
      "kernel.Engine",
      "market data",
      "exchange adapters",
      "wallet balance"
    ]
  },
  "evidence": {
    "sourceAnchors": [
      {
        "path": "main.go",
        "line": 1
      },
      {
        "path": "cli.go",
        "line": 1
      },
      {
        "path": "api/server.go",
        "line": 1
      },
      {
        "path": "api/route_registry.go",
        "line": 1
      },
      {
        "path": "manager/trader_manager.go",
        "line": 1
      },
      {
        "path": "trader/auto_trader_decision.go",
        "line": 1
      },
      {
        "path": "kernel/engine.go",
        "line": 1
      },
      {
        "path": "market/data.go",
        "line": 1
      },
      {
        "path": "provider/nofxos/client.go",
        "line": 1
      },
      {
        "path": "store/store.go",
        "line": 1
      },
      {
        "path": "store/trader.go",
        "line": 1
      },
      {
        "path": "auth/auth.go",
        "line": 1
      },
      {
        "path": "crypto/crypto.go",
        "line": 1
      },
      {
        "path": "security/url_validator.go",
        "line": 1
      },
      {
        "path": "web/src/lib/launch/launchAutopilot.ts",
        "line": 1
      },
      {
        "path": "web/src/lib/api/data.ts",
        "line": 1
      }
    ],
    "codegraph": {
      "files": 443,
      "nodes": 6559,
      "edges": 19575
    }
  },
  "personaEntrypoints": {
    "maintainer": [
      "knowledge_pack/architecture_map.md",
      "knowledge_pack/api_catalog.md",
      "diagrams/architecture.svg"
    ],
    "frontend_agent": [
      "web_terminal.md",
      "diagrams/api-entrypoints.svg",
      "knowledge_pack/api_catalog.md"
    ],
    "runtime_agent": [
      "runtime_orchestration.md",
      "trading_engine.md",
      "diagrams/runtime-flow.svg"
    ],
    "security_reviewer": [
      "security_identity.md",
      "diagrams/security-boundary.svg",
      "cli.go"
    ]
  },
  "projectOptimizations": {
    "launchPreflight": "Expose launch readiness as a first-class entry surface so agents check wallet, provider, and config gates before reasoning about runtime failures.",
    "localRecoveryBoundary": "Document reset-password/reset-account as host-local CLI paths, not HTTP flows.",
    "tradingRuntimeSeparation": "Separate API lifecycle, TraderManager ownership, AutoTrader loop, kernel prompt/decision, exchange execution, and persisted state.",
    "providerSurface": "Group market, nofxos, LLM provider, wallet, and exchange adapters as upstream data/control surfaces.",
    "publicPublishing": "Keep generated public artifacts under a stable static path and scrub local absolute paths before governance-site publication."
  },
  "diagramArtifacts": [
    {
      "id": "architecture",
      "group": "architecture",
      "title": "NOFX System Architecture",
      "file": "diagrams/architecture.svg",
      "type": "svg",
      "interpretation": "Shows the browser terminal, Gin API, manager, trading kernel, providers, persistence, and security boundary at the system level.",
      "evidence": [
        {
          "path": "main.go",
          "line": 1
        },
        {
          "path": "api/server.go",
          "line": 1
        }
      ],
      "source": "diagrams/architecture.mmd"
    },
    {
      "id": "runtime-flow",
      "group": "runtime-flow",
      "title": "NOFX Launch And Runtime Flow",
      "file": "diagrams/runtime-flow.svg",
      "type": "svg",
      "interpretation": "Shows launch preflight, trader start, decision loop, order execution, persistence, and dashboard polling.",
      "evidence": [
        {
          "path": "api/launch_preflight.go",
          "line": 1
        },
        {
          "path": "trader/auto_trader_decision.go",
          "line": 1
        }
      ],
      "source": "diagrams/runtime-flow.mmd"
    },
    {
      "id": "data-flow",
      "group": "data-flow",
      "title": "NOFX Market And State Data Flow",
      "file": "diagrams/data-flow.svg",
      "type": "svg",
      "interpretation": "Maps provider market data, wallet/account state, AI decisions, and persisted telemetry into frontend dashboards.",
      "evidence": [
        {
          "path": "market/data.go",
          "line": 1
        },
        {
          "path": "store/equity.go",
          "line": 1
        }
      ],
      "source": "diagrams/data-flow.mmd"
    },
    {
      "id": "state-machine",
      "group": "state-machine",
      "title": "NOFX Trader Lifecycle State Machine",
      "file": "diagrams/state-machine.svg",
      "type": "svg",
      "interpretation": "Shows configured trader state progressing through preflight, start, running, stop, and failure states.",
      "evidence": [
        {
          "path": "manager/trader_manager.go",
          "line": 1
        },
        {
          "path": "api/handler_trader_status.go",
          "line": 1
        }
      ],
      "source": "diagrams/state-machine.mmd"
    },
    {
      "id": "model-contract",
      "group": "model-contract",
      "title": "NOFX Model And Contract Map",
      "file": "diagrams/model-contract.svg",
      "type": "svg",
      "interpretation": "Shows core persisted contracts for users, traders, strategies, AI models, exchanges, decisions, orders, positions, and equity.",
      "evidence": [
        {
          "path": "store/store.go",
          "line": 1
        },
        {
          "path": "store/trader.go",
          "line": 1
        }
      ],
      "source": "diagrams/model-contract.mmd"
    },
    {
      "id": "security-boundary",
      "group": "security-boundary",
      "title": "NOFX Security Boundary Map",
      "file": "diagrams/security-boundary.svg",
      "type": "svg",
      "interpretation": "Shows the public browser/API boundary, JWT-authenticated APIs, credential crypto boundary, wallet authorization, and host-local recovery commands.",
      "evidence": [
        {
          "path": "api/server.go",
          "line": 1
        },
        {
          "path": "cli.go",
          "line": 1
        }
      ],
      "source": "diagrams/security-boundary.mmd"
    },
    {
      "id": "api-entrypoints",
      "group": "entrypoint",
      "title": "NOFX API And UI Entrypoints",
      "file": "diagrams/api-entrypoints.svg",
      "type": "svg",
      "interpretation": "Groups process, HTTP API, runtime, provider, persistence, frontend, and security entrypoints for agent navigation.",
      "evidence": [
        {
          "path": "api/route_registry.go",
          "line": 1
        },
        {
          "path": "web/src/lib/httpClient.ts",
          "line": 1
        }
      ],
      "source": "diagrams/api-entrypoints.mmd"
    }
  ],
  "artifactLinks": {
    "interactive": "interactive/index.html",
    "diagrams": "diagrams/index.html",
    "agentContext": "knowledge_pack/agent_context.json"
  },
  "coverage": {
    "api": true,
    "runtime": true,
    "frontend": true,
    "providerIntegrations": true,
    "securityBoundaries": true,
    "persistenceContracts": true
  }
}
