# ramcharan-30/zero-dependency architecture

> Architecture diagram of the GitHub repository ramcharan-30/zero-dependency, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ramcharan-30/zero-dependency
- Repository: https://github.com/ramcharan-30/zero-dependency

## Overview

#### Purpose and entry points
Zero-Compress is a standard-library-only Python desktop-style utility for losslessly compressing one file into a custom `.zc` archive and restoring it with integrity validation. Runtime starts at `run.py`, which launches the package application flow in `src/zcomp/app.py`; interactive command handling is separated into `src/zcomp/cli.py`.

#### User interaction and orchestration
`src/zcomp/app.py` owns the top-level compress/decompress workflow: solicit an operation, choose an input file, select an algorithm, invoke archive processing, and report outcomes. `src/zcomp/cli.py` provides console prompts/menu behavior, while `src/zcomp/file_dialog.py` bridges to the native `tkinter` file chooser. This keeps UI concerns outside compression and archive code.

#### File selection and output boundary
Input selection is handled through `src/zcomp/file_dialog.py`, including archive-oriented selection for decompression. `src/zcomp/filesystem.py` centralizes filesystem operations and output naming/location behavior, isolating host paths and Downloads-directory handling from the archive codec. Application code should pass paths/data across this boundary rather than embed platform filesystem logic.

#### Archive container protocol
`src/zcomp/archive.py` defines the `.zc` binary archive read/write pipeline. It packages and interprets archive-level concerns: format identification, selected algorithm ID, file metadata, compressed payload, and CRC32 integrity information. On extraction it validates the container and checksum before accepting reconstructed output; invalid/corrupt data is surfaced through `src/zcomp/errors.py`.

#### Compression algorithm boundary
The archive layer dispatches algorithm-specific payload encoding and decoding to:
- `src/zcomp/huffman.py` for Huffman coding.
- `src/zcomp/rle.py` for run-length encoding.

Both operate beneath the container protocol: they produce or consume compressed payload representations, while `src/zcomp/archive.py` retains responsibility for algorithm selection, metadata framing, and validation.

#### Bit-level encoding substrate
`src/zcomp/bitio.py` provides bit-oriented read/write primitives used by formats that need non-byte-aligned codes, principally Huffman payload construction and decoding. This is a low-level binary boundary: higher layers should not replicate bit packing or interpret bitstream state directly.

#### Integrity, errors, and observability
`src/zcomp/archive.py` performs CRC32-based corruption detection over restored/archive-managed data. `src/zcomp/errors.py` provides domain-specific failure signaling across malformed archives, decoding, and validation failures, allowing `src/zcomp/app.py` to present controlled user-facing errors. `src/zcomp/metrics.py` supports compression-result measurement/reporting without coupling metrics to codec implementation.

#### Runtime and dependencies
The project targets Python 3.10+ and intentionally uses only the Python standard library. Its material host integration is `tkinter` for native file dialogs; otherwise execution is local filesystem I/O with no network services, database, package runtime, or external infrastructure. `build.py` is a repository-level build entry distinct from the interactive runtime.

