# sveltejs/cli architecture

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

- Interactive diagram: https://gitdiagram.com/sveltejs/cli
- Repository: https://github.com/sveltejs/cli

## Overview

##### Main Components Organization

- CLI Core System
- -ons System
- Migration System
- Creation System
- Tooling Infrastructure

##### Component Relationships

a) CLI Core System (Central Hub):
- It to command handlers:
- create (sv-create)
- (sv-add)
- check (sv-check)
- migrate (sv-migrate)

b) -ons System (Right Side):
- Drizzle
- ESLint
- Lucia
- MDSvex
- Playwright
- etc.

c) Creation System (Left Side):
- Templates container:
- Demo template
- Library template
- Minimal template
- To shared resources
- Link to CLI create command

d) Migration System (Bottom):
- Migration types:
- App state migrations
- Package migrations
- Routes migrations
- Svelte version migrations
- To CLI migrate command

e) Tooling Infrastructure (Top):
- AST Tooling
- Core Tooling
- Clack Prompts (CLI interface)

##### Implementation Details

Technical aspects:
- Package manager integration
- File system operations
- Command processing flow
- -on resolution system
- Template processing pipeline

##### Data Flow Indicators

Interactions:
- Command input → CLI Core → Specific handlers
- Template selection → Creation system → Project output
- -on selection → Add-on system → Project modification
- Migration source → Migration system → Updated code

##### Additional Elements

Supporting components:
- Configuration management
- Testing infrastructure
- Documentation system
- Community integration points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph CLI["CLI Core System"]
        CLI_CORE["CLI Core"]:::core
        CMD_ADD["Add Command"]:::command
        CMD_CHECK["Check Command"]:::command
        CMD_CREATE["Create Command"]:::command
        CMD_MIGRATE["Migrate Command"]:::command
        
        CLI_CORE --> CMD_ADD
        CLI_CORE --> CMD_CHECK
        CLI_CORE --> CMD_CREATE
        CLI_CORE --> CMD_MIGRATE
    end

    subgraph ADDONS["Add-ons System"]
        OFFICIAL["Official Add-ons"]:::addon
        COMMUNITY["Community Add-ons"]:::addon
        ADDON_CONFIG["Add-on Configuration"]:::config
        
        OFFICIAL --> ADDON_CONFIG
        COMMUNITY --> ADDON_CONFIG
    end

    subgraph CREATE["Creation System"]
        TEMPLATES["Templates"]:::template
        DEMO["Demo Template"]:::template
        LIBRARY["Library Template"]:::template
        MINIMAL["Minimal Template"]:::template
        SHARED["Shared Resources"]:::shared
        
        TEMPLATES --> DEMO
        TEMPLATES --> LIBRARY
        TEMPLATES --> MINIMAL
        TEMPLATES --> SHARED
    end

    subgraph MIGRATE["Migration System"]
        MIG_CORE["Migration Core"]:::migration
        APP_STATE["App State Migrations"]:::migration
        PKG_MIG["Package Migrations"]:::migration
        ROUTES_MIG["Routes Migrations"]:::migration
        SVELTE4["Svelte 4 Migrations"]:::migration
        SVELTE5["Svelte 5 Migrations"]:::migration
        
        MIG_CORE --> APP_STATE
        MIG_CORE --> PKG_MIG
        MIG_CORE --> ROUTES_MIG
        MIG_CORE --> SVELTE4
        MIG_CORE --> SVELTE5
    end

    subgraph TOOLS["Tooling Infrastructure"]
        AST["AST Tooling"]:::tool
        CORE["Core Tooling"]:::tool
        CLACK["Clack Prompts"]:::tool
    end

    %% Connections between components
    CLI_CORE --> ADDONS
    CLI_CORE --> CREATE
    CLI_CORE --> MIGRATE
    TOOLS --> CLI

    %% Click events
    click CLI_CORE "https://github.com/sveltejs/cli/tree/main/packages/cli"
    click CMD_ADD "https://github.com/sveltejs/cli/tree/main/packages/cli/commands/add"
    click CMD_CHECK "https://github.com/sveltejs/cli/blob/main/packages/cli/commands/check.ts"
    click CMD_CREATE "https://github.com/sveltejs/cli/blob/main/packages/cli/commands/create.ts"
    click CMD_MIGRATE "https://github.com/sveltejs/cli/blob/main/packages/cli/commands/migrate.ts"
    click OFFICIAL "https://github.com/sveltejs/cli/tree/main/packages/addons"
    click COMMUNITY "https://github.com/sveltejs/cli/tree/main/community-addons"
    click ADDON_CONFIG "https://github.com/sveltejs/cli/tree/main/packages/addons/_config"
    click TEMPLATES "https://github.com/sveltejs/cli/tree/main/packages/create/templates"
    click DEMO "https://github.com/sveltejs/cli/tree/main/packages/create/templates/demo"
    click LIBRARY "https://github.com/sveltejs/cli/tree/main/packages/create/templates/library"
    click MINIMAL "https://github.com/sveltejs/cli/tree/main/packages/create/templates/minimal"
    click SHARED "https://github.com/sveltejs/cli/tree/main/packages/create/shared"
    click MIG_CORE "https://github.com/sveltejs/cli/tree/main/packages/migrate"
    click APP_STATE "https://github.com/sveltejs/cli/tree/main/packages/migrate/migrations/app-state"
    click PKG_MIG "https://github.com/sveltejs/cli/tree/main/packages/migrate/migrations/package"
    click ROUTES_MIG "https://github.com/sveltejs/cli/tree/main/packages/migrate/migrations/routes"
    click SVELTE4 "https://github.com/sveltejs/cli/tree/main/packages/migrate/migrations/svelte-4"
    click SVELTE5 "https://github.com/sveltejs/cli/tree/main/packages/migrate/migrations/svelte-5"
    click AST "https://github.com/sveltejs/cli/tree/main/packages/ast-tooling"
    click CORE "https://github.com/sveltejs/cli/tree/main/packages/core"
    click CLACK "https://github.com/sveltejs/cli/tree/main/packages/clack-core"

    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef command fill:#90CAF9,stroke:#64B5F6,color:black
    classDef addon fill:#FFD54F,stroke:#FFC107,color:black
    classDef template fill:#81C784,stroke:#4CAF50,color:black
    classDef migration fill:#CE93D8,stroke:#9C27B0,color:white
    classDef tool fill:#A1887F,stroke:#795548,color:white
    classDef config fill:#FFB74D,stroke:#FF9800,color:black
    classDef shared fill:#90A4AE,stroke:#607D8B,color:white

    %% Legend
    subgraph Legend
        L_CORE["Core Component"]:::core
        L_CMD["Command"]:::command
        L_ADDON["Add-on"]:::addon
        L_TEMPLATE["Template"]:::template
        L_MIGRATION["Migration"]:::migration
        L_TOOL["Tool"]:::tool
    end
```
