flow-pie / flow-pie/chamaa.api
Real-time voting (socket.io / SignalR)
- Dominant language
- HTML
- Stars
- 3
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
### Objective
Provide a real-time voting experience (live updates) for proposal voting and results using websockets (Socket.io for Node.js or SignalR for .NET).
### Description
When members vote, other group members should see the updated tally and vote counts in near-real-time. This requires a websocket layer that pushes vote events, finalization events, and status changes from backend to connected clients. It should be scalable and respect authentication & authorization (only members of the group receive updates).
### Key Tasks
- Add websocket server:
- Node.js: Socket.io server integrated with NestJS/Express
- .NET: SignalR hub integrated into ASP.NET app
- Define real-time channels/rooms by `groupId` and `proposalId`
- Emit events:
- `vote_cast` → broadcast incremental tally and recent voter (obfuscated if privacy required)
- `proposal_finalized` → final result + tx hash (if on-chain)
- `proposal_update` → status changes (started/ended)
- Ensure authentication:
- Validate JWT on connection and join only allowed rooms
- Implement debounce/throttle logic to avoid event flooding
- Add client-side sample (Android or web) demonstrating socket connection and real-time UI update
- Add tests for concurrent votes (simulate multiple clients)
### Acceptance Criteria
- [ ] Socket server authenticates connections and joins correct rooms
- [ ] Voting from one client updates all connected clients within <1s (network dependent)
- [ ] Events include enough context: proposalId, new counts, time remaining
- [ ] On finalize, clients receive final result and backend logs the finalization action
- [ ] Rate limiting / throttling implemented to protect from spam
### Tech Notes / Suggestions
- Use Redis adapter for Socket.io if scaled across multiple nodes
- Secure websockets with TLS in production
- For mobile: implement a lightweight client that reconnects reliably and handles network drops
### Labels
`realtime`, `backend`, `feature`, `scalability`
Contributor guide
Assessment
This issue has not been assessed yet.