Chapter 2: Architecture and Package Topology

March 21, 2026 ยท View on GitHub

Welcome to Chapter 2: Architecture and Package Topology. In this part of Claude Code Router Tutorial: Multi-Provider Routing and Control Plane for Claude Code, you will build an intuitive mental model first, then move into concrete implementation details and practical production tradeoffs.

This chapter maps CCR's monorepo structure and runtime boundaries.

Learning Goals

  • understand responsibilities of CLI, server, and shared packages
  • trace request flow across router and transformer layers
  • identify extension points for custom routing/transformers
  • reduce confusion when debugging multi-layer behavior

Core Package Roles

PackageResponsibility
CLIcommand orchestration, model/preset/status workflows
Serverrequest routing, API handling, stream processing
Sharedcommon config, constants, preset utilities
external @musistudio/llmsprovider transformation framework

Source References

Summary

You now have a clear component model for reasoning about CCR behavior.

Next: Chapter 3: Provider Configuration and Transformer Strategy

Source Code Walkthrough

docs/src/docusaurus.d.ts

The Heading function in docs/src/docusaurus.d.ts handles a key part of this chapter's functionality:


// Additional theme component type declarations
declare module '@theme/Heading' {
  import type {ReactNode, CSSProperties} from 'react';

  export type Props = {
    readonly as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
    readonly className?: string;
    readonly style?: CSSProperties;
    readonly children?: ReactNode;
  };

  export default function Heading(props: Props): ReactNode;
}

This function is important because it defines how Claude Code Router Tutorial: Multi-Provider Routing and Control Plane for Claude Code implements the patterns covered in this chapter.

How These Components Connect

flowchart TD
    A[Heading]