# chocolatey/choco architecture

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

- Interactive diagram: https://gitdiagram.com/chocolatey/choco
- Repository: https://github.com/chocolatey/choco

## Overview

Chocolatey is a Windows package manager exposed primarily through the `choco` CLI. The main user workflow is to invoke a package command, resolve package sources and metadata, then install, upgrade, or remove packages; the README also highlights refreshing the current shell environment after installation. The source index confirms key CLI, NuGet, configuration, and platform modules, but many implementations were not sampled, so uncertain internal links are omitted or shown as unverified.

Main entry points: [`src/chocolatey/infrastructure.app/services/NugetService.cs`](https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure.app/services/NugetService.cs) (Package operations), [`src/chocolatey.console/Program.cs`](https://github.com/chocolatey/choco/blob/develop/src/chocolatey.console/Program.cs) (CLI entry), [`src/Chocolatey.PowerShell/Commands/UpdateSessionEnvironmentCommand.cs`](https://github.com/chocolatey/choco/blob/develop/src/Chocolatey.PowerShell/Commands/UpdateSessionEnvironmentCommand.cs) (PowerShell commands), [`src/chocolatey/infrastructure.app/commands`](https://github.com/chocolatey/choco/tree/develop/src/chocolatey/infrastructure.app/commands) (Commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and configuration"]
  node_console["CLI entry<br/>[Program.cs]"]
  node_commands["Commands<br/>[commands]"]
  node_config["Configuration"]
  node_parameters["App parameters"]
end

subgraph group_packages["Package operations"]
  node_package_service["Package operations<br/>[NugetService.cs]"]
  node_sources["Package sources<br/>[SourceTypes.cs]"]
  node_package_result["Package results<br/>[PackageResult.cs]"]
  node_local_repo[("Local repository")]
  node_installers["Installer handlers<br/>[installers]"]
  node_templates["Package templates<br/>[templates]"]
  node_nuget_tools["Pack and push<br/>[nuget]"]
end

subgraph group_runtime["Runtime services"]
  node_filesystem["Filesystem API<br/>[IFileSystem.cs]"]
  node_dotnet_files["File operations"]
  node_platform["Platform detection<br/>[Platform.cs]"]
  node_events["Event manager<br/>[EventManager.cs]"]
  node_logging["Logging<br/>[Log.cs]"]
  node_strings["String resources<br/>[StringResources.cs]"]
end

subgraph group_shell["Shell integration"]
  node_ps_commands["PowerShell commands"]
  node_environment_helper["Environment helper"]
end

node_user(("CLI user"))
node_shell(("PowerShell session"))
node_community_feed[("Package repository")]

node_user -->|"invokes"| node_console
node_console -.->|"dispatches"| node_commands
node_console -->|"configures"| node_config
node_console -->|"reads"| node_parameters
node_commands -.->|"runs package actions"| node_package_service
node_package_service -->|"reads"| node_config
node_package_service -->|"uses sources"| node_sources
node_package_service -.->|"produces results"| node_package_result
node_package_service -.->|"uses repository"| node_local_repo
node_package_service -.->|"runs installers"| node_installers
node_package_service -.->|"retrieves packages"| node_community_feed
node_user -->|"chooses packages"| node_community_feed
node_nuget_tools -.->|"publishes packages"| node_community_feed
node_filesystem -->|"implemented by"| node_dotnet_files
node_platform -->|"initializes"| node_filesystem
node_console -->|"bootstraps runtime"| node_platform
node_console -->|"configures"| node_logging
node_package_service -->|"references"| node_strings
node_ps_commands -->|"uses"| node_environment_helper
node_shell -->|"runs refreshenv"| node_ps_commands
node_ps_commands -->|"updates environment"| node_shell

click node_console "https://github.com/chocolatey/choco/blob/develop/src/chocolatey.console/Program.cs"
click node_commands "https://github.com/chocolatey/choco/tree/develop/src/chocolatey/infrastructure.app/commands"
click node_config "https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs"
click node_parameters "https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure.app/ApplicationParameters.cs"
click node_package_service "https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure.app/services/NugetService.cs"
click node_sources "https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure.app/domain/SourceTypes.cs"
click node_package_result "https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure/results/PackageResult.cs"
click node_local_repo "https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure.app/nuget/ChocolateyLocalPackageRepository.cs"
click node_installers "https://github.com/chocolatey/choco/tree/develop/src/chocolatey/infrastructure.app/domain/installers"
click node_templates "https://github.com/chocolatey/choco/tree/develop/src/chocolatey/infrastructure.app/templates"
click node_nuget_tools "https://github.com/chocolatey/choco/tree/develop/src/chocolatey/infrastructure.app/nuget"
click node_filesystem "https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure/filesystem/IFileSystem.cs"
click node_dotnet_files "https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs"
click node_platform "https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure/platforms/Platform.cs"
click node_events "https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure/events/EventManager.cs"
click node_logging "https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure/logging/Log.cs"
click node_strings "https://github.com/chocolatey/choco/blob/develop/src/chocolatey/StringResources.cs"
click node_ps_commands "https://github.com/chocolatey/choco/blob/develop/src/Chocolatey.PowerShell/Commands/UpdateSessionEnvironmentCommand.cs"
click node_environment_helper "https://github.com/chocolatey/choco/blob/develop/src/Chocolatey.PowerShell/Helpers/EnvironmentHelper.cs"

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_console,node_commands,node_config,node_parameters,node_user toneBlue
class node_package_service,node_sources,node_package_result,node_local_repo,node_installers,node_templates,node_nuget_tools,node_community_feed toneAmber
class node_filesystem,node_dotnet_files,node_platform,node_events,node_logging,node_strings toneMint
class node_ps_commands,node_environment_helper toneRose
class node_shell toneIndigo
```

## Components

### CLI and configuration

- [CLI entry](https://github.com/chocolatey/choco/blob/develop/src/chocolatey.console/Program.cs): `src/chocolatey.console/Program.cs`
- [Commands](https://github.com/chocolatey/choco/tree/develop/src/chocolatey/infrastructure.app/commands): `src/chocolatey/infrastructure.app/commands`
- [Configuration](https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs): `src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs`
- [App parameters](https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure.app/ApplicationParameters.cs): `src/chocolatey/infrastructure.app/ApplicationParameters.cs`

### Package operations

- [Package operations](https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure.app/services/NugetService.cs): `src/chocolatey/infrastructure.app/services/NugetService.cs`
- [Package sources](https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure.app/domain/SourceTypes.cs): `src/chocolatey/infrastructure.app/domain/SourceTypes.cs`
- [Package results](https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure/results/PackageResult.cs): `src/chocolatey/infrastructure/results/PackageResult.cs`
- [Local repository](https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure.app/nuget/ChocolateyLocalPackageRepository.cs): `src/chocolatey/infrastructure.app/nuget/ChocolateyLocalPackageRepository.cs`
- [Installer handlers](https://github.com/chocolatey/choco/tree/develop/src/chocolatey/infrastructure.app/domain/installers): `src/chocolatey/infrastructure.app/domain/installers`
- [Package templates](https://github.com/chocolatey/choco/tree/develop/src/chocolatey/infrastructure.app/templates): `src/chocolatey/infrastructure.app/templates`
- [Pack and push](https://github.com/chocolatey/choco/tree/develop/src/chocolatey/infrastructure.app/nuget): `src/chocolatey/infrastructure.app/nuget`

### Runtime services

- [Filesystem API](https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure/filesystem/IFileSystem.cs): `src/chocolatey/infrastructure/filesystem/IFileSystem.cs`
- [File operations](https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs): `src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs`
- [Platform detection](https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure/platforms/Platform.cs): `src/chocolatey/infrastructure/platforms/Platform.cs`
- [Event manager](https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure/events/EventManager.cs): `src/chocolatey/infrastructure/events/EventManager.cs`
- [Logging](https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure/logging/Log.cs): `src/chocolatey/infrastructure/logging/Log.cs`
- [String resources](https://github.com/chocolatey/choco/blob/develop/src/chocolatey/StringResources.cs): `src/chocolatey/StringResources.cs`

### Shell integration

- [PowerShell commands](https://github.com/chocolatey/choco/blob/develop/src/Chocolatey.PowerShell/Commands/UpdateSessionEnvironmentCommand.cs): `src/Chocolatey.PowerShell/Commands/UpdateSessionEnvironmentCommand.cs`
- [Environment helper](https://github.com/chocolatey/choco/blob/develop/src/Chocolatey.PowerShell/Helpers/EnvironmentHelper.cs): `src/Chocolatey.PowerShell/Helpers/EnvironmentHelper.cs`

### Other components

- **CLI user**
- **PowerShell session**
- **Package repository**

## Connections

- CLI user → CLI entry: invokes (evidence: `README.md`)
- CLI entry → Commands: dispatches
- CLI entry → Configuration: configures (evidence: `src/chocolatey.console/Program.cs`)
- CLI entry → App parameters: reads (evidence: `src/chocolatey.console/Program.cs`)
- Commands → Package operations: runs package actions
- Package operations → Configuration: reads (evidence: `src/chocolatey/infrastructure.app/services/NugetService.cs`)
- Package operations → Package sources: uses sources (evidence: `src/chocolatey/infrastructure.app/services/NugetService.cs`)
- Package operations → Package results: produces results (evidence: `src/chocolatey/infrastructure.app/services/NugetService.cs`)
- Package operations → Local repository: uses repository
- Package operations → Installer handlers: runs installers
- Package operations → Package repository: retrieves packages
- CLI user → Package repository: chooses packages (evidence: `README.md`)
- Pack and push → Package repository: publishes packages
- Filesystem API → File operations: implemented by (evidence: `src/chocolatey/infrastructure/platforms/Platform.cs`)
- Platform detection → Filesystem API: initializes (evidence: `src/chocolatey/infrastructure/platforms/Platform.cs`)
- CLI entry → Platform detection: bootstraps runtime (evidence: `src/chocolatey.console/Program.cs`)
- CLI entry → Logging: configures (evidence: `src/chocolatey.console/Program.cs`)
- Package operations → String resources: references (evidence: `src/chocolatey/infrastructure.app/services/NugetService.cs`)
- PowerShell commands → Environment helper: uses (evidence: `src/Chocolatey.PowerShell/Commands/UpdateSessionEnvironmentCommand.cs`)
- PowerShell session → PowerShell commands: runs refreshenv (evidence: `README.md`)
- PowerShell commands → PowerShell session: updates environment (evidence: `README.md`)
