A modern, high-performance file compression and decompression web application powered by Huffman coding algorithm and WebAssembly.
- π High-Performance Compression: Utilizes Huffman coding algorithm compiled to WebAssembly for optimal speed
- π Modern Web Interface: Built with Next.js 15 and React 19 with a sleek, responsive design
- π Drag & Drop Support: Intuitive file upload with drag-and-drop functionality
- π Bidirectional Processing: Both compression and decompression capabilities
- π Compression Statistics: Real-time compression ratio and file size information
- πΎ Local File Management: Client-side file processing with download capabilities
- π¨ Beautiful UI: Styled with Tailwind CSS and Radix UI components
- β‘ Real-time Progress: Live progress tracking during compression/decompression
- π Dark Mode Support: Built-in dark/light theme toggle
Zipster follows a hybrid architecture combining the power of C++ algorithms with modern web technologies:
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Frontend β β API Routes β β WASM Core β
β (Next.js) βββββΊβ (Next.js) βββββΊβ (C++ Huffman) β
β β β β β β
β β’ File Upload β β β’ /api/compress β β β’ Huffman Tree β
β β’ Progress UI β β β’ /api/decompressβ β β’ Serialization β
β β’ File Download β β β’ WASM Loading β β β’ Bit Encoding β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
- Node.js 18+ and npm/yarn
- A C++ compiler (for building WASM module)
- Emscripten (for WebAssembly compilation)
-
Clone the repository
git clone https://github.com/pandarudra/Zipster.git cd Zipster -
Install dependencies
cd web npm install -
Build the WASM module (if needed)
cd ../huffman-core # Compile C++ to WebAssembly emcc huffman.cpp -o huffman.wasm -s EXPORTED_FUNCTIONS="['_compress','_decompress','_malloc','_free']" -s ALLOW_MEMORY_GROWTH=1 # Copy WASM files to web directory cp huffman.wasm ../web/lib/ cp huffman.wasm ../web/public/
-
Run the development server
cd ../web npm run dev -
Open your browser Navigate to
http://localhost:3000to start using Zipster!
Zipster/
βββ π huffman-core/ # Core Huffman algorithm implementation
β βββ huffman.cpp # C++ Huffman coding implementation
β βββ input.txt # Test input file
β βββ huffman.wasm # Compiled WebAssembly module
β
βββ π web/ # Next.js web application
β βββ π app/ # App router (Next.js 13+)
β β βββ layout.tsx # Root layout component
β β βββ page.tsx # Main application page
β β βββ π api/ # API routes
β β βββ compress/ # Compression endpoint
β β βββ decompress/ # Decompression endpoint
β β
β βββ π components/ # React components
β β βββ compression-mode-selector.tsx
β β βββ file-upload.tsx
β β βββ hero-section.tsx
β β βββ processing-card.tsx
β β βββ storage-manager.tsx
β β βββ π ui/ # Reusable UI components (Radix)
β β
β βββ π lib/ # Utility libraries
β β βββ file-utils.ts # File handling utilities
β β βββ huffman-wrapper.js
β β βββ huffman.js
β β βββ huffman.wasm # WASM module
β β βββ loadHuffman.ts # WASM loader
β β βββ utils.ts # General utilities
β β
β βββ π hooks/ # Custom React hooks
β βββ π public/ # Static assets
β βββ π types/ # TypeScript type definitions
β βββ package.json # Dependencies and scripts
β
βββ README.md # This file
- Location:
huffman-core/huffman.cpp - Features:
- Efficient Huffman tree construction
- Tree serialization for decompression
- Optimized bit-level encoding/decoding
- Memory-safe operations
- Loader:
web/lib/loadHuffman.ts - Wrapper:
web/lib/huffman-wrapper.js - Features:
- Dynamic WASM module loading
- Memory management
- Type-safe interfaces
- Compression:
POST /api/compress - Decompression:
POST /api/decompress - Features:
- Base64 file encoding
- Progress tracking
- Error handling
- FileUpload: Drag-and-drop file selection
- CompressionModeSelector: Toggle between compress/decompress modes
- ProcessingCard: Real-time progress and statistics
- StorageManager: File download and management
To modify the Huffman algorithm or rebuild the WebAssembly module:
cd huffman-core
# Install Emscripten (if not already installed)
# Follow instructions at: https://emscripten.org/docs/getting_started/downloads.html
# Compile C++ to WebAssembly
emcc huffman.cpp -o huffman.wasm \
-s EXPORTED_FUNCTIONS="['_compress','_decompress','_malloc','_free']" \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s EXPORT_NAME="createHuffmanModule" \
-O3
# Copy to web directories
cp huffman.wasm ../web/lib/
cp huffman.wasm ../web/public/# Development server with Turbopack
npm run dev
# Production build
npm run build
# Start production server
npm run start
# Lint code
npm run lint- Algorithm Changes: Modify
huffman-core/huffman.cppand rebuild WASM - UI Components: Add to
web/components/following the existing pattern - API Endpoints: Create new routes in
web/app/api/ - Utilities: Add helper functions to
web/lib/
- Upload various file types (text, images, documents)
- Test compression and decompression cycles
- Verify file integrity after decompression
- Test drag-and-drop functionality
- Check compression ratios and performance
- β Text files (.txt, .md, .json, .xml)
- β Documents (.pdf, .doc, .docx)
- β Images (.jpg, .png, .gif, .bmp)
- β Archives (.zip, .tar, .gz)
- β Code files (.js, .ts, .cpp, .py, etc.)
Zipster achieves excellent compression performance through:
- WebAssembly Speed: Near-native C++ performance in the browser
- Huffman Efficiency: Optimal compression ratios for most file types
- Streaming Processing: Handles large files efficiently
- Memory Management: Optimized memory usage with automatic cleanup
- Text files: 40-60% reduction
- Source code: 50-70% reduction
- Documents: 30-50% reduction
- Already compressed files: 0-10% reduction
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes:
- Follow the existing code style
- Add comments for complex logic
- Test your changes thoroughly
- Commit your changes:
git commit -m 'Add amazing feature' - Push to your branch:
git push origin feature/amazing-feature - Open a Pull Request
- π§ Performance optimizations
- π¨ UI/UX improvements
- π Documentation enhancements
- π§ͺ Additional test cases
- π Internationalization
- π± Mobile responsiveness
This project is licensed under the MIT License - see the LICENSE file for details.
- Huffman Coding Algorithm: Created by David A. Huffman in 1952
- Next.js Team: For the amazing React framework
- Radix UI: For the beautiful component primitives
- Emscripten: For making C++ β WASM compilation seamless
- Tailwind CSS: For the utility-first CSS framework
- Author: Rudra Panda
- GitHub: @pandarudra
- Project: Zipster Repository
Made with β€οΈ and lots of β
Star β this repo if you found it helpful!