Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anthonycorletti/modal-crdts
Multiplayer on Modal
https://github.com/anthonycorletti/modal-crdts
crdt fastapi modal quill sqlite yjs ypy ypy-websocket
Last synced: 12 days ago
JSON representation
Multiplayer on Modal
- Host: GitHub
- URL: https://github.com/anthonycorletti/modal-crdts
- Owner: anthonycorletti
- Created: 2024-10-04T16:09:05.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-10-24T15:41:52.000Z (20 days ago)
- Last Synced: 2024-10-24T19:25:21.160Z (20 days ago)
- Topics: crdt, fastapi, modal, quill, sqlite, yjs, ypy, ypy-websocket
- Language: Python
- Homepage:
- Size: 179 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# modal-crdts
[CRDTs (Conflict-free Replicated Data Types)](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type) are really useful data structures. CRDTs are often used in certain distributed systems to propagate changes across databases and file systems shared by multiple participants.
This example shows how you can leverage CRDTs via Yjs and websockets on [Modal](https://modal.com) to make a multiplayer text editing application.
> [!WARNING]
> This is meant for demo and learning purposes. Do not use this in production as is. CRDTs in production and at scale operate better with a primary caching layer and a secondary storage layer. You could use redis or valkey for caching and sql, object, or file storage for the secondary layer.This example uses:
- FastAPI to host the web service
- Sqlite for storing document updates
- Ypy and Ypy-websocket for handling server side CRDT updates
- Yjs for client side awareness, editing, and rendering
- Quill for the editor
- ...and it all runs on [Modal](https://modal.com)You'll notice that `app/static` has some javascript in it. That code is built from the code you'll find in the `web` directory.
Running `bun run build` from the `web` directory creates the client side js that's loaded by the html page.
To deploy this to modal and try it out for yourself, clone this repository and run `bin/deploy-modal`.
So where do we go from here? Maybe...
- Plugging in AI APIs as players that serve content through websockets
- Serving more than one room (right now this application only serves one room, `quill-demo`)