# pypa/pipenv architecture

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

- Interactive diagram: https://gitdiagram.com/pypa/pipenv
- Repository: https://github.com/pypa/pipenv

## Overview

Pipenv manages a project’s Python environment and dependencies: users invoke CLI commands that update the Pipfile, resolve and lock dependency versions, install packages into a virtualenv, and can then inspect or run the environment. The graph also captures documented project discovery, shell/.env support, dependency checks, and the bundled pip installation layer. Edges use README statements or SOURCE INDEX references; several internal implementation details are unsampled, so uncertain links are omitted.

Main entry points: [`pipenv/cli/command.py`](https://github.com/pypa/pipenv/blob/main/pipenv/cli/command.py) (CLI dispatcher), [`pipenv/project.py`](https://github.com/pypa/pipenv/blob/main/pipenv/project.py) (Project manager), [`pipenv/routines/install.py`](https://github.com/pypa/pipenv/blob/main/pipenv/routines/install.py) (Install routine), [`pipenv/routines/lock.py`](https://github.com/pypa/pipenv/blob/main/pipenv/routines/lock.py) (Lock routine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Command interface"]
  node_cli["CLI dispatcher<br/>[command.py]"]
end

subgraph group_project["Project state"]
  node_project_state["Project manager<br/>[project.py]"]
  node_pipfile["Pipfile and lock<br/>[pipfile.py]"]
  node_env_settings["Environment settings<br/>[environments.py]"]
end

subgraph group_deps["Dependency workflow"]
  node_install["Install routine<br/>[install.py]"]
  node_lock["Lock routine<br/>[lock.py]"]
  node_check["Dependency checks<br/>[check.py]"]
  node_graph["Dependency graph<br/>[graph.py]"]
  node_audit["Security audit<br/>[audit.py]"]
  node_dep_model["Dependency conversion<br/>[dependencies.py]"]
  node_resolver["Dependency resolver<br/>[core.py]"]
  node_resolver_cli["Resolver entry<br/>[main.py]"]
  node_pip_install["Bundled pip install<br/>[install.py]"]
end

subgraph group_runtime["Environment runtime"]
  node_virtualenv["Virtualenv management<br/>[virtualenv.py]"]
  node_environment["Python environment<br/>[environment.py]"]
  node_shell["Shell integration<br/>[shell.py]"]
  node_shell_utils["Shell utilities<br/>[shell.py]"]
end

node_user(("Developer"))
node_package_index(("Package index"))
node_python_runtime(("Python runtime"))

node_user -->|"runs commands"| node_cli
node_cli -->|"dispatches"| node_install
node_cli -->|"dispatches"| node_lock
node_cli -->|"dispatches"| node_check
node_cli -->|"dispatches"| node_graph
node_cli -->|"dispatches"| node_audit
node_install -->|"invokes"| node_lock
node_install -->|"updates declarations"| node_pipfile
node_lock -->|"writes lock data"| node_pipfile
node_lock -.->|"resolves dependencies"| node_resolver_cli
node_resolver_cli -->|"uses resolver"| node_resolver
node_resolver -->|"uses dependency data"| node_dep_model
node_install -.->|"installs packages"| node_pip_install
node_pip_install -.->|"fetches packages"| node_package_index
node_project_state -->|"loads project files"| node_pipfile
node_project_state -->|"uses dependency helpers"| node_dep_model
node_project_state -->|"discovers environment"| node_virtualenv
node_virtualenv -->|"selects interpreter"| node_python_runtime
node_virtualenv -->|"provides environment"| node_environment
node_cli -->|"dispatches"| node_shell
node_shell -->|"uses shell helpers"| node_shell_utils
node_env_settings -->|"configures settings"| node_project_state
node_check -.->|"checks declarations"| node_pipfile
node_graph -.->|"inspects installed packages"| node_environment
node_audit -.->|"checks vulnerabilities"| node_package_index
node_project_state -->|"reads environment options"| node_env_settings
node_user -->|"selects project"| node_project_state
node_environment -.->|"loads .env support"| node_shell_utils

click node_cli "https://github.com/pypa/pipenv/blob/main/pipenv/cli/command.py"
click node_install "https://github.com/pypa/pipenv/blob/main/pipenv/routines/install.py"
click node_lock "https://github.com/pypa/pipenv/blob/main/pipenv/routines/lock.py"
click node_check "https://github.com/pypa/pipenv/blob/main/pipenv/routines/check.py"
click node_graph "https://github.com/pypa/pipenv/blob/main/pipenv/routines/graph.py"
click node_audit "https://github.com/pypa/pipenv/blob/main/pipenv/routines/audit.py"
click node_project_state "https://github.com/pypa/pipenv/blob/main/pipenv/project.py"
click node_pipfile "https://github.com/pypa/pipenv/blob/main/pipenv/utils/pipfile.py"
click node_dep_model "https://github.com/pypa/pipenv/blob/main/pipenv/utils/dependencies.py"
click node_resolver "https://github.com/pypa/pipenv/blob/main/pipenv/resolver/core.py"
click node_resolver_cli "https://github.com/pypa/pipenv/blob/main/pipenv/resolver/main.py"
click node_pip_install "https://github.com/pypa/pipenv/blob/main/pipenv/patched/pip/_internal/commands/install.py"
click node_virtualenv "https://github.com/pypa/pipenv/blob/main/pipenv/utils/virtualenv.py"
click node_environment "https://github.com/pypa/pipenv/blob/main/pipenv/environment.py"
click node_shell "https://github.com/pypa/pipenv/blob/main/pipenv/routines/shell.py"
click node_shell_utils "https://github.com/pypa/pipenv/blob/main/pipenv/utils/shell.py"
click node_env_settings "https://github.com/pypa/pipenv/blob/main/pipenv/environments.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 toneBlue
class node_project_state,node_pipfile,node_env_settings toneAmber
class node_install,node_lock,node_check,node_graph,node_audit,node_dep_model,node_resolver,node_resolver_cli,node_pip_install toneMint
class node_virtualenv,node_environment,node_shell,node_shell_utils toneRose
class node_user,node_package_index,node_python_runtime toneIndigo
```

## Components

### Command interface

- [CLI dispatcher](https://github.com/pypa/pipenv/blob/main/pipenv/cli/command.py): `pipenv/cli/command.py`

### Project state

- [Project manager](https://github.com/pypa/pipenv/blob/main/pipenv/project.py): `pipenv/project.py`
- [Pipfile and lock](https://github.com/pypa/pipenv/blob/main/pipenv/utils/pipfile.py): `pipenv/utils/pipfile.py`
- [Environment settings](https://github.com/pypa/pipenv/blob/main/pipenv/environments.py): `pipenv/environments.py`

### Dependency workflow

- [Install routine](https://github.com/pypa/pipenv/blob/main/pipenv/routines/install.py): `pipenv/routines/install.py`
- [Lock routine](https://github.com/pypa/pipenv/blob/main/pipenv/routines/lock.py): `pipenv/routines/lock.py`
- [Dependency checks](https://github.com/pypa/pipenv/blob/main/pipenv/routines/check.py): `pipenv/routines/check.py`
- [Dependency graph](https://github.com/pypa/pipenv/blob/main/pipenv/routines/graph.py): `pipenv/routines/graph.py`
- [Security audit](https://github.com/pypa/pipenv/blob/main/pipenv/routines/audit.py): `pipenv/routines/audit.py`
- [Dependency conversion](https://github.com/pypa/pipenv/blob/main/pipenv/utils/dependencies.py): `pipenv/utils/dependencies.py`
- [Dependency resolver](https://github.com/pypa/pipenv/blob/main/pipenv/resolver/core.py): `pipenv/resolver/core.py`
- [Resolver entry](https://github.com/pypa/pipenv/blob/main/pipenv/resolver/main.py): `pipenv/resolver/main.py`
- [Bundled pip install](https://github.com/pypa/pipenv/blob/main/pipenv/patched/pip/_internal/commands/install.py): `pipenv/patched/pip/_internal/commands/install.py`

### Environment runtime

- [Virtualenv management](https://github.com/pypa/pipenv/blob/main/pipenv/utils/virtualenv.py): `pipenv/utils/virtualenv.py`
- [Python environment](https://github.com/pypa/pipenv/blob/main/pipenv/environment.py): `pipenv/environment.py`
- [Shell integration](https://github.com/pypa/pipenv/blob/main/pipenv/routines/shell.py): `pipenv/routines/shell.py`
- [Shell utilities](https://github.com/pypa/pipenv/blob/main/pipenv/utils/shell.py): `pipenv/utils/shell.py`

### Other components

- **Developer**
- **Package index**
- **Python runtime**

## Connections

- Developer → CLI dispatcher: runs commands
- CLI dispatcher → Install routine: dispatches (evidence: `pipenv/cli/command.py`)
- CLI dispatcher → Lock routine: dispatches (evidence: `pipenv/cli/command.py`)
- CLI dispatcher → Dependency checks: dispatches (evidence: `pipenv/cli/command.py`)
- CLI dispatcher → Dependency graph: dispatches (evidence: `pipenv/cli/command.py`)
- CLI dispatcher → Security audit: dispatches (evidence: `pipenv/cli/command.py`)
- Install routine → Lock routine: invokes (evidence: `pipenv/routines/install.py`)
- Install routine → Pipfile and lock: updates declarations (evidence: `pipenv/routines/install.py`)
- Lock routine → Pipfile and lock: writes lock data
- Lock routine → Resolver entry: resolves dependencies
- Resolver entry → Dependency resolver: uses resolver (evidence: `pipenv/resolver/main.py`)
- Dependency resolver → Dependency conversion: uses dependency data (evidence: `pipenv/utils/resolver.py`)
- Install routine → Bundled pip install: installs packages
- Bundled pip install → Package index: fetches packages
- Project manager → Pipfile and lock: loads project files (evidence: `pipenv/project.py`)
- Project manager → Dependency conversion: uses dependency helpers (evidence: `pipenv/project.py`)
- Project manager → Virtualenv management: discovers environment (evidence: `pipenv/project.py`)
- Virtualenv management → Python runtime: selects interpreter
- Virtualenv management → Python environment: provides environment (evidence: `pipenv/environment.py`)
- CLI dispatcher → Shell integration: dispatches (evidence: `pipenv/cli/command.py`)
- Shell integration → Shell utilities: uses shell helpers
- Environment settings → Project manager: configures settings (evidence: `pipenv/project.py`)
- Dependency checks → Pipfile and lock: checks declarations
- Dependency graph → Python environment: inspects installed packages
- Security audit → Package index: checks vulnerabilities
- Project manager → Environment settings: reads environment options (evidence: `pipenv/project.py`)
- Developer → Project manager: selects project
- Python environment → Shell utilities: loads .env support (evidence: `pipenv/environment.py`)
