A sophisticated file compression and indexing system that combines optimal lossless compression with lightning-fast data retrieval using advanced tree structures.
| Feature | Description | Performance |
|---|---|---|
| ๐ง Huffman Compression | Optimal lossless compression algorithm | 40-60% size reduction |
| ๐ณ Dual Tree Indexing | B-Tree + Red-Black Tree structures | O(log n) search time |
| ๐ฅ๏ธ Modern GUI | Professional PyQt5 interface | Real-time visualization |
| โก CLI Interface | Command-line for automation | Batch processing support |
| ๐ Performance Analytics | Compression metrics & benchmarks | Built-in profiling tools |
| ๐ Visual Trees | Interactive tree structure display | Educational & debugging |
graph TB
A[๐ฅ๏ธ User Interface Layer] --> B[๐ฏ Application Controller]
B --> C[๐ฆ Compression Engine]
B --> D[๐๏ธ Storage Engine]
B --> E[๐ Search Engine]
C --> F[๐ Huffman Algorithm]
C --> G[๐ Frequency Analyzer]
C --> H[๐ณ Tree Builder]
D --> I[๐
ฑ๏ธ B-Tree Index]
D --> J[๐ด Red-Black Tree]
D --> K[๐พ File Manager]
E --> L[๐ Unified Search]
E --> M[๐ Results Handler]
style A fill:#e1f5fe
style F fill:#f3e5f5
style I fill:#e8f5e8
style J fill:#ffebee
+------------------------------+
| CLI Interface |
+------------------------------+
| |
v v
+----------------+ +----------------+
| Compression | | Storage |
| Module | | Module |
+----------------+ +----------------+
| - Huffman Tree | | - B/B+ Tree |
| - Encoder | | - Red-Black |
| - Decoder | | Tree |
| - Analyzer | | - Index Mgmt |
+----------------+ +----------------+
| |
v v
+------------------------------+
| File System Access |
+------------------------------+
graph TB
CLI[๐ฅ๏ธ CLI Interface] --> CM[๐ฆ Compression Module]
CLI --> SM[๐๏ธ Storage Module]
CM --> HT[๐ณ Huffman Tree]
CM --> EN[๐ง Encoder]
CM --> DE[๐ Decoder]
CM --> AN[๐ Analyzer]
SM --> BT[๐
ฑ๏ธ B/B+ Tree]
SM --> RB[๐ด Red-Black Tree]
SM --> IM[๐ Index Management]
HT --> FS[๐พ File System Access]
EN --> FS
DE --> FS
AN --> FS
BT --> FS
RB --> FS
IM --> FS
style CLI fill:#e1f5fe
style CM fill:#f3e5f5
style SM fill:#e8f5e8
style FS fill:#fff3e0
๐ธ Visual Reference: View Original Architecture Diagram
- Python 3.8 or higher
- PyQt5 for GUI interface
-
Clone the repository
git clone https://github.com/Mehmetbaruk/file-compression-indexing-system.git cd file-compression-indexing-system -
Install dependencies
pip install -r requirements.txt
-
Launch the application
# GUI Interface (Recommended) python gui_launcher.py # CLI Interface python gui_launcher.py --cli # Direct main module python main.py
Huffman Coding Implementation
- Frequency Analysis: Dynamic character frequency calculation
- Tree Construction: Optimal binary tree generation using priority queues
- Bit-Level Encoding: Custom binary representation with padding handling
- Lossless Guarantee: Perfect reconstruction of original data
graph LR
A[๐ Input File] --> B[๐ Frequency Analysis]
B --> C[๐ณ Huffman Tree]
C --> D[๐ Binary Encoding]
D --> E[๐พ Compressed File]
E --> F[๐ Tree Recovery]
F --> G[๐ Binary Decoding]
G --> H[๐ Original File]
style A fill:#e3f2fd
style E fill:#e8f5e8
style H fill:#fff3e0
| Data Structure | Use Case | Time Complexity | Space Complexity |
|---|---|---|---|
| B-Tree | File indexing, Range queries | O(log n) | O(n) |
| Red-Black Tree | Fast searching, In-memory ops | O(log n) | O(n) |
| Hash Index | Direct access, Metadata | O(1) average | O(n) |
B-Tree Features:
- โ Self-balancing with configurable degree
- โ Optimal for disk-based operations
- โ Range query support
- โ Bulk loading capabilities
Red-Black Tree Features:
- โ Guaranteed O(log n) height
- โ Fast insertion and deletion
- โ Color-coded visualization
- โ Memory-efficient operations
Modern PyQt5 Application with Tabbed Interface:
| Tab | Description | Key Features |
|---|---|---|
| ๐ฆ Compression | File compression/decompression | Progress tracking, metrics display |
| ๐ณ RB-Tree Storage | Red-Black tree operations | Interactive tree visualization |
| B-tree indexing operations | Node structure display | |
| ๐ Unified Search | Cross-tree search capabilities | Performance comparison |
| ๐ Visualizations | Tree structure rendering | Real-time algorithm animation |
| โก Batch Operations | Multi-file processing | Progress monitoring |
| ๐ Benchmarks | Performance testing suite | Detailed metrics analysis |
| ๐ฎ Demo | Interactive system demo | Educational walkthrough |
| โ๏ธ Configuration | System settings management | User preferences |
Professional command-line interface for automation:
# Compression operations
python main.py compress input.txt output.huff
python main.py decompress output.huff restored.txt
# Tree operations
python main.py btree-add filename.txt
python main.py rbtree-search "filename.txt"
# Batch processing
python main.py batch-compress ./documents/ --filter "*.txt"
# Visualization
python main.py visualize-trees --output tree_structure.png| File Type | Average Compression Ratio | Speed (KB/s) | Memory Usage |
|---|---|---|---|
| Plain Text | 45-65% | 1,200-1,800 | Low |
| Source Code | 35-55% | 1,000-1,500 | Low |
| Documentation | 40-60% | 1,100-1,600 | Low |
| Configuration | 50-70% | 1,300-2,000 | Low |
| Operation | B-Tree | Red-Black Tree | Linear Search |
|---|---|---|---|
| Single Search | 0.18ms | 0.21ms | 45.2ms |
| Range Query | 2.3ms | N/A | 278ms |
| Bulk Insert | 12.4ms | 15.7ms | 892ms |
| Memory Usage | Moderate | Low | High |
graph LR
A[๐ Source Code] --> B[๐ง Compress]
B --> C[๐ฆ Archive]
C --> D[๐ณ Index]
D --> E[๐ Quick Access]
style A fill:#e3f2fd
style C fill:#e8f5e8
style E fill:#fff3e0
- Project Archival: Compress source code projects for storage
- Build Optimization: Reduce artifact sizes in CI/CD pipelines
- Documentation Management: Organize and compress technical docs
- Dataset Compression: Reduce storage costs for large text datasets
- Algorithm Research: Study compression and tree algorithm implementations
- Performance Analysis: Benchmark data structure performance
- Algorithm Visualization: Teach Huffman coding and tree structures
- Interactive Learning: Hands-on experience with computer science concepts
- Research Projects: Foundation for advanced algorithm implementations
graph TD
A[๐ Input Text] --> B[๐ Character Frequency]
B --> C[๐๏ธ Priority Queue]
C --> D[๐ณ Build Huffman Tree]
D --> E[๐ Generate Codes]
E --> F[๐พ Encode Text]
F --> G[๐ Compressed File]
G --> H[๐ณ Extract Tree]
H --> I[๐ Decode Bits]
I --> J[๐ Original Text]
style A fill:#e3f2fd
style G fill:#e8f5e8
style J fill:#fff3e0
Key Features:
- โ Optimal prefix-free codes
- โ Dynamic frequency analysis
- โ Tree serialization/deserialization
- โ Bit-level manipulation
- โ Memory-efficient encoding
class BTreeNode:
def __init__(self, degree):
self.keys = [] # File metadata
self.children = [] # Child nodes
self.is_leaf = True # Leaf indicator
self.degree = degree # Maximum childrenclass RBNode:
def __init__(self, key, color='RED'):
self.key = key # File identifier
self.color = color # RED or BLACK
self.left = None # Left child
self.right = None # Right child
self.parent = None # Parent nodefile-compression-indexing-system/
โโโ ๐ cli/ # Command-line interface
โ โโโ interface.py # Main CLI controller
โ โโโ compression_handler.py # Compression commands
โ โโโ storage_handler.py # Storage commands
โโโ ๐ gui/ # Graphical interface
โ โโโ app.py # Main GUI application
โ โโโ other_tabs.py # Additional GUI tabs
โ โโโ visualization_tab.py # Tree visualization
โโโ ๐ compression/ # Compression algorithms
โ โโโ huffman.py # Huffman coding implementation
โโโ ๐ storage/ # Data structures
โ โโโ btree.py # B-Tree implementation
โ โโโ red_black_tree.py # Red-Black Tree implementation
โโโ ๐ tests/ # Test suite
โ โโโ unit/ # Unit tests
โ โโโ integration/ # Integration tests
โ โโโ performance/ # Performance tests
โโโ ๐ utils/ # Utility modules
โ โโโ config_manager.py # Configuration management
โโโ requirements.txt # Python dependencies
โโโ gui_launcher.py # Application launcher
โโโ README.md # Project documentation
| Module | Unit Tests | Integration Tests | Performance Tests |
|---|---|---|---|
| Compression | โ 95% | โ Complete | โ Benchmarked |
| B-Tree | โ 92% | โ Complete | โ Benchmarked |
| Red-Black Tree | โ 94% | โ Complete | โ Benchmarked |
| GUI Interface | โ 88% | โ Partial | โณ In Progress |
| CLI Interface | โ 90% | โ Complete | โ Benchmarked |
# Run all tests
python -m pytest tests/
# Run specific test categories
python -m pytest tests/unit/
python -m pytest tests/integration/
python -m pytest tests/performance/
# Generate coverage report
python -m pytest --cov=. --cov-report=htmlWe welcome contributions! Here's how you can help:
- ๐ Bug Reports: Found a bug? Open an issue with detailed reproduction steps
- ๐ก Feature Requests: Have an idea? We'd love to hear it!
- ๐ง Code Contributions: Fork, develop, and submit a pull request
- ๐ Documentation: Help improve our documentation
- ๐งช Testing: Add test cases for better coverage
# Clone and setup development environment
git clone https://github.com/Mehmetbaruk/file-compression-indexing-system.git
cd file-compression-indexing-system
# Install development dependencies
pip install -r requirements.txt
pip install pytest pytest-cov black flake8
# Run pre-commit checks
black .
flake8 .
pytestThis project is licensed under the MIT License - see the LICENSE file for details.
- Computer Science Community: For the foundational algorithms and data structures
- PyQt5 Team: For the excellent GUI framework
- Python Community: For the amazing ecosystem and tools
- Academic Institutions: For advancing computer science education
- ๐ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- ๐ง Email: mehmetbaruk38@gmail.com