# callstackincubator/cali architecture

> Architecture diagram of the GitHub repository callstackincubator/cali, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/callstackincubator/cali
- Repository: https://github.com/callstackincubator/cali

## Overview

##### Project type and purpose
- This is a TypeScript-based monorepo (managed via root package.json & tsconfig.json) containing three cooperating packages:
- packages/cali – a CLI-based AI agent for building React Native apps
- packages/tools – a library of “tool” functions (wrappers around RN-CLI, npm, pods, device management, etc.)
- packages/mcp-server – an HTTP server implementing the Model Context Protocol (MCP) so that LLMs like Claude or Zed can drive the same tools remotely
- Its purpose is to let a large language model orchestrate React Native app workflows (build, install deps, manage devices) via either a terminal CLI, Vercel AI SDK, or any MCP-compatible client.

##### File structure
- Top-level config files (.eslintrc, tsconfig.json, LICENSE, README.md, docs/) govern linting, build, contribution guidelines, and overall monorepo docs.
- packages/cali
– cli.ts: entry point that loads the toolset and orchestrates LLM prompts
– prompt.ts/utils.ts: logic for building prompts and parsing LLM responses
- packages/tools
– android.ts, apple.ts, fs.ts, git.ts, npm.ts, react-native.ts: wrappers around native CLIs
– vendor/: any third-party or custom adapters
- packages/mcp-server
– index.ts: HTTP server exposing tool methods according to the MCP JSON-RPC protocol
- Shared rslib.config.ts files & individual tsconfig.json files show that each package compiles to JS modules for Node.

##### Key insights from the README
- Three delivery modes: standalone CLI, Vercel AI SDK integration, MCP server
- Core features: build automation, device management, dependency management, library search
- External dependencies include React Native CLI, CocoaPods, npm, git, plus LLM endpoints (OpenAI, Anthropic, etc.)

a. Main components
- CLI Client (packages/cali)
- Tools Library (packages/tools)
- MCP Server (packages/mcp-server)
- Underlying native CLIs & local OS services (React Native CLI, CocoaPods, npm, git, filesystem, simulators)
- External LLM Providers (OpenAI, Claude, Zed, etc.)
- Optional Integration: Vercel AI SDK
b. Relationships & data flows
1. CLI Client or MCP Server invokes Tools Library methods.
2. Tools call underlying CLIs (e.g., `npx react-native run-ios`, `pod install`, `npm install`).
3. CLI assembles prompts via prompt.ts, sends them to LLM Provider over HTTP/SDK, receives JSON responses.
4. MCP Server exposes the same Tools methods over a JSON-RPC interface to any MCP-capable LLM client.
5. (Optional) Vercel AI SDK wraps the Tools Library for web-based LLM UIs.
c. Architectural patterns
– Monorepo with isolated packages and shared build configs
– Plugin-style “tools” abstraction around native CLIs
– Thin application layers (CLI & server) that orchestrate LLM calls + tool invocation
d. Technologies & frameworks
– Node.js + TypeScript
– rslib for build/packaging
– React Native CLI, CocoaPods, npm, git
– Vercel AI SDK (integration)
– MCP (Model Context Protocol) over HTTP

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Monorepo Packages"
        subgraph "CLI Client"
            CLI["CLI Agent"]:::internal
            click CLI "https://github.com/callstackincubator/cali/blob/main/packages/cali/src/cli.ts"
            CaliPkg["package.json"]:::internal
            click CaliPkg "https://github.com/callstackincubator/cali/blob/main/packages/cali/package.json"
        end
        subgraph "Orchestration Layer"
            Prompt["prompt.ts"]:::internal
            click Prompt "https://github.com/callstackincubator/cali/blob/main/packages/cali/src/prompt.ts"
            Utils["utils.ts"]:::internal
            click Utils "https://github.com/callstackincubator/cali/blob/main/packages/cali/src/utils.ts"
        end
        subgraph "Tools Library"
            ToolsLib["index.ts"]:::internal
            click ToolsLib "https://github.com/callstackincubator/cali/blob/main/packages/tools/src/index.ts"
            ToolsPkg["package.json"]:::internal
            click ToolsPkg "https://github.com/callstackincubator/cali/blob/main/packages/tools/package.json"
            subgraph "Tool Wrappers"
                Android["android.ts"]:::tool
                click Android "https://github.com/callstackincubator/cali/blob/main/packages/tools/src/android.ts"
                Apple["apple.ts"]:::tool
                click Apple "https://github.com/callstackincubator/cali/blob/main/packages/tools/src/apple.ts"
                FS["fs.ts"]:::tool
                click FS "https://github.com/callstackincubator/cali/blob/main/packages/tools/src/fs.ts"
                Git["git.ts"]:::tool
                click Git "https://github.com/callstackincubator/cali/blob/main/packages/tools/src/git.ts"
                NPM["npm.ts"]:::tool
                click NPM "https://github.com/callstackincubator/cali/blob/main/packages/tools/src/npm.ts"
                RN["react-native.ts"]:::tool
                click RN "https://github.com/callstackincubator/cali/blob/main/packages/tools/src/react-native.ts"
                Vendor["vendor/"]:::tool
                click Vendor "https://github.com/callstackincubator/cali/tree/main/packages/tools/src/vendor/"
            end
        end
        subgraph "MCP Server"
            MCP["MCP Server"]:::internal
            click MCP "https://github.com/callstackincubator/cali/blob/main/packages/mcp-server/src/index.ts"
            MCPpkg["package.json"]:::internal
            click MCPpkg "https://github.com/callstackincubator/cali/blob/main/packages/mcp-server/package.json"
        end
    end

    subgraph "Shared Config"
        TSConfig["tsconfig.json"]:::config
        click TSConfig "https://github.com/callstackincubator/cali/blob/main/tsconfig.json"
        ESLint[".eslintrc.cjs"]:::config
        click ESLint "https://github.com/callstackincubator/cali/blob/main/.eslintrc.cjs"
    end

    subgraph "External Systems"
        LLM["External LLM Providers"]:::external
        Vercel["Vercel AI SDK"]:::external
        Native["Native CLIs & OS"]:::tool
    end

    CLI -->|orchestrates| Prompt
    Prompt -->|sends/receives| LLM
    Prompt -->|invokes| ToolsLib
    ToolsLib -->|executes| Native
    MCP -->|calls| ToolsLib
    MCP -->|JSON-RPC| LLM
    Vercel -->|wraps| Prompt

    classDef internal fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef external fill:#90EE90,stroke:#333,stroke-width:1px
    classDef tool fill:#FFA500,stroke:#333,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:1px
```
