{"id":28816361,"url":"https://github.com/v0id-user/wasmchannel","last_synced_at":"2026-04-29T23:04:49.676Z","repository":{"id":296800010,"uuid":"989194944","full_name":"v0id-user/WasmChannel","owner":"v0id-user","description":"Experimental app using Rust+Wasm on Next.js frontend \u0026 Cloudflare Workers backend, featuring a custom binary protocol.","archived":false,"fork":false,"pushed_at":"2025-06-17T04:20:11.000Z","size":1238,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-17T04:28:50.323Z","etag":null,"topics":["binary","cloudflare","nextjs","protocol","queue","real-time","rust","wasm","websocket","workers"],"latest_commit_sha":null,"homepage":"https://wasm,channel","language":"WebAssembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/v0id-user.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-23T17:57:38.000Z","updated_at":"2025-06-17T04:20:15.000Z","dependencies_parsed_at":"2025-06-03T08:04:58.360Z","dependency_job_id":null,"html_url":"https://github.com/v0id-user/WasmChannel","commit_stats":null,"previous_names":["v0id-user/wasmchannel"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/v0id-user/WasmChannel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0id-user%2FWasmChannel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0id-user%2FWasmChannel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0id-user%2FWasmChannel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0id-user%2FWasmChannel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/v0id-user","download_url":"https://codeload.github.com/v0id-user/WasmChannel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v0id-user%2FWasmChannel/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260595653,"owners_count":23033788,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary","cloudflare","nextjs","protocol","queue","real-time","rust","wasm","websocket","workers"],"created_at":"2025-06-18T17:03:07.346Z","updated_at":"2025-10-17T19:17:03.756Z","avatar_url":"https://github.com/v0id-user.png","language":"WebAssembly","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# WasmChannel 🦀\n\n**Experimental real-time chat application using Rust+WASM on Cloudflare Workers \u0026 Next.js frontend, featuring a custom binary protocol.**\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?logo=typescript\u0026logoColor=white)](https://www.typescriptlang.org/)\n[![Rust](https://img.shields.io/badge/Rust-000000?logo=rust\u0026logoColor=white)](https://www.rust-lang.org/)\n[![Next.js](https://img.shields.io/badge/Next.js-000000?logo=next.js\u0026logoColor=white)](https://nextjs.org/)\n[![Cloudflare Workers](https://img.shields.io/badge/Cloudflare-F38020?logo=cloudflare\u0026logoColor=white)](https://workers.cloudflare.com/)\n[![WebAssembly](https://img.shields.io/badge/WebAssembly-654FF0?logo=webassembly\u0026logoColor=white)](https://webassembly.org/)\n\n\u003cdiv align=\"center\"\u003e\n\n[![MADE BY #V0ID](https://img.shields.io/badge/MADE%20BY%20%23V0ID-F3EEE1.svg?style=for-the-badge)](https://github.com/v0id-user)\n\n\u003c/div\u003e\n\n\u003c/div\u003e\n\n## Overview\nWasmChannel combines the performance of WebAssembly with the scalability of Cloudflare's edge infrastructure to create a high-performance real-time chat experience in an intentionally over engineered distributed system.\n\n### Key Features\n\n- **Real-time messaging** with WebSocket connections\n- **Custom binary protocol** with LZ4 compression\n- **WebAssembly performance** for message processing\n- **Edge-first architecture** on Cloudflare Workers\n- **Authentication** via Better Auth\n- **Message reactions** with live updates\n- **Typing indicators** and user presence\n- **Persistent storage** with Cloudflare D1\n- **Optimized bandwidth** usage through compression\n\n## Architecture\n![Processing Messages Architecture](arch/prcessing_messages.png)\n\n### Core Components\n\n- **Frontend**: Next.js with React hooks for real-time UI\n- **WASM Layer**: Rust-compiled WebAssembly for high-performance packet processing as protocol layer over websocket\n- **Backend**: Cloudflare Workers \u0026 Queues for database async writes and Durable Objects for stateful connections\n- **Protocol**: Custom binary format with LZ4 compression and CRC32 validation\n\n### Message Flow Architecture\n\nThe system uses a multi-tier approach optimized for ultra-low latency and reliability:\n\n1. **WebSocket Reception** - Messages received via WebSocket connections in Durable Objects\n2. **Immediate Broadcast** - Messages instantly broadcast to all connected WebSocket clients for low latency\n3. **Cache Layer** - Messages immediately stored in Cloudflare KV for fast retrieval and temporary persistence\n4. **Queue Processing** - Messages sent to Cloudflare Queue for batch processing (10 messages or 5-second intervals)\n5. **Database Persistence** - Queue consumer processes messages in batches and persists to D1 database\n\n**Benefits:**\n- **Ultra-Low Latency** - Messages broadcast immediately to connected users before persistence\n- **Reliability** - Queue ensures messages aren't lost during high traffic\n- **Efficiency** - Batch processing reduces database load\n- **Scalability** - Queue handles traffic spikes automatically\n\n### Tech Stack\n\n**Frontend**\n- Next.js 15, React 19, TypeScript\n- Tailwind CSS, Zustand\n\n**Backend**\n- Cloudflare Workers, Hono, Durable Objects\n- Better Auth, Drizzle ORM\n\n**WebAssembly**\n- Rust, wasm-bindgen, LZ4, Bincode\n\n**Infrastructure**\n- Cloudflare D1, KV, Queues\n\n## Quick Start\n\n### Prerequisites\n- Bun or Node.js 18+\n- Rust toolchain\n- wasm-pack\n- Cloudflare account\n\n### Installation\n\n```bash\n# Clone and install\ngit clone https://github.com/v0id-user/wasmchannel.git\ncd wasmchannel\nbun install\ncd worker \u0026\u0026 bun install \u0026\u0026 cd ..\n\n# Build WASM\nbun run build:wasm:dev\n\n# Setup environment\ncp worker/.dev.vars.example worker/.dev.vars\n# Edit with your Cloudflare credentials\n\n# Start development\nbun run dev              # Terminal 1: Frontend\nbun run worker:dev       # Terminal 2: Worker\n```\n\n## Documentation\n\n- **[Cloudflare Worker Setup](worker/README.md)** - Backend deployment and configuration\n- **[Rust/WASM Development](crates/README.md)** - WebAssembly compilation and optimization\n- **[Binary Protocol Specification](#binary-protocol)** - Custom messaging protocol details\n\n## Binary Protocol\n\nWasmChannel uses a custom binary protocol for efficient communication:\n\n```rust\npub struct WasmPacket {\n    inner: Packet {\n        pub kind: PacketKind,              // Message type\n        pub message_id: Option\u003cString\u003e,    // Unique identifier  \n        pub user_id: Option\u003cString\u003e,       // Sender ID\n        pub reaction_kind: Option\u003cReactionKind\u003e, // Reaction type\n        pub payload: Vec\u003cu8\u003e,              // LZ4-compressed data\n        pub serialized: bool,              // Serialization state\n        pub crc: u32,                      // CRC32 integrity check\n    }\n}\n```\n\n**Protocol Features:**\n- LZ4 frame compression for payload optimization\n- CRC32 validation for data integrity\n- Binary serialization via Bincode\n- Type-safe packet handling in both Rust and TypeScript\n\n## Development Commands\n\n```bash\n# WASM builds\nbun run build:wasm:dev      # Development build\nbun run build:wasm:release  # Production build\n\n# Deployment\nbun run build               # Frontend build\ncd worker \u0026\u0026 bun run deploy # Worker deployment\n```\n\n## Project Structure\n\n```\nwasmchannel/\n├── app/                 # Next.js app directory\n├── components/          # React components  \n├── hooks/              # Custom React hooks\n├── crates/             # Rust WebAssembly source\n├── worker/             # Cloudflare Worker backend\n├── types/              # TypeScript definitions\n└── utils/              # Shared utilities\n```\n\n## License\n\nMIT License - see [LICENSE](LICENSE) for details.\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**Built with ❤️ by [@v0id_user](https://x.com/v0id_user)**\n\n*This is an experimental project. It's meant to be a learning experience for me.*\n\n**⚠️ Important Notice:**\nThis project is incomplete and experimental. Several features like proper message fetching and reaction systems are not fully implemented. Host and use this at your own risk as things may break. The primary purpose of this project was for my learning experience, and it has served that purpose.\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv0id-user%2Fwasmchannel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fv0id-user%2Fwasmchannel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv0id-user%2Fwasmchannel/lists"}