%%{init: {"theme": "base", "themeVariables": {"fontFamily": "Inter, ui-sans-serif, system-ui, Segoe UI, Arial", "background": "transparent", "primaryTextColor": "#172033", "lineColor": "#718096"}}}%%
flowchart LR
    client(["Claude Code<br/>CLI / IDE / Bots"])
    api["Anthropic-compatible API<br/>/v1/messages, /v1/models"]

    subgraph proxy["Free Claude Code Proxy :8082"]
        admin["Local Admin UI<br/>keys, models, status"]
        config[("Managed Config<br/>~/.fcc/.env")]
        router{"Model Router<br/>Opus / Sonnet / Haiku"}
        optimize["Request Optimizations<br/>cheap local probes"]
        normalize["Protocol Normalizer<br/>streaming, tools, thinking"]
        adapters["Provider Adapters<br/>Anthropic + OpenAI-compatible"]
    end

    subgraph hosted["Hosted Providers"]
        nim(["NVIDIA NIM"])
        kimi(["Kimi"])
        wafer(["Wafer"])
        openrouter(["OpenRouter"])
        deepseek(["DeepSeek"])
    end

    subgraph local["Local Providers"]
        lmstudio(["LM Studio"])
        llamacpp(["llama.cpp"])
        ollama(["Ollama"])
    end

    client -->|"Anthropic Messages"| api
    api --> router
    admin --> config
    config --> router
    router --> optimize
    optimize --> normalize
    normalize --> adapters
    adapters --> hosted
    adapters --> local

    classDef client fill:#efe7ff,stroke:#7c3aed,stroke-width:2px,color:#2e1065;
    classDef api fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#172554;
    classDef proxy fill:#ecfeff,stroke:#0891b2,stroke-width:2px,color:#164e63;
    classDef config fill:#fef3c7,stroke:#d97706,stroke-width:2px,color:#78350f;
    classDef transform fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d;
    classDef provider fill:#fff7ed,stroke:#ea580c,stroke-width:2px,color:#7c2d12;

    class client client;
    class api api;
    class admin,router proxy;
    class config config;
    class optimize,normalize,adapters transform;
    class nim,kimi,wafer,openrouter,deepseek,lmstudio,llamacpp,ollama provider;
