# aspadax/requirements-txt-generator architecture

> Architecture diagram of the GitHub repository aspadax/requirements-txt-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aspadax/requirements-txt-generator
- Repository: https://github.com/aspadax/requirements-txt-generator

## Overview

This is a Conda-focused CLI that generates a Python project’s requirements.txt without querying package registries. The workflow validates command-line options, locates the environment’s package metadata, scans project Python files for imports, excludes standard-library names, matches imports to locally installed packages and versions, then writes the result. The graph preserves these distinct stages and the standard-library data input. Relationships are based on the shown main, package, Conda, and writer code; other environment integrations are not evidenced.

Main entry points: [`src/main.rs`](https://github.com/aspadax/requirements-txt-generator/blob/main/src/main.rs) (Generation workflow), [`src/cli.rs`](https://github.com/aspadax/requirements-txt-generator/blob/main/src/cli.rs) (CLI arguments), [`src/virtual_envs/conda.rs`](https://github.com/aspadax/requirements-txt-generator/blob/main/src/virtual_envs/conda.rs) (Conda detection and paths), [`src/python/std.rs`](https://github.com/aspadax/requirements-txt-generator/blob/main/src/python/std.rs) (Standard-library loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Inputs and options"]
  node_cli["CLI arguments<br/>[cli.rs]"]
  node_orchestrator["Generation workflow<br/>[main.rs]"]
end

subgraph group_environment["Conda environment"]
  node_conda_access["Conda detection and paths<br/>[conda.rs]"]
  node_environment_packages[("Conda site-packages")]
  node_package_trait["Environment package interface<br/>[traits.rs]"]
end

subgraph group_analysis["Dependency analysis"]
  node_standard_list["Standard-library list"]
  node_standard_loader["Standard-library loader<br/>[std.rs]"]
  node_project_files["Python file discovery<br/>[package.rs]"]
  node_file_reader["Python source reader<br/>[package.rs]"]
  node_import_parser["Import extraction<br/>[package.rs]"]
  node_package_matcher["Package matching and versions<br/>[package.rs]"]
end

subgraph group_output["Requirements output"]
  node_requirements_writer["Requirements writer<br/>[writer.rs]"]
  node_requirements_file["requirements.txt"]
end

node_user(("Tool user"))

node_user -->|"provides options"| node_cli
node_cli -->|"parses and validates"| node_orchestrator
node_orchestrator -->|"loads names"| node_standard_loader
node_standard_loader -->|"reads JSON"| node_standard_list
node_orchestrator -->|"locates environment"| node_conda_access
node_conda_access -->|"reads metadata"| node_environment_packages
node_orchestrator -->|"scans project"| node_project_files
node_orchestrator -->|"reads discovered files"| node_file_reader
node_orchestrator -->|"extracts imports"| node_import_parser
node_orchestrator -->|"matches dependencies"| node_package_matcher
node_package_matcher -->|"reads package names and versions"| node_package_trait
node_orchestrator -->|"writes result"| node_requirements_writer
node_requirements_writer -->|"creates file"| node_requirements_file

click node_cli "https://github.com/aspadax/requirements-txt-generator/blob/main/src/cli.rs"
click node_orchestrator "https://github.com/aspadax/requirements-txt-generator/blob/main/src/main.rs"
click node_standard_list "https://github.com/aspadax/requirements-txt-generator/blob/main/python_std_libraries.json"
click node_standard_loader "https://github.com/aspadax/requirements-txt-generator/blob/main/src/python/std.rs"
click node_conda_access "https://github.com/aspadax/requirements-txt-generator/blob/main/src/virtual_envs/conda.rs"
click node_package_trait "https://github.com/aspadax/requirements-txt-generator/blob/main/src/virtual_envs/traits.rs"
click node_project_files "https://github.com/aspadax/requirements-txt-generator/blob/main/src/python/package.rs"
click node_file_reader "https://github.com/aspadax/requirements-txt-generator/blob/main/src/python/package.rs"
click node_import_parser "https://github.com/aspadax/requirements-txt-generator/blob/main/src/python/package.rs"
click node_package_matcher "https://github.com/aspadax/requirements-txt-generator/blob/main/src/python/package.rs"
click node_requirements_writer "https://github.com/aspadax/requirements-txt-generator/blob/main/src/writer.rs"

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,node_orchestrator,node_user toneBlue
class node_conda_access,node_environment_packages,node_package_trait toneAmber
class node_standard_list,node_standard_loader,node_project_files,node_file_reader,node_import_parser,node_package_matcher toneMint
class node_requirements_writer,node_requirements_file toneRose
```

## Components

### Inputs and options

- [CLI arguments](https://github.com/aspadax/requirements-txt-generator/blob/main/src/cli.rs): `src/cli.rs`
- [Generation workflow](https://github.com/aspadax/requirements-txt-generator/blob/main/src/main.rs): `src/main.rs`

### Conda environment

- [Conda detection and paths](https://github.com/aspadax/requirements-txt-generator/blob/main/src/virtual_envs/conda.rs): `src/virtual_envs/conda.rs`
- **Conda site-packages**
- [Environment package interface](https://github.com/aspadax/requirements-txt-generator/blob/main/src/virtual_envs/traits.rs): `src/virtual_envs/traits.rs`

### Dependency analysis

- [Standard-library list](https://github.com/aspadax/requirements-txt-generator/blob/main/python_std_libraries.json): `python_std_libraries.json`
- [Standard-library loader](https://github.com/aspadax/requirements-txt-generator/blob/main/src/python/std.rs): `src/python/std.rs`
- [Python file discovery](https://github.com/aspadax/requirements-txt-generator/blob/main/src/python/package.rs): `src/python/package.rs`
- [Python source reader](https://github.com/aspadax/requirements-txt-generator/blob/main/src/python/package.rs): `src/python/package.rs`
- [Import extraction](https://github.com/aspadax/requirements-txt-generator/blob/main/src/python/package.rs): `src/python/package.rs`
- [Package matching and versions](https://github.com/aspadax/requirements-txt-generator/blob/main/src/python/package.rs): `src/python/package.rs`

### Requirements output

- [Requirements writer](https://github.com/aspadax/requirements-txt-generator/blob/main/src/writer.rs): `src/writer.rs`
- **requirements.txt**

### Other components

- **Tool user**

## Connections

- Tool user → CLI arguments: provides options (evidence: `README.md`)
- CLI arguments → Generation workflow: parses and validates (evidence: `src/main.rs`)
- Generation workflow → Standard-library loader: loads names (evidence: `src/main.rs`)
- Standard-library loader → Standard-library list: reads JSON (evidence: `src/python/std.rs`)
- Generation workflow → Conda detection and paths: locates environment (evidence: `src/main.rs`)
- Conda detection and paths → Conda site-packages: reads metadata (evidence: `src/virtual_envs/conda.rs`)
- Generation workflow → Python file discovery: scans project (evidence: `src/main.rs`)
- Generation workflow → Python source reader: reads discovered files (evidence: `src/main.rs`)
- Generation workflow → Import extraction: extracts imports (evidence: `src/main.rs`)
- Generation workflow → Package matching and versions: matches dependencies (evidence: `src/main.rs`)
- Package matching and versions → Environment package interface: reads package names and versions (evidence: `src/python/package.rs`)
- Generation workflow → Requirements writer: writes result (evidence: `src/main.rs`)
- Requirements writer → requirements.txt: creates file (evidence: `src/writer.rs`)
