{"id":24764944,"url":"https://github.com/letsmakecakes/huffman-compression","last_synced_at":"2025-08-18T18:09:40.108Z","repository":{"id":274296554,"uuid":"919525292","full_name":"letsmakecakes/huffman-compression","owner":"letsmakecakes","description":"A high-performance text file compression tool implemented in Go using Huffman coding. This tool provides lossless compression for text files by utilizing variable-length prefix coding based on character frequencies.","archived":false,"fork":false,"pushed_at":"2025-03-12T16:31:56.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T16:36:27.290Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/letsmakecakes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-20T14:52:13.000Z","updated_at":"2025-03-12T16:31:59.000Z","dependencies_parsed_at":"2025-01-26T12:19:17.718Z","dependency_job_id":"060c69f4-0455-4520-b51c-89bb44eaee20","html_url":"https://github.com/letsmakecakes/huffman-compression","commit_stats":null,"previous_names":["letsmakecakes/huffman-compression"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/letsmakecakes/huffman-compression","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsmakecakes%2Fhuffman-compression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsmakecakes%2Fhuffman-compression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsmakecakes%2Fhuffman-compression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsmakecakes%2Fhuffman-compression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/letsmakecakes","download_url":"https://codeload.github.com/letsmakecakes/huffman-compression/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsmakecakes%2Fhuffman-compression/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271035991,"owners_count":24688534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-28T22:36:20.279Z","updated_at":"2025-08-18T18:09:39.904Z","avatar_url":"https://github.com/letsmakecakes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Huffman Compression Tool\n\nA high-performance text file compression tool implemented in Go using Huffman coding. This tool provides lossless compression for text files by utilizing variable-length prefix coding based on character frequencies.\n\n## Features\n\n- Efficient text file compression using Huffman coding\n- Lossless compression and decompression\n- High-performance I/O with buffered operations\n- Memory-efficient bit manipulation\n- Comprehensive error handling\n- Unit tested components\n- Command-line interface\n- Progress indication for large files\n\n## Installation\n\nEnsure you have Go 1.21 or later installed on your system.\n\n```bash\n# Clone the repository\ngit clone https://github.com/letsmakecakes/huffman-compression\ncd huffman-compression\n\n# Build the project\nmake build\n\n# Run tests\nmake test\n```\n\n## Usage\n\nThe tool provides two main operations: compression and decompression.\n\n### Basic Commands\n\n```bash\n# Compress a file\n./huffman -input input.txt -output compressed.huf -mode compress\n\n# Decompress a file\n./huffman -input compressed.huf -output decompressed.txt -mode decompress\n```\n\n### Command Line Options\n\n- `-input`: Path to the input file (required)\n- `-output`: Path to the output file (required)\n- `-mode`: Operation mode - \"compress\" or \"decompress\" (default: \"compress\")\n- `-verbose`: Enable verbose logging (optional)\n\n## Project Structure\n\n```\nhuffman-compression/\n├── cmd/                  # Command-line application\n├── internal/             # Internal packages\n│   ├── codec/           # Encoding/decoding logic\n│   ├── frequency/       # Character frequency analysis\n│   ├── huffman/         # Huffman tree implementation\n│   ├── io/              # File I/O operations\n│   └── models/          # Shared types and interfaces\n├── pkg/                 # Public packages\n│   └── bitutils/        # Bit manipulation utilities\n└── test/                # Test files and integration tests\n```\n\n## How It Works\n\n1. **Frequency Analysis**: The tool first analyzes the input file to count the frequency of each character.\n\n2. **Tree Construction**: A Huffman tree is built using these frequencies, with more frequent characters placed closer to the root for shorter codes.\n\n3. **Code Generation**: Variable-length prefix codes are generated for each character based on their position in the tree.\n\n4. **Compression**:\n    - The Huffman tree structure is written to the output file header\n    - The input text is encoded using the generated codes\n    - Bits are packed efficiently into bytes for storage\n\n5. **Decompression**:\n    - The header is read to reconstruct the Huffman tree\n    - The compressed data is read bit by bit\n    - The original text is reconstructed using the tree\n\n## Performance\n\nThe tool implements several optimizations for better performance:\n\n- Buffered I/O operations\n- Efficient bit manipulation\n- CPU cache-friendly data structures\n- Minimal memory allocations\n- Parallel processing for large files\n\n## Example\n\n```go\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n    // Sample compression\n    inputFile := \"les-miserables.txt\"\n    compressedFile := \"compressed.huf\"\n    \n    // Compress\n    if err := compress(inputFile, compressedFile); err != nil {\n        fmt.Printf(\"Compression error: %v\\n\", err)\n        return\n    }\n    \n    // Show compression ratio\n    PrintCompressionStats(inputFile, compressedFile)\n}\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. Make sure to:\n\n1. Add tests for any new features\n2. Follow the existing code style\n3. Update documentation as needed\n4. Add comments for non-obvious code sections\n\n## Testing\n\nRun the test suite:\n\n```bash\nmake test\n```\n\nRun benchmarks:\n\n```bash\nmake bench\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Credits\n\nThis implementation is inspired by:\n- David Huffman's original 1952 paper \"A Method for the Construction of Minimum-Redundancy Codes\"\n- Modern performance optimization techniques for Go applications\n- Best practices from the Go community\n\n## Author\n\nAdwaith Rajeev\n\n## Acknowledgments\n\nSpecial thanks to:\n- The Go team for their excellent standard library\n- The open source community for their valuable feedback\n- Everyone who has contributed to the project\n\n## Project Status\n\nActive development - Bug reports and feature requests are welcome!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletsmakecakes%2Fhuffman-compression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fletsmakecakes%2Fhuffman-compression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletsmakecakes%2Fhuffman-compression/lists"}