44 lines
1.6 KiB
Markdown
44 lines
1.6 KiB
Markdown
# P2P Poll App
|
|
|
|
A peer-to-peer polling application where users create and vote on polls without any central server. All data syncs directly between browsers using WebRTC and CRDTs.
|
|
|
|
## Features
|
|
|
|
- **Real-time P2P sync** — poll options and votes sync instantly across all connected peers via WebRTC
|
|
- **Collaborative poll title** — editable title that syncs between all participants
|
|
- **One vote per user** — each peer gets a stable ID, enforcing one vote per person per option
|
|
- **Vote/Unvote toggle** — change your mind anytime
|
|
- **Connection status** — see when you're connected and how many peers are in the room
|
|
- **Shareable polls** — share via URL with `?room=your-poll-name`
|
|
- **No backend required** — runs entirely in the browser
|
|
|
|
## Tech Stack
|
|
|
|
- [Yjs](https://yjs.dev/) — CRDT library for conflict-free shared state
|
|
- [y-webrtc](https://github.com/yjs/y-webrtc) — WebRTC provider for peer-to-peer connections
|
|
- [Vite](https://vitejs.dev/) — Development server and build tool
|
|
- Vanilla JavaScript — no framework dependencies
|
|
|
|
## Getting Started
|
|
|
|
```bash
|
|
npm install
|
|
npm run dev
|
|
```
|
|
|
|
Open `http://localhost:5173/?room=my-poll` in multiple browser tabs to test.
|
|
|
|
To test across devices on the same network:
|
|
|
|
```bash
|
|
npm run dev -- --host
|
|
```
|
|
|
|
Then open the URL shown in the terminal on other devices.
|
|
|
|
## How It Works
|
|
|
|
1. Each browser tab creates a Yjs document and connects to other peers via WebRTC
|
|
2. Poll options and votes are stored in Yjs shared data types (Y.Map)
|
|
3. Changes propagate automatically to all connected peers using CRDTs
|
|
4. A public signaling server handles peer discovery; all poll data flows directly between browsers |