A secure, multi-client file management system with real-time chat capabilities built on a Client-Server architecture.
| Feature | Description |
|---|---|
| π€ Upload | Securely upload files to a central server with chunked transfer |
| π₯ Download | Download files from the server with encrypted transmission |
| ποΈ Delete | Remove files from the server repository |
| π¬ Real-Time Chat | Store-and-forward messaging system between users |
| π₯ Multi-User Support | Concurrent connections with multi-threading |
| π Security | SSL/TLS encryption, certificate-based authentication |
| π₯οΈ GUI | User-friendly graphical interface |
The system operates on a Client-Server Architecture where:
- Server: Acts as a "Private Cloud" running on a specific IP and TCP port (9998). It is concurrent - handles multiple users simultaneously without blocking.
- Clients: User-facing GUI applications that initiate requests. They don't store data permanently - they only push (upload) or pull (download) data from the central server.
βββββββββββββββ ββββββββββββββββββββ βββββββββββββββ
β Client A ββββββββββΊβ Server (Cloud) ββββββββββΊβ Client B β
β (GUI) β β 10.0.14.87:9998 β β (GUI) β
βββββββββββββββ ββββββββββββββββββββ βββββββββββββββ
β
βββββββββββΌββββββββββ
β Client C β
β (GUI) β
βββββββββββββββββββββ
- Socket Creation: Standard TCP stream socket ensures reliable data delivery
- TLS Handshake: Server presents its digital certificate (
server.crt) - Encrypted Tunnel: All data (passwords, files, chat) is encrypted before transmission
Client Server
β β
ββββββ TCP Connection ββββββββββββββΊβ
β β
ββββββ TLS Handshake ββββββββββββββΊβ
β (Certificate Exchange) β
βββββββ Encrypted Tunnel βββββββββββ
β β
ββββββ Encrypted Data βββββββββββββΊβ
βββββββ Encrypted Response βββββββββ
The server implements session-based authentication:
- Client establishes secure connection
- Client sends:
LOGIN <username> <password> - Server validates credentials against internal dictionary
- Success β
200 OK+is_authenticated = True - Failure β Connection rejected
Only authenticated users can access the server_files directory.
The server uses Python's threading module for concurrent user handling:
- Main Server Loop: Listens for new connections
- Per-Client Thread: Spawns
handle_clientthread for each new user - Result: User A can upload, User B can delete, User C can chat - simultaneously!
βββββββββββββββββββ
β Main Server β
β Loop β
ββββββββββ¬βββββββββ
β
βββββββββββββββββββΌββββββββββββββββββ
β β β
ββββββββΌβββββββ ββββββββΌβββββββ ββββββββΌβββββββ
β Thread 1 β β Thread 2 β β Thread 3 β
β (User A) β β (User B) β β (User C) β
β UPLOAD β β DELETE β β CHAT β
ββββββββββββββ βββββββββββββββ βββββββββββββββ
Files are transferred in 1KB blocks to avoid loading entire files into RAM:
- Client sends:
PUT <filename> - Server opens file and responds:
READY - Client loop: Read 1KB β Encrypt β Send β Repeat
- Client sends:
FILE_ENDmarker - Server decrypts and writes each chunk to disk
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FILE TRANSFER β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Client β
β β β
β ββββΊ READ 1KB ββββΊ ENCRYPT ββββΊ SEND β
β β β
β ββββΊ READ 1KB ββββΊ ENCRYPT ββββΊ SEND β
β β β
β ββββΊ SEND FILE_END ββββββββββββββββββββββββββββββΊβ
β β
β Server β
β β β
β ββββ RECEIVE ββββΊ DECRYPT ββββΊ WRITE to disk β
β β β
β ββββ RECEIVE ββββΊ DECRYPT ββββΊ WRITE to disk β
β β β
β ββββ FILE_END β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Since TCP is a single data stream, the server acts as a temporary mailbox:
- User A sends a message β Stored in
chat_historylist - User B polls every 2 seconds:
GET_CHAT - Server responds with latest chat history
- Result: Real-time chat illusion without complex async protocols
βββββββββββ Polls every 2s βββββββββββ
β Client AβββββββββββββββββββββββββββΊβ Server β
β β "Any new messages?" β β
βββββββββββ ββββββ¬βββββ
β
ββββββββββββββ΄βββββββββββββ
β chat_history: [] β
β [msg1, msg2, msg3...] β
βββββββββββββββββββββββββββ
β
βββββββββββ Receives β
β Client Bββββββββββββββββββββββββββββββββ
β β [msg1, msg2, msg3...]
βββββββββββ
The Client GUI handles two simultaneous operations:
- Background: Auto-refreshes chat every 2 seconds
- Foreground: Waiting for user to click "Upload"
If both happen simultaneously, data streams could mix β Protocol Violation
- Acts like a "talking stick"
- Before sending data, a function must acquire the Lock
- If Upload holds the Lock, Chat Refresh waits until upload finishes
- Prevents crashes during simultaneous operations
- Python 3.x
- Required libraries:
socket,ssl,threading,tkinter
python server.pyThe server will start on 0.0.0.0:9998 and use SSL/TLS encryption.
python client_gui.pyConnect to the server using the server's IP address and port 9998.
Distributed-File-Repository-System/
βββ client_gui.py # Client GUI application
βββ server.py # Server application
βββ server.crt # SSL certificate
βββ server.key # SSL private key
βββ server_files/ # Repository directory for files
βββ image1.png # Demo screenshot 1
βββ image2.png # Demo screenshot 2
βββ Readme.md # This file
| Command | Description |
|---|---|
LOGIN <user> <pass> |
Authenticate with server |
PUT <filename> |
Upload a file |
GET <filename> |
Download a file |
DELETE <filename> |
Delete a file from server |
LIST |
List all files on server |
GET_CHAT |
Retrieve chat history |
SEND_CHAT <msg> |
Send a chat message |
- β TLS/SSL Encryption - All data encrypted in transit
- β Certificate-Based Authentication - Server identity verification
- β Session Management - Authentication state tracking
- β Per-User Thread Isolation - Secure multi-user environment
- Protocol: TCP Stream Sockets with SSL/TLS
- Port: 9998
- Chunk Size: 1024 bytes (1KB)
- Chat Poll Interval: 2 seconds
- Concurrency: Multi-threaded (one thread per client)
Built with β€οΈ using Python

