DEV Community

Cover image for [Project Breakdown] Syncord: Encrypted File Storage via Discord
krish
krish

Posted on

[Project Breakdown] Syncord: Encrypted File Storage via Discord

In today’s episode of project breakdown (yes, I’m starting this just now), we’ll look at one of my recent projects: Syncord.

What Is Syncord?

Syncord is a CLI-based file storage tool that uses Discord as an encrypted file storage.

It allows you to upload files or entire directories to Discord, encrypt and partition them locally, and later download and reconstruct them securely; all through a simple command-line interface or an optional TUI dashboard.

start-up TUI image

So in short, it is more or less a google drive but instead of google it's discord and instead of drive it's encrypted partitions.

Why Even Create This Project?

I’ve seen similar projects before, but most of them relied on a web server (Flask, Express.js) and a browser-based workflow. I personally didn’t enjoy hosting a server just to upload or download files.

syncord was built to be purely command-line driven, something I could put in my PATH and just use instantly without opening a browser.

There are objectively better file storage solutions like Google Drive or One Drive, and I’d recommend those for most users. syncord exists primarily as a learning project and experiment, built during my college winter break.

People might question whether this violates Discord’s ToS. While syncord uses a user-owned bot, standard attachment uploads, and documented APIs. It does not exploit bugs. However, excessive or abusive usage could still result in rate limiting or action against the bot.

Why Discord?

Well, Discord provides up-to 8MB of upload limit per message and while Discord does not guarantee long-term retention, but in practice files persist unless removed or moderated (I still have photos sent to a friend back in 2019 on Discord). So why not use it?

I am thinking of adding telegram or other "free" storage providers too but that would most likely not happen anytime soon.

The Core Idea

Project structure:

syncord/
└── core/
    ├── ascii_hell.py
    ├── db_manager.py
    ├── discord_handler.py
    ├── encrypter.py
    ├── partition.py
    ├── setup.py
    └── tui.py
└── main.py
└── setup.yaml
└── syncord.db
└── syncord.exe
Enter fullscreen mode Exit fullscreen mode

Let us talk about the 8MB upload limit first

files size <= 8MB

If a file is smaller than 8MB then you can upload it without having any issues from discord and would work as intended.

file size > 8MB

Problem starts when the file size is actually greater than 8MB. To tackle that in my project, I have created a partition system that chunks files into relevant size and a SQLite DB that tracks the partition number and partition ID.

What is this partition system? core/partition.py

When a file is intended to be uploaded via syncord, the file is broken into 5.5MB chunks and the metadata is stored in a database.

The files created have {number}.bin extension since I am essentially saying binary of the file itself.

DB Table: core/database_manager.py

CREATE TABLE if not exists syncord(parition_number integer, parition_uuid text, message_id text primary key, file_name text, folder_name text, file_size_bytes integer)
Enter fullscreen mode Exit fullscreen mode

The DB includes: (yes typo was done in the DB itself which I never fixed)

  • parition_number: Which number partition this record represents. (e.g. 1.bin, 2.bin, etc)
  • parition_uuid: Which file are we talking about?
  • message_id: We get this after uploading to Discord.
  • file_name: Helps with knowing the original name along with it's extension.
  • folder_name: Since syncord support entire folder upload feature so this helps with knowing the exact tree of it.
  • file_size_bytes: Currently used for stats. Later could be used to checksum to further save the integrity of file.

What about privacy?

While uploading to discord sounds like a wonderful idea for some people. Some might also question how safe it is since anyone can join your discord server without much effort. For that, I have implemented an encryption system.

Encryption System core/encrypter.py

I used fernet (Fernet encryption is a symmetric, authenticated cryptography system from Python's cryptography library that uses a single secret key for both encryption and decryption, ensuring messages can't be read or tampered with unless you have the key.) to encrypt my bytes before making then .bin file which gets uploaded. The key is stored locally (setup.yaml) on the PC itself rather than uploading that on Discord.

