A Trillion Characters
3 hours ago
- #Realtime Collaboration
- #Backend Architecture
- #Datastar Framework
- 'Trillion Characters' is a real-time collaborative experiment built using Datastar, allowing users to type on a canvas and see others' cursors in real-time.
- Datastar is a lightweight framework that moves all interactive logic to the backend, streaming HTML updates via server-sent events (SSE) for a 'movie-like' experience, with compression techniques like Brotli reducing bandwidth usage significantly.
- The backend uses CQRS (Command Query Responsibility Segregation) architecture to separate reads and writes, enabling real-time collaboration by queuing commands and rendering state into HTML templates customized per client.
- Characters are stored in 45x45 chunks using LMDB, a memory-mapped key-value store, with LZ4 compression and Z-order mapping via morton codes for efficient 2D to 1D storage locality, ensuring full ACID compliance for data reliability.
- The application runs on a €5.52 VPS in Germany, emphasizing low cost and scalability, and is credited to Elias de Jong with an open-source link provided.