A high-performance real-time data broadcasting and file storage service built on Cloudflare Workers infrastructure.
- Real-time WebSocket Broadcasting - Instantly push data to all connected clients
- File Upload & Storage - Secure file handling with Supabase integration
- Zero Configuration - Deploy and run with minimal setup
- Global Edge Network - Powered by Cloudflare's worldwide infrastructure
- CORS Enabled - Seamless cross-origin integration
The system consists of two independent Cloudflare Workers:
- WebSocket connections for real-time communication
- Broadcast messaging to all connected clients
- Latest data retrieval endpoint
- Durable Objects for stateful WebSocket management
- Multipart form data file uploads
- Automatic file naming with collision prevention
- Direct integration with Supabase Storage
- File metadata retrieval
| Service | Endpoint | Description |
|---|---|---|
| WebSocket | wss://data-transmitter.hemeshchadalavada.workers.dev |
Real-time data streaming |
| Broadcast API | POST /broadcast |
Send data to all connected clients |
| Latest Data | GET /latest |
Retrieve most recent broadcast |
| File Upload | POST /upload |
Upload files to cloud storage |
| File Info | GET /file/{fileName} |
Get file metadata and URLs |
const ws = new WebSocket('wss://data-transmitter.hemeshchadalavada.workers.dev');
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Received:', data);
};fetch('https://data-transmitter.hemeshchadalavada.workers.dev/broadcast', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
device: 'web',
format: 'notification',
content: 'Hello World'
})
});const formData = new FormData();
formData.append('file', fileInput.files[0]);
fetch('https://file-upload-api.hemeshchadalavada.workers.dev/upload', {
method: 'POST',
body: formData
});- Wrangler CLI
- Cloudflare account
- Supabase project (for file uploads)
- Clone the repository
git clone https://github.com/hemeshch/evanai-server.git
cd evanai-server- Configure Wrangler
wrangler login- Run Data Transmitter locally
wrangler dev --config wrangler.toml- Run File Upload API locally
wrangler dev --config file-upload-wrangler.tomlDeploy Data Transmitter:
wrangler deploy --config wrangler.tomlDeploy File Upload API:
wrangler deploy --config file-upload-wrangler.toml{
"device": "string", // Required: Device identifier
"format": "string", // Required: Message format type
"content": "string", // Required: Message payload
"timestamp": 1234567890, // Optional: Unix timestamp (ms)
"...": "any" // Additional custom fields allowed
}{
"success": true,
"fileName": "1758346198562-abc123.pdf",
"downloadUrl": "https://file-upload-api.../file/...",
"supabaseUrl": "https://supabase.co/.../files/...",
"originalName": "document.pdf",
"size": 245678,
"type": "application/pdf"
}websocket-test.html- Interactive WebSocket testing interfaceupload-test.html- File upload testing interface
upload-icon.js- Programmatic file upload testingupload-icon-simple.js- Simplified upload testing
Open test HTML files directly in browser:
open websocket-test.html
open upload-test.html| Metric | Limit | Notes |
|---|---|---|
| Max WebSocket Connections | Memory bound | Per Durable Object instance |
| Max File Size | ~100MB | Cloudflare request limit |
| Message Size | ~1MB | Practical limit for broadcasts |
| Response Time | <50ms | Global edge network |
- No authentication on endpoints
- Public file access via URLs
- Open WebSocket connections
Recommended for Production:
- Implement API key authentication
- Add JWT token validation
- Enable rate limiting
- Restrict CORS origins
- Add file access controls
All endpoints support CORS with:
Access-Control-Allow-Origin: *Access-Control-Allow-Methods: GET, POST, OPTIONSAccess-Control-Allow-Headers: Content-Type
name = "data-transmitter"
main = "worker.js"
compatibility_date = "2024-01-01"
[[durable_objects.bindings]]
name = "DATA_BROADCASTER"
class_name = "DataBroadcaster"name = "file-upload-api"
main = "file-upload-worker.js"
compatibility_date = "2024-01-01"
[vars]
SUPABASE_URL = "your-supabase-url"
SUPABASE_ANON_KEY = "your-anon-key"- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is open source and available under the MIT License.
For issues and questions:
- Open an issue on GitHub
- Check the SERVER-SPEC.md for detailed API documentation
Built with β‘ by Hemesh Chadalavada