Main entry points: [`src/zcomp/app.py`](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/app.py) (Application workflow), [`src/zcomp/archive.py`](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/archive.py) (.zc archive codec), [`src/zcomp/file_dialog.py`](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/file_dialog.py) (Native file chooser), [`src/zcomp/errors.py`](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/errors.py) (Domain errors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interaction"]
  node_app["Application workflow<br/>orchestrator<br/>[app.py]"]
  node_cli["Console interface<br/>interactive CLI<br/>[cli.py]"]
  node_file_dialog["Native file chooser<br/>tkinter adapter<br/>[file_dialog.py]"]
end

subgraph group_container["Archive protocol"]
  node_archive[".zc archive codec<br/>container protocol<br/>[archive.py]"]
  node_integrity["CRC32 validation<br/>integrity stage<br/>[archive.py]"]
  node_errors["Domain errors<br/>failure model<br/>[errors.py]"]
end

subgraph group_codecs["Compression codecs"]
  node_huffman["Huffman codec<br/>payload codec<br/>[huffman.py]"]
  node_rle["Run-length codec<br/>payload codec<br/>[rle.py]"]
  node_bitio["Bitstream I/O<br/>bit primitives<br/>[bitio.py]"]
end

node_run(("Runtime entry<br/>Python launcher<br/>[run.py]"))
node_build["Build entry<br/>Python build script<br/>[build.py]"]
node_filesystem["Filesystem boundary<br/>path and output I/O<br/>[filesystem.py]"]
node_metrics["Compression metrics<br/>reporting<br/>[metrics.py]"]

node_run -->|"launches"| node_app
node_app -->|"prompts and reports"| node_cli
node_app -->|"selects input"| node_file_dialog
node_file_dialog -->|"returns paths"| node_filesystem
node_app -->|"reads and writes files"| node_filesystem
node_app -->|"compresses or extracts"| node_archive
node_app -->|"reports results"| node_metrics
node_archive -->|"dispatches payload codec"| node_huffman
node_archive -->|"dispatches payload codec"| node_rle
node_huffman -->|"packs and reads bits"| node_bitio
node_archive -->|"validates restored data"| node_integrity
node_archive -->|"raises malformed or corrupt failures"| node_errors
node_errors -.->|"controlled user-facing failures"| node_app

click node_run "https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/run.py"
click node_build "https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/build.py"
click node_app "https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/app.py"
click node_cli "https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/cli.py"
click node_file_dialog "https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/file_dialog.py"
click node_filesystem "https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/filesystem.py"
click node_metrics "https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/metrics.py"
click node_archive "https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/archive.py"
click node_integrity "https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/archive.py"
click node_errors "https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/errors.py"
click node_huffman "https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/huffman.py"
click node_rle "https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/rle.py"
click node_bitio "https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/bitio.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_app,node_cli,node_file_dialog toneBlue
class node_archive,node_integrity,node_errors toneAmber
class node_huffman,node_rle,node_bitio toneMint
class node_run,node_build,node_filesystem,node_metrics toneNeutral
```

## Components

### User interaction

- [Application workflow](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/app.py): orchestrator · Coordinates compression and restoration workflows. · `src/zcomp/app.py`
- [Console interface](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/cli.py): interactive CLI · `src/zcomp/cli.py`
- [Native file chooser](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/file_dialog.py): tkinter adapter · `src/zcomp/file_dialog.py`

### Archive protocol

- [.zc archive codec](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/archive.py): container protocol · Frames metadata, algorithm ID, payload, and CRC32 validation. · `src/zcomp/archive.py`
- [CRC32 validation](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/archive.py): integrity stage · Rejects corrupt or invalid reconstructed archive data. · `src/zcomp/archive.py`
- [Domain errors](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/errors.py): failure model · `src/zcomp/errors.py`

### Compression codecs

- [Huffman codec](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/huffman.py): payload codec · `src/zcomp/huffman.py`
- [Run-length codec](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/rle.py): payload codec · `src/zcomp/rle.py`
- [Bitstream I/O](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/bitio.py): bit primitives · Provides non-byte-aligned encoding and decoding. · `src/zcomp/bitio.py`

### Other components

- [Runtime entry](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/run.py): Python launcher · `run.py`
- [Build entry](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/build.py): Python build script · Repository build flow separate from the interactive runtime. · `build.py`
- [Filesystem boundary](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/filesystem.py): path and output I/O · Owns output naming, locations, and host filesystem operations. · `src/zcomp/filesystem.py`
- [Compression metrics](https://github.com/ramcharan-30/zero-dependency/blob/feature/foundation/src/zcomp/metrics.py): reporting · `src/zcomp/metrics.py`

## Connections

- Runtime entry → Application workflow: launches
- Application workflow → Console interface: prompts and reports
- Application workflow → Native file chooser: selects input
- Native file chooser → Filesystem boundary: returns paths
- Application workflow → Filesystem boundary: reads and writes files
- Application workflow → .zc archive codec: compresses or extracts
- Application workflow → Compression metrics: reports results
- .zc archive codec → Huffman codec: dispatches payload codec
- .zc archive codec → Run-length codec: dispatches payload codec
- Huffman codec → Bitstream I/O: packs and reads bits
- .zc archive codec → CRC32 validation: validates restored data
- .zc archive codec → Domain errors: raises malformed or corrupt failures
- Domain errors → Application workflow: controlled user-facing failures