Since fernet introduces it's own metadata overhead, padding and base64 encoding on top of the data, it increases the file size (approx ~33.33%) and that was why I chunked on 5.5MB and not 8MB itself.

How is it stored on discord?

I am using py-cord that is commonly used for creating a Discord BOT. A channel named syncord gets created in the provided guild ID. All the files are sent together via the API and their message IDs are stored in the DB to help retrieve the files again when downloaded.

setup:
  bot_token: "your_bot_token"
  encryption_key: "auto_generated_using_fernet"
  guild_id: 1234567890123456789
Enter fullscreen mode Exit fullscreen mode

This pretty much sums up what exactly happens in the background.
Upload:

  1. File is partitioned into 5.5MB chunks (if needed)
  2. Each chunk is encrypted using Fernet
  3. Chunks are uploaded via a Discord bot
  4. Message IDs and metadata are stored locally in SQLite

Download:

  1. Metadata is read from the local database
  2. Chunks are fetched using stored message IDs
  3. Data is decrypted locally
  4. Original file is reconstructed and saved

Usage

Prebuilt Binary (Recommended)

  1. Download syncord.exe
  2. Place it in a directory included in your system PATH
  3. Verify installation:
syncord --help
Enter fullscreen mode Exit fullscreen mode

syncord can now be invoked from any directory.

Mandatory Initial Setup

Syncord requires setup before first use.

Both the Discord bot token and Guild ID are mandatory.

Required Configuration

  • Discord Bot Token
  • Discord Guild ID (server where files are uploaded)
  • Encryption Key (generated locally)
syncord setup --token YOUR_DISCORD_BOT_TOKEN --guild-id YOUR_GUILD_ID --encryption-key
Enter fullscreen mode Exit fullscreen mode

Important Notes

  • The encryption key is critical.
  • Losing the key means permanent data loss.
  • Discord cannot decrypt or recover your files.
  • syncord will not function without a valid token and guild ID.

Uploading Files

Upload a Single File

syncord upload file.ext
Enter fullscreen mode Exit fullscreen mode

Upload an Entire Directory

TUI with folders and files image

syncord upload folder_name
Enter fullscreen mode Exit fullscreen mode

Behavior:

  • All files inside the directory are processed
  • Folder structure is logically preserved
  • Each directory becomes its own Syncord folder namespace

Downloading Files

syncord download folder_on_syncord/file
Enter fullscreen mode Exit fullscreen mode

Syncord will:

  • Locate all required partitions
  • Download them from Discord
  • Decrypt locally
  • Reassemble the original file

If no folder is provided, Syncord assumes the default upload namespace default.

TUI Dashboard

TUI image

syncord dashboard
Enter fullscreen mode Exit fullscreen mode

Provides:

  • Stored file overview
  • Folder and file downloads
  • Storage usage
  • Interactive navigation

Usage Statistics

syncord stats
Enter fullscreen mode Exit fullscreen mode

Displays:

  • Total files uploaded
  • Total downloads
  • Storage usage
  • Other tracked metrics

Command Summary

Command Description
syncord setup Mandatory initial configuration
syncord upload Upload a file or directory
syncord download Download and reconstruct a file
syncord dashboard Launch terminal UI dashboard
syncord stats Show usage statistics

Limitations & Tradeoffs

  • Discord is not a storage service and offers no durability guarantees.
  • Heavy usage may trigger rate limits or bot restrictions.
  • Loss of the encryption key results in permanent data loss.
  • Metadata (filenames, folder names) is stored locally but not encrypted.

Conclusion

This was my first time building a TUI-based application, coming from a background focused mainly on back-end API development. The project was fun.

Writing this blog also motivated me to start documenting my past and future projects. I hope the dev.to community enjoys these breakdowns. I plan to make them a regular thing.

This was also one of my first blog written specifically over a project. I would apologize if it was a little challenging to read or comprehend, I intend to improve over time and practice.

GitHub Link: https://github.com/krishsharma0413/syncord ⭐ if you like what you see.
personal rating: 8.5/10
Here is a video of the entire project.

Top comments (0)