|
| 1 | +# Three-repo architecture: CLI · Router · Platform |
| 2 | + |
| 3 | +Status: current state verified against code (2026-09-04); target state is a |
| 4 | +proposal. See also `gateway-architecture.md` (human-readable version), |
| 5 | +`ECOSYSTEM-WIRING.md` (pre-migration wiring, partially stale). |
| 6 | + |
| 7 | +## Current state (verified) |
| 8 | + |
| 9 | +```mermaid |
| 10 | +flowchart LR |
| 11 | + subgraph CLI["graycode-cli"] |
| 12 | + TUI["chat · exec · review\nagent loop · sessions"] |
| 13 | + ENG["graycode-router engine\n(compiled in)"] |
| 14 | + end |
| 15 | +
|
| 16 | + subgraph ROUTER["graycode-router"] |
| 17 | + LIB["engine library\n(router, adapters)"] |
| 18 | + SRV["HTTP server (skeleton)\ninternal/api + openapi.yaml"] |
| 19 | + end |
| 20 | +
|
| 21 | + subgraph PLAT["graycode-platform"] |
| 22 | + WEB["web / BFF"] |
| 23 | + AUTH["login · billing"] |
| 24 | + end |
| 25 | +
|
| 26 | + TUI --> ENG |
| 27 | + ENG -. "go.mod (module only)" .-> LIB |
| 28 | + TUI -. "opt-in HTTPS\n(device login, usage, sync)" .-> WEB |
| 29 | +``` |
| 30 | + |
| 31 | +Wires, with evidence: |
| 32 | + |
| 33 | +| From → To | Mechanism | Evidence | |
| 34 | +|---|---|---| |
| 35 | +| CLI → Router | Go module dep, in-process construction | `go.mod` requires `github.com/GrayCodeAI/graycode-router`; `internal/provider/gateway/gateway.go` is the sole importer | |
| 36 | +| CLI → Platform | Opt-in HTTPS (login, usage, graph sync) | `internal/platform/cloud/client.go`; `Enabled()` requires endpoint + token; no default URL | |
| 37 | +| Router → CLI | none | router `go.mod`/`go.sum` contain zero graycode-cli refs | |
| 38 | +| Router ↔ Platform | none | no imports, package deps, or API calls either direction | |
| 39 | + |
| 40 | +## Target state (proposal) |
| 41 | + |
| 42 | +```mermaid |
| 43 | +flowchart LR |
| 44 | + CLI2["graycode-cli\n(default: in-process)"] -. "opt-in --model-gateway" .-> GW |
| 45 | + WEB2["platform web/BFF"] -->|per-user keys| GW |
| 46 | + subgraph GW["graycode-router: common service"] |
| 47 | + API["OpenAI-compatible API\n/v1/chat/completions + SSE"] |
| 48 | + POL["routing · retry · guardrails\nspend tracking"] |
| 49 | + end |
| 50 | + GW --> PROV[(providers)] |
| 51 | + CLI2 -->|direct| PROV |
| 52 | +``` |
| 53 | + |
| 54 | +Rules: CLI always works alone; streams pass through byte-transparent; |
| 55 | +auth fails fast with a login hint; CLI pins a gateway API version. |
| 56 | + |
| 57 | +## Open items |
| 58 | + |
| 59 | +- Gateway endpoints don't exist yet (`server.go` is a skeleton). |
| 60 | +- Plugin registry index has no live home (both old and new URLs 404). |
| 61 | +- `Y0_MARKETPLACE` default disagrees between code (on) and old docs (off). |
| 62 | +- Remaining architecture prose still describes the pre-migration ecosystem. |
0 commit comments