forked from quic-issues/427e7578-d7bf-49c8-aee9-2dd999e25316
- Add peer-to-peer polling with real-time synchronization via PeerJS - Implement vote changing, unvoting, and proper vote validation - Add modal interface for adding poll options - Fix vote inheritance issues for new users joining rooms - Create sidebar with available polls and connected peers - Add vote count synchronization across all connected peers - Implement proper vote state validation per user - Add localStorage persistence for polls and vote states - Create responsive design with modern UI components - Replace emojis with proper text-based icons - Add comprehensive error handling and user feedback - Support multiple polls with switching capabilities - Implement conflict resolution for concurrent voting
57 lines
2.0 KiB
Markdown
57 lines
2.0 KiB
Markdown
# P2P Poll App
|
|
|
|
A peer-to-peer polling application where users can create polls, add options, and vote in real-time without a central server.
|
|
|
|
## Features
|
|
|
|
- **Real-time P2P voting** using WebRTC via PeerJS
|
|
- **Dynamic option management** - add/remove options during polling
|
|
- **Duplicate vote prevention** - one vote per user
|
|
- **Automatic data synchronization** across all connected peers
|
|
- **Local storage persistence** for poll recovery
|
|
- **Responsive design** works on desktop and mobile
|
|
- **No server required** - uses PeerJS free signaling service
|
|
|
|
## How to Use
|
|
|
|
1. **Open the app** in your browser (open `index.html`)
|
|
2. **First user (Host)**: Leave the Peer ID field empty and click "Connect to Host"
|
|
3. **Copy your Peer ID** using the "Copy Your Peer ID" button
|
|
4. **Share your Peer ID** with other users (via chat, email, etc.)
|
|
5. **Other users**: Paste the host's Peer ID and click "Connect to Host"
|
|
6. **Create a poll** with question and options
|
|
7. **Vote** by clicking on options (one vote per person)
|
|
8. **Watch results** update in real-time across all devices
|
|
|
|
## Technical Details
|
|
|
|
- **P2P Library**: PeerJS (WebRTC-based)
|
|
- **Frontend**: Vanilla JavaScript with modern CSS
|
|
- **Data Sync**: Custom conflict resolution for concurrent operations
|
|
- **Storage**: localStorage for basic persistence
|
|
- **Network**: Full mesh topology where each peer connects to all others
|
|
|
|
## File Structure
|
|
|
|
```
|
|
├── index.html # Main application
|
|
├── css/
|
|
│ └── styles.css # Application styling
|
|
└── js/
|
|
├── app.js # Main application logic
|
|
├── peer-manager.js # P2P connection handling
|
|
├── poll-manager.js # Poll data and sync logic
|
|
└── ui-controller.js # UI interactions
|
|
```
|
|
|
|
## Browser Support
|
|
|
|
Requires modern browsers with WebRTC support:
|
|
- Chrome 23+
|
|
- Firefox 22+
|
|
- Safari 11+
|
|
- Edge 79+
|
|
|
|
## Development
|
|
|
|
Simply open `index.html` in a browser - no build process required. For testing with multiple peers, open the app in multiple browser tabs or windows. |