Go to file
2024-06-25 20:45:18 +07:00
static Fixes 2024-06-25 18:49:28 +07:00
.gitignore Update README to be more professional 2024-06-25 20:45:18 +07:00
main.py Update README to be more professional 2024-06-25 20:45:18 +07:00
README.md Update README to be more professional 2024-06-25 20:45:18 +07:00
requirements.txt First commit 2024-06-25 18:24:27 +07:00

Compress Files

Instructions

  1. Ensure Python and Flask are installed
  2. Run python main.py
  3. Navigate to http://localhost:8888

Design Considerations and Key Decisions

The project consisted of both a frontend and backend component. The frontend only required a straightforward web interface solely for file upload and display of compressed file details, thus a static HTML file sufficed.

For the backend, a REST API was essential to facilitate file uploads and subsequent downloads of compressed files:

  • /api/upload_file
    • Accepts HTTP POST requests containing the file to compress
    • Returns a JSON object including fields: {"compressed_size":INT,"file_id":STR,"original_size":INT}
      • Essential information for user display and compressed file retrieval
  • /api/download_file/<FILE_ID>
    • Accepts HTTP GET requests
    • Retrieves the compressed file corresponding to FILE_ID

Python Flask was selected for the backend due to its suitability for developing REST APIs.

Upon file upload, the backend saves and compresses the file, subsequently deleting the original. Each file is uniquely identified using a UUIDv4 to prevent naming conflicts.

Other considerations

For scalability, multithreading could enhance performance with increased load and larger files, but this was beyond the project's current scope.

Decompression functionality was not required for this project. However, if needed, decompression details could be stored server-side (e.g., in JSON files linked to each file ID) or within the compressed file itself.

Compression Algorithm

Research revealed no standardized format for ECG files, limiting optimization options for headers or data structures.

The Huffman Coding algorithm was chosen for its proven reliability. Opting for a 1-byte node representation was determined to be optimal despite initially considering for 3-byte nodes, owing to the algorithm's efficiency with only 256 possible combinations.