A full-stack web application that demonstrates Huffman Coding and LZW (Lempel-Ziv-Welch) compression algorithms with step-by-step visualization. Built as an ADS (Advanced Data Structures) project.
- Backend β C++ REST API using the Crow web framework
- Frontend β React app with GSAP animations for interactive algorithm visualization
- Upload any file and compress it using Huffman or LZW algorithms
- Visualize the compression process step-by-step:
- Huffman: frequency analysis, tree construction (merge steps), code table generation, and encoding
- LZW: dictionary building, encoding steps, and bit packing
- Decompress data back to the original file
- View compression ratio and size statistics
- g++ with C++17 support
- libasio-dev (networking library for Crow)
- libboost-all-dev
- Node.js and npm
Install system dependencies (Ubuntu/Debian):
sudo apt install g++ libasio-dev libboost-all-dev libssl-dev.
βββ server.cpp # Crow REST API server (compress/decompress endpoints)
βββ huffman.h # Huffman coding implementation
βββ lzw.h # LZW compression implementation
βββ Makefile # Build configuration for the backend
βββ Crow/ # Crow framework (git clone)
βββ frontend/ # React frontend
βββ src/
βββ App.js
βββ components/
βββ HuffmanViz.js # Huffman visualization
βββ LzwViz.js # LZW visualization
βββ NetworkCanvas.js # Canvas-based network animation
makecd frontend
npm installStart the backend server:
make run
# Server runs at http://localhost:18080In a separate terminal, start the React dev server:
cd frontend
npm start
# Frontend runs at http://localhost:3000 (proxies API calls to :18080)For production, build the frontend and serve it from the backend:
cd frontend
npm run build
# The backend serves frontend/build/index.html at http://localhost:18080Compress file data using the specified algorithm.
Request body:
{
"algorithm": "huffman" | "lzw",
"data": "<base64-encoded file data>",
"filename": "example.txt"
}Response: compressed data (base64), compression ratio, size stats, and visualization steps.
Decompress previously compressed data.
Request body:
{
"algorithm": "huffman" | "lzw",
"data": "<base64-encoded compressed data>"
}Response: decompressed data (base64), size stats, and visualization steps.