# yashdev9274/supercli architecture

> Architecture diagram of the GitHub repository yashdev9274/supercli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yashdev9274/supercli
- Repository: https://github.com/yashdev9274/supercli

## Overview

#### 1. Repository Purpose and Topology
Supercode is a Bun/Turborepo TypeScript monorepo for an AI software-engineering platform. Its primary product is an installable coding-agent CLI, supplemented by a dashboard, terminal browser client, documentation site, and a separate design-generation application. Workspace orchestration starts at `package.json` and `turbo.json`.

#### 2. AI Coding-Agent CLI
The main execution entry point is the Bun CLI at `apps/supercode-cli/server/src/index.ts`, with command dispatch in `apps/supercode-cli/server/src/cli/main.ts` and command registration in `apps/supercode-cli/server/src/cli/commands/index.ts`. The interactive chat loop under `apps/supercode-cli/server/src/cli/ai/chat/chat.ts` gathers workspace context, sends model requests, renders streaming terminal output, and coordinates tool calls.

#### 3. Agent Orchestration and Provider Boundary
Agent modes, prompts, subagents, and execution are concentrated in `apps/supercode-cli/server/src/agent/agent.ts`, `apps/supercode-cli/server/src/agent/agent-service.ts`, and `apps/supercode-cli/server/src/agent/runner.ts`. Prompt templates split work into build, explore, plan, compaction, and summary flows in `apps/supercode-cli/server/src/agent/prompts/`. Provider adapters isolate model-specific APIs—OpenRouter, Google, Minimax, NVIDIA, and server proxy—from chat orchestration in `apps/supercode-cli/server/src/cli/ai/provider.ts` and adjacent `*-service.ts` files.

#### 4. Tooling, Permissions, and Local Boundary
The agent invokes a registry of filesystem, shell, web-search, scraping, delegation, and user-question tools through `apps/supercode-cli/server/src/tools/registry.ts` and `apps/supercode-cli/server/src/cli/ai/tool-executor.ts`. Mutating or sensitive operations are gated by `apps/supercode-cli/server/src/tools/permission-manager.ts` and agent sub-permission policy in `apps/supercode-cli/server/src/agent/subagent-permissions.ts`. Tool definitions such as `apps/supercode-cli/server/src/tools/definitions/edit-file.ts`, `run-command.ts`, and `delegate.ts` form the critical boundary between LLM decisions and the local developer workspace.

#### 5. Web Platform and Async Processing
The public/dashboard Next.js App Router application begins in `apps/web/app/layout.tsx` and `apps/web/app/page.tsx`; authenticated product views live in `apps/web/app/dashboard/page.tsx` and feature modules. Better Auth is exposed through `apps/web/app/api/auth/[...all]/route.ts`, with shared auth/database layers in `packages/auth/src/server.ts` and `packages/db/src/client.ts`. GitHub events enter via `apps/web/app/api/webhooks/github/route.ts`; the Inngest route and AI-review job provide asynchronous repository processing at `apps/web/app/api/inngest/route.ts` and `apps/web/inngest/functions/ai-review.ts`.

#### 6. Persistence, Retrieval, and External Services
PostgreSQL/Prisma is split deliberately: dashboard data uses `packages/db/prisma/schema.prisma`, while CLI/terminal identity or device-flow data uses `apps/supercode-cli/server/prisma/schema.prisma` and `packages/db-terminal/prisma/schema.prisma`. Pinecone-backed RAG is encapsulated by `apps/web/lib/pinecone/pinecone.ts` and `apps/web/modules/pinecone/rag/index.ts`. Material integrations include GitHub OAuth/API, Better Auth, Inngest, Pinecone, Anthropic/Claude, OpenRouter, Google/Gemini, Exa, Firecrawl, MCP/Composio, and optional Slack/Linear/GitHub agent connectors.

