# bhangun/coto architecture

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

- Interactive diagram: https://gitdiagram.com/bhangun/coto
- Repository: https://github.com/bhangun/coto

## Overview

Coto is a Go CLI for combining files, renaming paths, and extracting code blocks. The main user workflow runs through the CLI entry point: combination filters and processes files before writing text/JSON/XML/Markdown output, while subcommands dispatch to rename or extraction. Extraction selects language plugins through a registry, extracts blocks, and optionally writes results/reports. README documents configuration, compression, parallel processing, and progress; unsampled implementation details are represented conservatively.

Main entry points: [`cmd/extract/registry.go`](https://github.com/bhangun/coto/blob/main/cmd/extract/registry.go) (Extractor registry), [`pkg/extractor/types.go`](https://github.com/bhangun/coto/blob/main/pkg/extractor/types.go) (Code block model), [`cmd/main/main.go`](https://github.com/bhangun/coto/blob/main/cmd/main/main.go) (Combine workflow), [`cmd/extract/extract.go`](https://github.com/bhangun/coto/blob/main/cmd/extract/extract.go) (Extract command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflows"]
  node_entry["Command entry<br/>[main.go]"]
  node_rename["Rename paths<br/>[rename.go]"]
end

subgraph group_combine["File combination"]
  node_combine_flow["Combine workflow<br/>[main.go]"]
  node_config["JSON configuration<br/>[main.go]"]
  node_discovery["File discovery<br/>[main.go]"]
  node_processing["File processing<br/>[main.go]"]
  node_output["Format and compression<br/>[main.go]"]
  node_destination["Output file"]
end

subgraph group_extract["Code extraction"]
  node_extract_cmd["Extract command<br/>[extract.go]"]
  node_registry["Extractor registry<br/>[registry.go]"]
  node_extract_core["Extraction engine<br/>[extractors.go]"]
  node_block_model["Code block model<br/>[types.go]"]
  node_extracted_output["Extracted files and report<br/>[extract.go]"]
end

subgraph group_plugins["Extraction plugins"]
  node_go_plugin["Go extractor<br/>[golang.go]"]
  node_js_plugin["JavaScript extractor<br/>[javascript.go]"]
  node_python_plugin["Python extractor<br/>[python.go]"]
  node_java_plugin["Java extractor<br/>[java.go]"]
  node_dart_plugin["Dart extractor<br/>[dart.go]"]
  node_rust_plugin["Rust extractor<br/>[rust.go]"]
  node_generic_plugin["Generic extractor<br/>[extractors.go]"]
end

node_user(("CLI user"))

node_user -->|"invokes"| node_entry
node_entry -->|"runs default"| node_combine_flow
node_entry -->|"dispatches extract"| node_extract_cmd
node_entry -->|"dispatches rename"| node_rename
node_user -->|"requests rename"| node_rename
node_combine_flow -->|"loads optionally"| node_config
node_combine_flow -->|"discovers files"| node_discovery
node_combine_flow -->|"processes files"| node_processing
node_combine_flow -->|"writes output"| node_output
node_output -->|"writes"| node_destination
node_user -->|"requests extraction"| node_extract_cmd
node_extract_cmd -->|"registers plugins"| node_registry
node_extract_cmd -->|"processes files"| node_extract_core
node_extract_cmd -->|"writes and reports"| node_extracted_output
node_extract_core -->|"produces blocks"| node_block_model
node_registry -->|"registers"| node_go_plugin
node_registry -->|"registers"| node_js_plugin
node_registry -->|"registers"| node_python_plugin
node_registry -->|"registers"| node_java_plugin
node_registry -->|"registers"| node_dart_plugin
node_registry -->|"registers"| node_rust_plugin
node_registry -->|"registers fallback"| node_generic_plugin
node_extract_core -->|"selects extractor"| node_registry
node_go_plugin -->|"emits blocks"| node_block_model
node_js_plugin -->|"emits blocks"| node_block_model
node_python_plugin -->|"emits blocks"| node_block_model
node_java_plugin -->|"emits blocks"| node_block_model
node_dart_plugin -->|"emits blocks"| node_block_model
node_rust_plugin -->|"emits blocks"| node_block_model

click node_entry "https://github.com/bhangun/coto/blob/main/cmd/main/main.go"
click node_rename "https://github.com/bhangun/coto/blob/main/cmd/rename/rename.go"
click node_combine_flow "https://github.com/bhangun/coto/blob/main/cmd/main/main.go"
click node_config "https://github.com/bhangun/coto/blob/main/cmd/main/main.go"
click node_discovery "https://github.com/bhangun/coto/blob/main/cmd/main/main.go"
click node_processing "https://github.com/bhangun/coto/blob/main/cmd/main/main.go"
click node_output "https://github.com/bhangun/coto/blob/main/cmd/main/main.go"
click node_extract_cmd "https://github.com/bhangun/coto/blob/main/cmd/extract/extract.go"
click node_registry "https://github.com/bhangun/coto/blob/main/cmd/extract/registry.go"
click node_extract_core "https://github.com/bhangun/coto/blob/main/cmd/extract/extractors.go"
click node_block_model "https://github.com/bhangun/coto/blob/main/pkg/extractor/types.go"
click node_extracted_output "https://github.com/bhangun/coto/blob/main/cmd/extract/extract.go"
click node_go_plugin "https://github.com/bhangun/coto/blob/main/pkg/plugins/golang.go"
click node_js_plugin "https://github.com/bhangun/coto/blob/main/pkg/plugins/javascript.go"
click node_python_plugin "https://github.com/bhangun/coto/blob/main/pkg/plugins/python.go"
click node_java_plugin "https://github.com/bhangun/coto/blob/main/pkg/plugins/java.go"
click node_dart_plugin "https://github.com/bhangun/coto/blob/main/pkg/plugins/dart.go"
click node_rust_plugin "https://github.com/bhangun/coto/blob/main/pkg/plugins/rust.go"
click node_generic_plugin "https://github.com/bhangun/coto/blob/main/cmd/extract/extractors.go"

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_entry,node_rename,node_user toneBlue
class node_combine_flow,node_config,node_discovery,node_processing,node_output,node_destination toneAmber
class node_extract_cmd,node_registry,node_extract_core,node_block_model,node_extracted_output toneMint
class node_go_plugin,node_js_plugin,node_python_plugin,node_java_plugin,node_dart_plugin,node_rust_plugin,node_generic_plugin toneRose
```

## Components

### CLI workflows

- [Command entry](https://github.com/bhangun/coto/blob/main/cmd/main/main.go): `cmd/main/main.go`
- [Rename paths](https://github.com/bhangun/coto/blob/main/cmd/rename/rename.go): `cmd/rename/rename.go`

### File combination

- [Combine workflow](https://github.com/bhangun/coto/blob/main/cmd/main/main.go): `cmd/main/main.go`
- [JSON configuration](https://github.com/bhangun/coto/blob/main/cmd/main/main.go): `cmd/main/main.go`
- [File discovery](https://github.com/bhangun/coto/blob/main/cmd/main/main.go): `cmd/main/main.go`
- [File processing](https://github.com/bhangun/coto/blob/main/cmd/main/main.go): `cmd/main/main.go`
- [Format and compression](https://github.com/bhangun/coto/blob/main/cmd/main/main.go): `cmd/main/main.go`
- **Output file**

### Code extraction

- [Extract command](https://github.com/bhangun/coto/blob/main/cmd/extract/extract.go): `cmd/extract/extract.go`
- [Extractor registry](https://github.com/bhangun/coto/blob/main/cmd/extract/registry.go): `cmd/extract/registry.go`
- [Extraction engine](https://github.com/bhangun/coto/blob/main/cmd/extract/extractors.go): `cmd/extract/extractors.go`
- [Code block model](https://github.com/bhangun/coto/blob/main/pkg/extractor/types.go): `pkg/extractor/types.go`
- [Extracted files and report](https://github.com/bhangun/coto/blob/main/cmd/extract/extract.go): `cmd/extract/extract.go`

### Extraction plugins

- [Go extractor](https://github.com/bhangun/coto/blob/main/pkg/plugins/golang.go): `pkg/plugins/golang.go`
- [JavaScript extractor](https://github.com/bhangun/coto/blob/main/pkg/plugins/javascript.go): `pkg/plugins/javascript.go`
- [Python extractor](https://github.com/bhangun/coto/blob/main/pkg/plugins/python.go): `pkg/plugins/python.go`
- [Java extractor](https://github.com/bhangun/coto/blob/main/pkg/plugins/java.go): `pkg/plugins/java.go`
- [Dart extractor](https://github.com/bhangun/coto/blob/main/pkg/plugins/dart.go): `pkg/plugins/dart.go`
- [Rust extractor](https://github.com/bhangun/coto/blob/main/pkg/plugins/rust.go): `pkg/plugins/rust.go`
- [Generic extractor](https://github.com/bhangun/coto/blob/main/cmd/extract/extractors.go): `cmd/extract/extractors.go`

### Other components

- **CLI user**

## Connections

- CLI user → Command entry: invokes (evidence: `README.md`)
- Command entry → Combine workflow: runs default (evidence: `cmd/main/main.go`)
- Command entry → Extract command: dispatches extract (evidence: `cmd/main/main.go`)
- Command entry → Rename paths: dispatches rename (evidence: `cmd/main/main.go`)
- CLI user → Rename paths: requests rename (evidence: `README.md`)
- Combine workflow → JSON configuration: loads optionally (evidence: `cmd/main/main.go`)
- Combine workflow → File discovery: discovers files (evidence: `cmd/main/main.go`)
- Combine workflow → File processing: processes files (evidence: `cmd/main/main.go`)
- Combine workflow → Format and compression: writes output (evidence: `cmd/main/main.go`)
- Format and compression → Output file: writes (evidence: `README.md`)
- CLI user → Extract command: requests extraction (evidence: `README.md`)
- Extract command → Extractor registry: registers plugins (evidence: `cmd/extract/extract.go`)
- Extract command → Extraction engine: processes files (evidence: `cmd/extract/extract.go`)
- Extract command → Extracted files and report: writes and reports (evidence: `cmd/extract/extract.go`)
- Extraction engine → Code block model: produces blocks (evidence: `cmd/extract/extractors.go`)
- Extractor registry → Go extractor: registers (evidence: `cmd/extract/registry.go`)
- Extractor registry → JavaScript extractor: registers (evidence: `cmd/extract/registry.go`)
- Extractor registry → Python extractor: registers (evidence: `cmd/extract/registry.go`)
- Extractor registry → Java extractor: registers (evidence: `cmd/extract/registry.go`)
- Extractor registry → Dart extractor: registers (evidence: `cmd/extract/registry.go`)
- Extractor registry → Rust extractor: registers (evidence: `cmd/extract/registry.go`)
- Extractor registry → Generic extractor: registers fallback (evidence: `cmd/extract/registry.go`)
- Extraction engine → Extractor registry: selects extractor
- Go extractor → Code block model: emits blocks (evidence: `pkg/plugins/golang.go`)
- JavaScript extractor → Code block model: emits blocks (evidence: `pkg/plugins/javascript.go`)
- Python extractor → Code block model: emits blocks (evidence: `pkg/plugins/python.go`)
- Java extractor → Code block model: emits blocks (evidence: `pkg/plugins/java.go`)
- Dart extractor → Code block model: emits blocks (evidence: `pkg/plugins/dart.go`)
- Rust extractor → Code block model: emits blocks (evidence: `pkg/plugins/rust.go`)
