Skip to content

A peer-to-peer file sharing application with integrated chat functionality, allowing users to connect, communicate, and share files directly with each other.

Notifications You must be signed in to change notification settings

Mysterio-17/FileFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

96 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒ FileFlow - P2P File Sharing Application ๐Ÿ“

A peer-to-peer file sharing application with integrated chat functionality, allowing users to connect, communicate, and share files directly with each other.

Built with Go and Docker for seamless deployment and cross-platform compatibility.

โœจ Features

  • ๐Ÿ‘ค User Authentication: Connect with a username and maintain persistent sessions
  • ๐Ÿ’ฌ Real-time Chat: Send and receive messages with all connected users
  • ๐Ÿ“ File Sharing: Transfer files directly between users
  • ๐Ÿ“‚ Folder Sharing: Share entire folders with other users
  • ๐Ÿ” File Discovery: Look up and browse other users' shared directories
  • ๐Ÿ”„ Automatic Reconnection: Seamlessly reconnect with your existing session
  • ๐Ÿ‘ฅ Status Tracking: Monitor which users are currently online
  • ๐ŸŽจ Colorful UI: Enhanced CLI interface with colors and emojis
  • ๐Ÿ“Š Progress Bars: Visual feedback for file and folder transfers
  • ๐Ÿ”’ Data Integrity: MD5 checksum verification for files and folders

๐Ÿš€ Installation

Prerequisites

  • Docker and Docker Compose (recommended) ๐Ÿณ
  • OR Go (1.22.3 or later) ๐Ÿ”ง

Option 1: Using Docker (Recommended) ๐Ÿณ

  1. Clone the repository โฌ‡๏ธ
git clone https://github.com/YOUR_USERNAME/FileFlow.git
cd FileFlow
  1. Build and run with Docker Compose ๐Ÿ› ๏ธ
# Start the server and example clients
docker-compose up -d

# View logs
docker-compose logs -f

# Stop all services
docker-compose down
  1. Run individual containers ๐Ÿ“ฆ
# Build the Docker image
docker build -t fileflow .

# Run server
docker run -d -p 8080:8080 --name fileflow-server fileflow ./server --port 8080

# Run client (interactive mode)
docker run -it --name fileflow-client1 --link fileflow-server fileflow ./client --server fileflow-server:8080

Option 2: Native Installation (Without Docker) ๐Ÿ”ง

  1. Clone the repository โฌ‡๏ธ
git clone https://github.com/YOUR_USERNAME/FileFlow.git
cd FileFlow
  1. Install dependencies ๐Ÿ“ฆ
go mod download
  1. Build the application ๐Ÿ› ๏ธ
# Build server
go build -o bin/server ./server/cmd/server.go

# Build client
go build -o bin/client ./client/cmd/client.go

๐ŸŽฎ Usage

Using Docker ๐Ÿณ

Starting the Server

# Using Docker Compose
docker-compose up fileflow-server

# Using Docker directly
docker run -d -p 8080:8080 --name fileflow-server fileflow ./server --port 8080

# Custom port
docker run -d -p 3000:3000 --name fileflow-server fileflow ./server --port 3000

Connecting as a Client

# Using Docker Compose (interactive mode)
docker-compose run --rm fileflow-client1

# Using Docker directly
docker run -it --link fileflow-server --name fileflow-client \
  -v $(pwd)/shared:/root/shared \
  fileflow ./client --server fileflow-server:8080

# Connect to remote server
docker run -it --name fileflow-client \
  -v $(pwd)/shared:/root/shared \
  fileflow ./client --server 192.168.0.203:8080

Using Native Binaries ๐Ÿ”ง

Starting the Server ๐Ÿ–ฅ๏ธ

# Start server on default port 8080
go run ./server/cmd/server.go --port 8080

# Or use the built binary
./bin/server --port 8080

# Start server on custom port
./bin/server --port 3000

Connecting as a Client ๐Ÿ“ฑ

# Connect to local server
go run ./client/cmd/client.go --server localhost:8080

# Or use the built binary
./bin/client --server localhost:8080

# Connect to remote server
./bin/client --server 192.168.0.203:8080

Application Validation โœ…

The application will automatically validate:

  • Server availability before client connection attempts
  • Port availability before starting a server
  • Existence of shared folder paths

๐Ÿ—๏ธ Architecture

The application follows a hybrid P2P architecture:

  • ๐ŸŒ A central server handles user registration, discovery, and connection brokering
  • โ†”๏ธ File and folder transfers occur directly between peers
  • ๐Ÿ’“ Server maintains connection status through regular heartbeat checks

๐Ÿ“ Commands

Chat Commands ๐Ÿ’ฌ

Command Description
/help Show all available commands
/status Show online users
exit Disconnect and exit the application

