Skip to content

A modern, high-performance file compression and decompression web application powered by Huffman coding algorithm and WebAssembly.

Notifications You must be signed in to change notification settings

pandarudra/Zipster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Zipster πŸ“¦

A modern, high-performance file compression and decompression web application powered by Huffman coding algorithm and WebAssembly.

Zipster Preview TypeScript C++ WebAssembly

✨ Features

  • πŸš€ 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

πŸ—οΈ Architecture

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  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm/yarn
  • A C++ compiler (for building WASM module)
  • Emscripten (for WebAssembly compilation)

Installation

  1. Clone the repository

    git clone https://github.com/pandarudra/Zipster.git
    cd Zipster
  2. Install dependencies

    cd web
    npm install
  3. 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/
  4. Run the development server

    cd ../web
    npm run dev
  5. Open your browser Navigate to http://localhost:3000 to start using Zipster!

πŸ“‚ Project Structure

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

πŸ”§ Core Components

Huffman Algorithm (C++)

  • Location: huffman-core/huffman.cpp
  • Features:
    • Efficient Huffman tree construction
    • Tree serialization for decompression
    • Optimized bit-level encoding/decoding
    • Memory-safe operations

WASM Integration

  • Loader: web/lib/loadHuffman.ts
  • Wrapper: web/lib/huffman-wrapper.js
  • Features:
    • Dynamic WASM module loading
    • Memory management
    • Type-safe interfaces

API Endpoints

  • Compression: POST /api/compress
  • Decompression: POST /api/decompress
  • Features:
    • Base64 file encoding
    • Progress tracking
    • Error handling

Frontend Components

  • FileUpload: Drag-and-drop file selection
  • CompressionModeSelector: Toggle between compress/decompress modes
  • ProcessingCard: Real-time progress and statistics
  • StorageManager: File download and management

πŸ› οΈ Development

Building the WASM Module

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 Scripts

# Development server with Turbopack
npm run dev

# Production build
npm run build

# Start production server
npm run start

# Lint code
npm run lint

Adding New Features

  1. Algorithm Changes: Modify huffman-core/huffman.cpp and rebuild WASM
  2. UI Components: Add to web/components/ following the existing pattern
  3. API Endpoints: Create new routes in web/app/api/
  4. Utilities: Add helper functions to web/lib/

πŸ§ͺ Testing

Manual Testing

  1. Upload various file types (text, images, documents)
  2. Test compression and decompression cycles
  3. Verify file integrity after decompression
  4. Test drag-and-drop functionality
  5. Check compression ratios and performance

File Format Support

  • βœ… 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.)

πŸ“Š Performance

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

Typical Compression Ratios

  • Text files: 40-60% reduction
  • Source code: 50-70% reduction
  • Documents: 30-50% reduction
  • Already compressed files: 0-10% reduction

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes:
    • Follow the existing code style
    • Add comments for complex logic
    • Test your changes thoroughly
  4. Commit your changes: git commit -m 'Add amazing feature'
  5. Push to your branch: git push origin feature/amazing-feature
  6. Open a Pull Request

Areas for Contribution

  • πŸ”§ Performance optimizations
  • 🎨 UI/UX improvements
  • πŸ“š Documentation enhancements
  • πŸ§ͺ Additional test cases
  • 🌐 Internationalization
  • πŸ“± Mobile responsiveness

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • 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

πŸ“ž Contact


Made with ❀️ and lots of β˜•

Star ⭐ this repo if you found it helpful!

About

A modern, high-performance file compression and decompression web application powered by Huffman coding algorithm and WebAssembly.

Resources

Stars

Watchers

Forks

Packages

No packages published