Author: Pinaka Type: CLI + WebSocket App Level: Advanced Architecture: Client–Server Protocol: WebSocket
This project is a real-time file sharing system built using FastAPI WebSockets and Python CLI clients.
It allows:
- One Sender to upload a file
- Multiple Receivers to receive the file live
- Chunk-based binary streaming
- Automatic reconnect for receivers
This mimics how real production file streaming systems work.
┌──────────────┐
│ Sender CLI │
└──────┬───────┘
│
│ WebSocket
▼
┌────────────────────────┐
│ FastAPI WebSocket API │
│ /sender /receiver │
└──────┬───────────┬─────┘
│ │
▼ ▼
Receiver CLI Receiver CLI
Project_28/
├── api/
│ └── main.py # FastAPI WebSocket server
├── client/
│ ├── sender.py # File sender CLI
│ └── receiver.py # File receiver CLI
└── README.md
- 📤 Send any file (binary safe)
- 📥 Receive files in real time
- 🔄 Chunk-based streaming
- 👥 Multiple receivers supported
- ♻ Auto-reconnect receiver
- 🧠 Minimal & clean protocol
- 🖥️ CLI-first design
fastapi
uvicorn
websockets
Install with:
pip install fastapi uvicorn websocketsuvicorn main:app --host 0.0.0.0 --port 8000python receiver.py-
Automatically connects to server
-
Waits for incoming files
-
Saves files as:
rcv_<original_filename> -
Auto-reconnects if connection drops
python sender.pyEnter full file path:
/home/user/Documents/test.pdf
✔ File will be streamed to all connected receivers
| Signal | Meaning |
|---|---|
START:<filename> |
File transfer begins |
| Binary chunks | File data |
__end__ |
File transfer complete |
END |
Receiver closes file |
- Sending file in one piece
- Blocking sockets
- No reconnect logic
- Chunk streaming
- Binary-safe transfer
- Receiver reconnection
- Server fan-out to multiple clients
- Stateless sender
- No encryption
- No authentication
- No resume support
- No file validation
👉 These are next-level enhancements, not beginner concepts.
- Start server
- Start multiple receivers
- Send large files
- Disconnect receiver → auto reconnect works
This project demonstrates:
- Real networking concepts
- How file streaming actually works
- Why WebSockets are used
- How to think like a backend engineer
It is far beyond a basic Python project and suitable for:
- Resume
- Portfolio
- Interview discussion