File Operations ๐Ÿ“‚

Command Description
/lookup <userId> Browse user's shared files
/sendfile <userId> <filePath> Send a file to another user
/sendfolder <userId> <folderPath> Send a folder to another user
/download <userId> <filename> Download a file from another user

Terminal UI Features ๐ŸŽจ

  • ๐ŸŒˆ Color-coded messages:

    • Commands appear in blue
    • Success messages appear in green
    • Error messages appear in red
    • User status notifications in yellow
  • ๐Ÿ“Š Progress bars for file transfers:

    [===================================>------] 75% (1.2 MB/1.7 MB)
    
  • ๐Ÿ“ Improved file listings:

    === FOLDERS ===
    ๐Ÿ“ [FOLDER] documents (Size: 0 bytes)
    ๐Ÿ“ [FOLDER] images (Size: 0 bytes)
    
    === FILES ===
    ๐Ÿ“„ [FILE] document.pdf (Size: 1024 bytes)
    ๐Ÿ“„ [FILE] image.jpg (Size: 2048 bytes)
    

๐Ÿ”’ Security

The application implements basic reconnection security by tracking IP addresses and user sessions.

  • ๐Ÿ“ Folder Path Validation: The application verifies that shared folder paths exist before establishing a connection. If an invalid path is provided, the user will be prompted to enter a valid folder path.
  • ๐Ÿ”Œ Server Availability Check: Client automatically verifies server availability before attempting connection, preventing connection errors.
  • ๐Ÿšซ Port Conflict Prevention: Server detects if a port is already in use and alerts the user to choose another port.
  • ๐Ÿ” Checksum Verification: All file and folder transfers include MD5 checksum calculation to verify data integrity:
    • When sending, a unique MD5 hash is calculated for the file/folder contents
    • During transfer, the hash is securely transmitted alongside the data
    • Upon receiving, a new hash is calculated from the received data
    • The application compares both hashes to confirm the transfer was successful and uncorrupted
    • Users receive visual confirmation of integrity checks with clear success/failure messages

This checksum process ensures that files and folders arrive exactly as they were sent, protecting against data corruption during transfer.

๐Ÿณ Docker Architecture

FileFlow uses a multi-stage Docker build for optimized image size:

  • Build Stage: Compiles Go binaries with all dependencies
  • Runtime Stage: Minimal Alpine Linux image with only the compiled binaries
  • Network: Bridge network for container communication
  • Volumes: Persistent storage for shared files

Docker Benefits

  • โœ… Consistent environment across all platforms
  • โœ… Easy deployment and scaling
  • โœ… Isolated file storage per client
  • โœ… No need to install Go locally
  • โœ… Quick setup with docker-compose

๐Ÿ“Š Project Structure

FileFlow/
โ”œโ”€โ”€ client/
โ”‚   โ”œโ”€โ”€ cmd/
โ”‚   โ”‚   โ””โ”€โ”€ client.go          # Client entry point
โ”‚   โ””โ”€โ”€ internal/
โ”‚       โ”œโ”€โ”€ connection.go       # Connection handling
โ”‚       โ”œโ”€โ”€ file.go            # File operations
โ”‚       โ”œโ”€โ”€ folder.go          # Folder operations
โ”‚       โ””โ”€โ”€ transfer.go        # Transfer management
โ”œโ”€โ”€ server/
โ”‚   โ”œโ”€โ”€ cmd/
โ”‚   โ”‚   โ””โ”€โ”€ server.go          # Server entry point
โ”‚   โ”œโ”€โ”€ interfaces/
โ”‚   โ”‚   โ””โ”€โ”€ interfaces.go      # Data structures
โ”‚   โ””โ”€โ”€ internal/
โ”‚       โ”œโ”€โ”€ connection.go       # Connection handling
โ”‚       โ”œโ”€โ”€ file.go            # File operations
โ”‚       โ””โ”€โ”€ folder.go          # Folder operations
โ”œโ”€โ”€ helper/
โ”‚   โ””โ”€โ”€ helper.go              # Utility functions
โ”œโ”€โ”€ utils/
โ”‚   โ””โ”€โ”€ ui.go                  # UI components
โ”œโ”€โ”€ Dockerfile                  # Docker build configuration
โ”œโ”€โ”€ docker-compose.yml         # Multi-container setup
โ”œโ”€โ”€ .dockerignore              # Docker ignore rules
โ”œโ”€โ”€ go.mod                     # Go dependencies
โ””โ”€โ”€ README.md                  # Documentation

Made with โค๏ธ by the FileFlow Team

About

A peer-to-peer file sharing application with integrated chat functionality, allowing users to connect, communicate, and share files directly with each other.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors