How ramcharan-30/zero-dependency works
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: app.py Application workflow · archive.py .zc archive codec · file_dialog.py Native file chooser · errors.py Domain errors
Components 13
User interaction
- Application workflow · Coordinates compression and restoration workflows.
src/zcomp/app.py - Console interface
src/zcomp/cli.py - Native file chooser
src/zcomp/file_dialog.py
Archive protocol
- .zc archive codec · Frames metadata, algorithm ID, payload, and CRC32 validation.
src/zcomp/archive.py - CRC32 validation · Rejects corrupt or invalid reconstructed archive data.
src/zcomp/archive.py - Domain errors
src/zcomp/errors.py
Compression codecs
- Huffman codec
src/zcomp/huffman.py - Run-length codec
src/zcomp/rle.py - Bitstream I/O · Provides non-byte-aligned encoding and decoding.
src/zcomp/bitio.py
Other components
- Runtime entry
run.py - Build entry · Repository build flow separate from the interactive runtime.
build.py - Filesystem boundary · Owns output naming, locations, and host filesystem operations.
src/zcomp/filesystem.py - Compression metrics
src/zcomp/metrics.py
Connections 13
- 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