# aws/aws-sam-cli architecture

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

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

## Overview

AWS SAM CLI is a Python command-line tool for creating, locally testing, synchronizing, and deploying serverless applications. The principal workflow starts with a developer invoking a SAM command, which operates on application templates and code to produce local execution, cloud synchronization, or deployment results. Separate command families also initialize projects, configure pipelines, and retrieve logs and traces. The graph includes the documented capabilities and the sampled CLI, provider, and local-runtime layers; internal links are limited to relationships shown in the excerpts or source index.

Main entry points: [`samcli/local/apigw/local_apigw_service.py`](https://github.com/aws/aws-sam-cli/blob/develop/samcli/local/apigw/local_apigw_service.py) (Local API service), [`samcli/local/docker/manager.py`](https://github.com/aws/aws-sam-cli/blob/develop/samcli/local/docker/manager.py) (Container manager), [`samcli/commands/init/command.py`](https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/init/command.py) (Project initialization), [`samcli/commands/local/local.py`](https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/local/local.py) (Local commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and context"]
  node_cli_entry["SAM CLI entry<br/>[main.py]"]
  node_cli_context["Command context<br/>[context.py]"]
end

subgraph group_templates["Templates and providers"]
  node_init["Project initialization<br/>[command.py]"]
  node_template["Template utilities<br/>[template.py]"]
  node_provider["Application providers<br/>[provider.py]"]
  node_function_provider["Function provider"]
  node_stack_provider["Stack provider"]
end

subgraph group_local["Local testing"]
  node_local_commands["Local commands<br/>[local.py]"]
  node_local_api["Local API service"]
  node_local_lambda["Local Lambda service"]
  node_docker_manager["Container manager<br/>[manager.py]"]
  node_docker_client["Container client"]
end

subgraph group_delivery["Cloud delivery"]
  node_sync["Cloud synchronization<br/>[command.py]"]
  node_deploy["Application deployment<br/>[command.py]"]
  node_pipeline["Pipeline setup<br/>[command.py]"]
end

subgraph group_observability["Operations"]
  node_logs["Log retrieval<br/>[command.py]"]
  node_traces["Trace retrieval<br/>[command.py]"]
end

node_developer(("Developer"))

node_developer -->|"initializes projects"| node_init
node_developer -->|"tests locally"| node_local_commands
node_developer -->|"syncs changes"| node_sync
node_developer -->|"deploys templates"| node_deploy
node_developer -->|"creates pipelines"| node_pipeline
node_developer -->|"tails logs"| node_logs
node_developer -->|"views traces"| node_traces
node_local_api -->|"invokes function"| node_local_lambda
node_docker_manager -->|"manages containers"| node_docker_client

click node_cli_entry "https://github.com/aws/aws-sam-cli/blob/develop/samcli/cli/main.py"
click node_cli_context "https://github.com/aws/aws-sam-cli/blob/develop/samcli/cli/context.py"
click node_init "https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/init/command.py"
click node_template "https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/_utils/template.py"
click node_provider "https://github.com/aws/aws-sam-cli/blob/develop/samcli/lib/providers/provider.py"
click node_function_provider "https://github.com/aws/aws-sam-cli/blob/develop/samcli/lib/providers/sam_function_provider.py"
click node_stack_provider "https://github.com/aws/aws-sam-cli/blob/develop/samcli/lib/providers/sam_stack_provider.py"
click node_local_commands "https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/local/local.py"
click node_local_api "https://github.com/aws/aws-sam-cli/blob/develop/samcli/local/apigw/local_apigw_service.py"
click node_local_lambda "https://github.com/aws/aws-sam-cli/blob/develop/samcli/local/lambda_service/local_lambda_http_service.py"
click node_docker_manager "https://github.com/aws/aws-sam-cli/blob/develop/samcli/local/docker/manager.py"
click node_docker_client "https://github.com/aws/aws-sam-cli/blob/develop/samcli/local/docker/container_client.py"
click node_sync "https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/sync/command.py"
click node_deploy "https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/deploy/command.py"
click node_pipeline "https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/pipeline/init/core/command.py"
click node_logs "https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/logs/command.py"
click node_traces "https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/traces/command.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_context toneBlue
class node_init,node_template,node_provider,node_function_provider,node_stack_provider toneAmber
class node_local_commands,node_local_api,node_local_lambda,node_docker_manager,node_docker_client toneMint
class node_sync,node_deploy,node_pipeline toneRose
class node_logs,node_traces,node_developer toneIndigo
```

## Components

### CLI and context

- [SAM CLI entry](https://github.com/aws/aws-sam-cli/blob/develop/samcli/cli/main.py): `samcli/cli/main.py`
- [Command context](https://github.com/aws/aws-sam-cli/blob/develop/samcli/cli/context.py): `samcli/cli/context.py`

### Templates and providers

- [Project initialization](https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/init/command.py): `samcli/commands/init/command.py`
- [Template utilities](https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/_utils/template.py): `samcli/commands/_utils/template.py`
- [Application providers](https://github.com/aws/aws-sam-cli/blob/develop/samcli/lib/providers/provider.py): `samcli/lib/providers/provider.py`
- [Function provider](https://github.com/aws/aws-sam-cli/blob/develop/samcli/lib/providers/sam_function_provider.py): `samcli/lib/providers/sam_function_provider.py`
- [Stack provider](https://github.com/aws/aws-sam-cli/blob/develop/samcli/lib/providers/sam_stack_provider.py): `samcli/lib/providers/sam_stack_provider.py`

### Local testing

- [Local commands](https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/local/local.py): `samcli/commands/local/local.py`
- [Local API service](https://github.com/aws/aws-sam-cli/blob/develop/samcli/local/apigw/local_apigw_service.py): `samcli/local/apigw/local_apigw_service.py`
- [Local Lambda service](https://github.com/aws/aws-sam-cli/blob/develop/samcli/local/lambda_service/local_lambda_http_service.py): `samcli/local/lambda_service/local_lambda_http_service.py`
- [Container manager](https://github.com/aws/aws-sam-cli/blob/develop/samcli/local/docker/manager.py): `samcli/local/docker/manager.py`
- [Container client](https://github.com/aws/aws-sam-cli/blob/develop/samcli/local/docker/container_client.py): `samcli/local/docker/container_client.py`

### Cloud delivery

- [Cloud synchronization](https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/sync/command.py): `samcli/commands/sync/command.py`
- [Application deployment](https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/deploy/command.py): `samcli/commands/deploy/command.py`
- [Pipeline setup](https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/pipeline/init/core/command.py): `samcli/commands/pipeline/init/core/command.py`

### Operations

- [Log retrieval](https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/logs/command.py): `samcli/commands/logs/command.py`
- [Trace retrieval](https://github.com/aws/aws-sam-cli/blob/develop/samcli/commands/traces/command.py): `samcli/commands/traces/command.py`

### Other components

- **Developer**

## Connections

- Developer → Project initialization: initializes projects
- Developer → Local commands: tests locally
- Developer → Cloud synchronization: syncs changes
- Developer → Application deployment: deploys templates
- Developer → Pipeline setup: creates pipelines
- Developer → Log retrieval: tails logs
- Developer → Trace retrieval: views traces
- Local API service → Local Lambda service: invokes function (evidence: `samcli/local/apigw/local_apigw_service.py`)
- Container manager → Container client: manages containers (evidence: `samcli/local/docker/manager.py`)
