# attaditya/cutypy architecture

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

- Interactive diagram: https://gitdiagram.com/attaditya/cutypy
- Repository: https://github.com/attaditya/cutypy

## Overview

CutyPy is a lightweight Python formatter. Its main workflow parses CLI arguments, starts the engine, discovers files, then either checks or formats each file; formatting writes changed content back to disk. The README also documents import sorting, indentation, blank-line normalization, line endings, trailing-space cleanup, EOF newlines, and CI check mode. The graph groups related rules to keep the workflow readable. Some subsystems are represented by their exact source directories because their individual implementations were not excerpted; those links rely on the source index or README.

Main entry points: [`cutypy/engine/worker.py`](https://github.com/attaditya/cutypy/blob/main/cutypy/engine/worker.py) (Workflow and file I/O), [`cutypy/core/main.py`](https://github.com/attaditya/cutypy/blob/main/cutypy/core/main.py) (CLI entrypoint), [`cutypy/engine/pipelines/solve.py`](https://github.com/attaditya/cutypy/blob/main/cutypy/engine/pipelines/solve.py) (Solve pipeline), [`cutypy/models/content.py`](https://github.com/attaditya/cutypy/blob/main/cutypy/models/content.py) (Content state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and orchestration"]
  node_args["Argument parsing<br/>[args_handler.py]"]
  node_version["Version handling<br/>[version.py]"]
  node_entry["CLI entrypoint<br/>[main.py]"]
end

subgraph group_engine["File processing"]
  node_worker["Workflow and file I/O<br/>[worker.py]"]
  node_discovery["Path discovery<br/>[discovery.py]"]
  node_check["Check pipeline<br/>[check.py]"]
  node_checker["Line-length checker"]
  node_solver_pipeline["Solve pipeline<br/>[solve.py]"]
end

subgraph group_format["Formatting rules"]
  node_compact_expand["String preservation"]
  node_rules["Formatting rules"]
end

subgraph group_models["Content and arguments"]
  node_content["Content state<br/>[content.py]"]
  node_arguments["Argument state<br/>[args.py]"]
end

node_user(("CLI user"))
node_filesystem["Source files"]

node_user -->|"invokes"| node_entry
node_entry -->|"parses arguments"| node_args
node_entry -->|"checks version"| node_version
node_entry -->|"starts engine"| node_worker
node_args -->|"creates"| node_arguments
node_version -->|"reads options"| node_arguments
node_worker -->|"reads paths"| node_arguments
node_worker -->|"discovers paths"| node_discovery
node_worker -->|"runs check"| node_check
node_worker -->|"runs formatting"| node_solver_pipeline
node_worker -->|"reads and writes"| node_filesystem
node_worker -->|"creates content"| node_content
node_check -->|"checks content"| node_checker
node_solver_pipeline -->|"preserves strings"| node_compact_expand
node_solver_pipeline -->|"applies rules"| node_rules
node_compact_expand -->|"transforms content"| node_content
node_rules -->|"transforms content"| node_content

click node_args "https://github.com/attaditya/cutypy/blob/main/cutypy/cli/args_handler.py"
click node_version "https://github.com/attaditya/cutypy/blob/main/cutypy/cli/version.py"
click node_entry "https://github.com/attaditya/cutypy/blob/main/cutypy/core/main.py"
click node_worker "https://github.com/attaditya/cutypy/blob/main/cutypy/engine/worker.py"
click node_discovery "https://github.com/attaditya/cutypy/blob/main/cutypy/engine/discovery.py"
click node_check "https://github.com/attaditya/cutypy/blob/main/cutypy/engine/pipelines/check.py"
click node_checker "https://github.com/attaditya/cutypy/blob/main/cutypy/checker/check_line_length.py"
click node_solver_pipeline "https://github.com/attaditya/cutypy/blob/main/cutypy/engine/pipelines/solve.py"
click node_compact_expand "https://github.com/attaditya/cutypy/tree/main/cutypy/common"
click node_rules "https://github.com/attaditya/cutypy/tree/main/cutypy/solver"
click node_content "https://github.com/attaditya/cutypy/blob/main/cutypy/models/content.py"
click node_arguments "https://github.com/attaditya/cutypy/blob/main/cutypy/models/args.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_args,node_version,node_entry,node_user toneBlue
class node_worker,node_discovery,node_check,node_checker,node_solver_pipeline toneAmber
class node_compact_expand,node_rules toneMint
class node_content,node_arguments toneRose
class node_filesystem toneIndigo
```

## Components

### CLI and orchestration

- [Argument parsing](https://github.com/attaditya/cutypy/blob/main/cutypy/cli/args_handler.py): `cutypy/cli/args_handler.py`
- [Version handling](https://github.com/attaditya/cutypy/blob/main/cutypy/cli/version.py): `cutypy/cli/version.py`
- [CLI entrypoint](https://github.com/attaditya/cutypy/blob/main/cutypy/core/main.py): `cutypy/core/main.py`

### File processing

- [Workflow and file I/O](https://github.com/attaditya/cutypy/blob/main/cutypy/engine/worker.py): `cutypy/engine/worker.py`
- [Path discovery](https://github.com/attaditya/cutypy/blob/main/cutypy/engine/discovery.py): `cutypy/engine/discovery.py`
- [Check pipeline](https://github.com/attaditya/cutypy/blob/main/cutypy/engine/pipelines/check.py): `cutypy/engine/pipelines/check.py`
- [Line-length checker](https://github.com/attaditya/cutypy/blob/main/cutypy/checker/check_line_length.py): `cutypy/checker/check_line_length.py`
- [Solve pipeline](https://github.com/attaditya/cutypy/blob/main/cutypy/engine/pipelines/solve.py): `cutypy/engine/pipelines/solve.py`

### Formatting rules

- [String preservation](https://github.com/attaditya/cutypy/tree/main/cutypy/common): `cutypy/common`
- [Formatting rules](https://github.com/attaditya/cutypy/tree/main/cutypy/solver): `cutypy/solver`

### Content and arguments

- [Content state](https://github.com/attaditya/cutypy/blob/main/cutypy/models/content.py): `cutypy/models/content.py`
- [Argument state](https://github.com/attaditya/cutypy/blob/main/cutypy/models/args.py): `cutypy/models/args.py`

### Other components

- **CLI user**
- **Source files**

## Connections

- CLI user → CLI entrypoint: invokes (evidence: `README.md`)
- CLI entrypoint → Argument parsing: parses arguments (evidence: `cutypy/core/main.py`)
- CLI entrypoint → Version handling: checks version (evidence: `cutypy/core/main.py`)
- CLI entrypoint → Workflow and file I/O: starts engine (evidence: `cutypy/core/main.py`)
- Argument parsing → Argument state: creates (evidence: `cutypy/cli/args_handler.py`)
- Version handling → Argument state: reads options (evidence: `cutypy/cli/version.py`)
- Workflow and file I/O → Argument state: reads paths (evidence: `cutypy/engine/worker.py`)
- Workflow and file I/O → Path discovery: discovers paths (evidence: `cutypy/engine/worker.py`)
- Workflow and file I/O → Check pipeline: runs check (evidence: `cutypy/engine/worker.py`)
- Workflow and file I/O → Solve pipeline: runs formatting (evidence: `cutypy/engine/worker.py`)
- Workflow and file I/O → Source files: reads and writes (evidence: `cutypy/engine/worker.py`)
- Workflow and file I/O → Content state: creates content (evidence: `cutypy/engine/worker.py`)
- Check pipeline → Line-length checker: checks content (evidence: `cutypy/engine/pipelines/check.py`)
- Solve pipeline → String preservation: preserves strings (evidence: `cutypy/engine/pipelines/solve.py`)
- Solve pipeline → Formatting rules: applies rules (evidence: `cutypy/engine/pipelines/solve.py`)
- String preservation → Content state: transforms content (evidence: `cutypy/common/compact.py`)
- Formatting rules → Content state: transforms content (evidence: `cutypy/solver/fix_import_order.py`)