#### 7. Supporting Product Surfaces and Shared Domain
The terminal browser UI is a distinct Next.js client with auth/device-approval flows in `apps/supercode-cli/client/app/device/page.tsx` and `apps/supercode-cli/client/app/approve/page.tsx`; it complements rather than replaces the local CLI. Documentation is an MDX-driven Next.js site routed through `apps/docs/app/docs/[slug]/page.tsx`. Superdesign is an independent authenticated Next.js app that exposes project/artifact generation APIs at `apps/superdesign/app/api/projects/[id]/generate/route.ts`, using reusable design prompts, systems, and skills from `packages/design-core/src/prompt-builder.ts` and `packages/design-core/src/design-systems/index.ts`. Open-model fine-tuning is a parallel Python workload, with data preparation and Tinker Qwen3 training in `supercode-openmodel/training/data/prepare_dataset.py` and `supercode-openmodel/training/tinker_qwen3/train.py`.

Main entry points: [`apps/supercode-cli/server/src/tools/registry.ts`](https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/tools/registry.ts) (Tool registry & executor), [`package.json`](https://github.com/yashdev9274/supercli/blob/main/package.json) (Bun/Turbo workspace), [`apps/supercode-cli/server/src/cli/ai/chat/chat.ts`](https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/cli/ai/chat/chat.ts) (Interactive chat), [`apps/supercode-cli/server/src/agent/agent-service.ts`](https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/agent/agent-service.ts) (Agent runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Coding Agent CLI"]
  node_cli_entry["CLI entry<br/>Bun executable<br/>[index.ts]"]
  node_cli_dispatch["Command dispatch<br/>CLI commands<br/>[main.ts]"]
  node_chat["Interactive chat<br/>agent UI loop<br/>[chat.ts]"]
  node_agent{{"Agent runtime<br/>orchestration<br/>[agent-service.ts]"}}
  node_providers["Model providers<br/>provider adapters<br/>[provider.ts]"]
  node_tools{{"Tool registry &amp; executor<br/>local tool boundary<br/>[registry.ts]"}}
  node_permissions["Permission policy<br/>safety gate"]
  node_workspace_local["Developer workspace<br/>local files and shell"]
end

subgraph group_platform["Web Platform"]
  node_web_app["Dashboard &amp; public app<br/>Next.js App Router<br/>[layout.tsx]"]
  node_auth["Auth service<br/>Better Auth<br/>[server.ts]"]
  node_dashboard_db[("Dashboard database<br/>PostgreSQL / Prisma<br/>[schema.prisma]")]
  node_github_events["GitHub webhook<br/>event ingress<br/>[route.ts]"]
  node_ai_review["AI review job<br/>Inngest function<br/>[ai-review.ts]"]
  node_rag[("Pinecone RAG<br/>retrieval layer<br/>[index.ts]")]
end

subgraph group_surfaces["Other Product Surfaces"]
  node_terminal_client["Terminal browser client<br/>Next.js client<br/>[page.tsx]"]
  node_docs["Documentation site<br/>MDX Next.js site<br/>[page.tsx]"]
  node_superdesign["Superdesign<br/>design-generation app<br/>[route.ts]"]
  node_design_core["Design core<br/>shared prompts and systems<br/>[prompt-builder.ts]"]
end

subgraph group_training["Open Model Training"]
  node_openmodel_data["Training data preparation<br/>Python pipeline<br/>[prepare_dataset.py]"]
  node_openmodel_train{{"Qwen3 fine-tuning<br/>Tinker training job<br/>[train.py]"}}
end

node_workspace["Bun/Turbo workspace<br/>monorepo orchestration<br/>[package.json]"]

node_workspace -->|"builds and runs"| node_cli_entry
node_workspace -->|"orchestrates"| node_web_app
node_workspace -->|"orchestrates"| node_superdesign
node_cli_entry -->|"starts"| node_cli_dispatch
node_cli_dispatch -->|"opens chat"| node_chat
node_chat -->|"requests execution"| node_agent
node_agent -->|"sends model requests"| node_providers
node_agent -->|"selects tools"| node_tools
node_chat -->|"coordinates calls"| node_tools
node_tools -->|"checks mutations"| node_permissions
node_permissions -->|"authorizes access"| node_workspace_local
node_tools -->|"reads and changes"| node_workspace_local
node_web_app -->|"authenticates users"| node_auth
node_web_app -->|"persists product data"| node_dashboard_db
node_github_events -->|"triggers"| node_ai_review
node_ai_review -->|"retrieves context"| node_rag
node_terminal_client -->|"device approval"| node_auth
node_superdesign -->|"uses prompts and systems"| node_design_core
node_openmodel_data -->|"produces training data"| node_openmodel_train

click node_workspace "https://github.com/yashdev9274/supercli/blob/main/package.json"
click node_cli_entry "https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/index.ts"
click node_cli_dispatch "https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/cli/main.ts"
click node_chat "https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/cli/ai/chat/chat.ts"
click node_agent "https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/agent/agent-service.ts"
click node_providers "https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/cli/ai/provider.ts"
click node_tools "https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/tools/registry.ts"
click node_permissions "https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/tools/permission-manager.ts"
click node_web_app "https://github.com/yashdev9274/supercli/blob/main/apps/web/app/layout.tsx"
click node_auth "https://github.com/yashdev9274/supercli/blob/main/packages/auth/src/server.ts"
click node_dashboard_db "https://github.com/yashdev9274/supercli/blob/main/packages/db/prisma/schema.prisma"
click node_github_events "https://github.com/yashdev9274/supercli/blob/main/apps/web/app/api/webhooks/github/route.ts"
click node_ai_review "https://github.com/yashdev9274/supercli/blob/main/apps/web/inngest/functions/ai-review.ts"
click node_rag "https://github.com/yashdev9274/supercli/blob/main/apps/web/modules/pinecone/rag/index.ts"
click node_terminal_client "https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/client/app/device/page.tsx"
click node_docs "https://github.com/yashdev9274/supercli/blob/main/apps/docs/app/docs/%5Bslug%5D/page.tsx"
click node_superdesign "https://github.com/yashdev9274/supercli/blob/main/apps/superdesign/app/api/projects/%5Bid%5D/generate/route.ts"
click node_design_core "https://github.com/yashdev9274/supercli/blob/main/packages/design-core/src/prompt-builder.ts"
click node_openmodel_data "https://github.com/yashdev9274/supercli/blob/main/supercode-openmodel/training/data/prepare_dataset.py"
click node_openmodel_train "https://github.com/yashdev9274/supercli/blob/main/supercode-openmodel/training/tinker_qwen3/train.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli_entry,node_cli_dispatch,node_chat,node_agent,node_providers,node_tools,node_permissions,node_workspace_local toneBlue
class node_web_app,node_auth,node_dashboard_db,node_github_events,node_ai_review,node_rag toneAmber
class node_terminal_client,node_docs,node_superdesign,node_design_core toneMint
class node_openmodel_data,node_openmodel_train toneRose
class node_workspace toneNeutral
```

## Components

### Coding Agent CLI

- [CLI entry](https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/index.ts): Bun executable · `apps/supercode-cli/server/src/index.ts`
- [Command dispatch](https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/cli/main.ts): CLI commands · `apps/supercode-cli/server/src/cli/main.ts`
- [Interactive chat](https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/cli/ai/chat/chat.ts): agent UI loop · Builds context, streams output, and coordinates tool calls. · `apps/supercode-cli/server/src/cli/ai/chat/chat.ts`
- [Agent runtime](https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/agent/agent-service.ts): orchestration · Modes, subagents, prompts, and execution. · `apps/supercode-cli/server/src/agent/agent-service.ts`
- [Model providers](https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/cli/ai/provider.ts): provider adapters · Routes requests to hosted models and server proxy. · `apps/supercode-cli/server/src/cli/ai/provider.ts`
- [Tool registry & executor](https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/tools/registry.ts): local tool boundary · Filesystem, shell, web, delegation, and question tools. · `apps/supercode-cli/server/src/tools/registry.ts`
- [Permission policy](https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/server/src/tools/permission-manager.ts): safety gate · Approves sensitive or mutating tool operations. · `apps/supercode-cli/server/src/tools/permission-manager.ts`
- **Developer workspace**: local files and shell

### Web Platform

- [Dashboard & public app](https://github.com/yashdev9274/supercli/blob/main/apps/web/app/layout.tsx): Next.js App Router · `apps/web/app/layout.tsx`
- [Auth service](https://github.com/yashdev9274/supercli/blob/main/packages/auth/src/server.ts): Better Auth · `packages/auth/src/server.ts`
- [Dashboard database](https://github.com/yashdev9274/supercli/blob/main/packages/db/prisma/schema.prisma): PostgreSQL / Prisma · `packages/db/prisma/schema.prisma`
- [GitHub webhook](https://github.com/yashdev9274/supercli/blob/main/apps/web/app/api/webhooks/github/route.ts): event ingress · `apps/web/app/api/webhooks/github/route.ts`
- [AI review job](https://github.com/yashdev9274/supercli/blob/main/apps/web/inngest/functions/ai-review.ts): Inngest function · Asynchronously processes repository events. · `apps/web/inngest/functions/ai-review.ts`
- [Pinecone RAG](https://github.com/yashdev9274/supercli/blob/main/apps/web/modules/pinecone/rag/index.ts): retrieval layer · `apps/web/modules/pinecone/rag/index.ts`

### Other Product Surfaces

- [Terminal browser client](https://github.com/yashdev9274/supercli/blob/main/apps/supercode-cli/client/app/device/page.tsx): Next.js client · Handles device approval for the local CLI. · `apps/supercode-cli/client/app/device/page.tsx`
- [Documentation site](https://github.com/yashdev9274/supercli/blob/main/apps/docs/app/docs/%5Bslug%5D/page.tsx): MDX Next.js site · `apps/docs/app/docs/[slug]/page.tsx`
- [Superdesign](https://github.com/yashdev9274/supercli/blob/main/apps/superdesign/app/api/projects/%5Bid%5D/generate/route.ts): design-generation app · Authenticated project and artifact generation. · `apps/superdesign/app/api/projects/[id]/generate/route.ts`
- [Design core](https://github.com/yashdev9274/supercli/blob/main/packages/design-core/src/prompt-builder.ts): shared prompts and systems · `packages/design-core/src/prompt-builder.ts`

### Open Model Training

- [Training data preparation](https://github.com/yashdev9274/supercli/blob/main/supercode-openmodel/training/data/prepare_dataset.py): Python pipeline · `supercode-openmodel/training/data/prepare_dataset.py`
- [Qwen3 fine-tuning](https://github.com/yashdev9274/supercli/blob/main/supercode-openmodel/training/tinker_qwen3/train.py): Tinker training job · `supercode-openmodel/training/tinker_qwen3/train.py`

### Other components

- [Bun/Turbo workspace](https://github.com/yashdev9274/supercli/blob/main/package.json): monorepo orchestration · `package.json`

## Connections

- Bun/Turbo workspace → CLI entry: builds and runs
- Bun/Turbo workspace → Dashboard & public app: orchestrates
- Bun/Turbo workspace → Superdesign: orchestrates
- CLI entry → Command dispatch: starts
- Command dispatch → Interactive chat: opens chat
- Interactive chat → Agent runtime: requests execution
- Agent runtime → Model providers: sends model requests
- Agent runtime → Tool registry & executor: selects tools
- Interactive chat → Tool registry & executor: coordinates calls
- Tool registry & executor → Permission policy: checks mutations
- Permission policy → Developer workspace: authorizes access
- Tool registry & executor → Developer workspace: reads and changes
- Dashboard & public app → Auth service: authenticates users
- Dashboard & public app → Dashboard database: persists product data
- GitHub webhook → AI review job: triggers
- AI review job → Pinecone RAG: retrieves context
- Terminal browser client → Auth service: device approval
- Superdesign → Design core: uses prompts and systems
- Training data preparation → Qwen3 fine-tuning: produces training data
