PulsePoll is a production live polling web application built for the HCL GUVI Full Stack Development Internship Selection Assignment.
It enables creators to build interactive polls, share public links with audiences, and observe real-time vote updates over persistent WebSocket connections without manual page refreshes.
PulsePoll is fully deployed and accessible on the public internet:
| Component | URL / Endpoint | Infrastructure |
|---|---|---|
| Frontend Application | https://pulsepoll-frontend.onrender.com | Render (Static Site with SPA rewrite) |
| Backend REST API | https://pulsepoll-backend.onrender.com/api | Render (Docker Web Service) |
| Public Health Check | https://pulsepoll-backend.onrender.com/api/health | Live dependency probe (mongodb: ok, redis: ok) |
| Realtime WebSocket | wss://pulsepoll-backend.onrender.com/api/polls/:id/ws |
Go / Gorilla WebSocket over WSS |
| Database | MongoDB Atlas (Cluster0 M0) | Managed Cloud Database |
| Cache & Realtime Broker | Render KeyValue (Redis 7) | Managed In-Memory Data Store |
| GitHub Repository | https://github.com/balax-24/pulsepoll-HCL_GUVI | Source Code & CI/CD Spec |
| Layer | Technology | Primary Architectural Responsibility |
|---|---|---|
| Frontend | React 19, Vite, Vanilla CSS | Responsive audience voting UI, animated live result bars, custom SVG icon system, WebSocket stream consumer |
| Backend | Go 1.23, Gin Web Framework | Concurrency-safe REST API, payload validation, JWT authentication, WebSocket connection hub |
| Database | MongoDB 7.0 | Authoritative persistence for users, polls, options, and immutable vote audit logs |
| Cache & Realtime | Redis 7.0 | Atomic live vote tallying (HINCRBY) and cross-instance event distribution via Redis Pub/Sub |
- Dual-Layer Storage: Separates durable disk persistence (MongoDB) from in-memory live counter aggregation (Redis).
- Atomic Concurrency: Vote counting uses atomic Redis
HINCRBYoperations, eliminating lost updates and race conditions under concurrent submissions. - Push-Based Updates: Connected audience clients receive vote events via persistent WebSocket connections, avoiding periodic polling loops.
- Strict Data Integrity: MongoDB unique compound indexes
(poll_id, voter_id)enforce single-vote rules at the database engine level.
[ Audience Client (React) ]
│ (HTTP POST /api/polls/:id/vote)
▼
[ Go / Gin Backend ]
├── 1. Validates poll lifecycle (active, not expired, valid option)
├── 2. Persists immutable vote audit document to MongoDB (unique index prevents duplicates)
├── 3. Atomically increments option tally in Redis (HINCRBY poll:{id}:votes {opt} 1)
└── 4. Publishes lightweight JSON event to Redis Pub/Sub (poll:{id}:updates)
│
▼
[ Redis Broker ]
│
▼
[ Go WebSocket Hub ] ─── (Broadcasts JSON frame over WSS) ───► [ Connected Audience Clients ]
.
├── docker-compose.yml # Local dev services: MongoDB (27017) & Redis (6380)
├── docker-compose.prod.yml # Self-hosted production stack with Nginx & persistent volumes
├── render.yaml # Render Blueprint for automated cloud deployment
├── .env.example # Unified configuration reference
├── .gitignore # Production-safe exclusions (secrets, builds, temp files)
├── README.md # System documentation & assignment alignment
├── backend/
│ ├── cmd/
│ │ └── server/
│ │ └── main.go # Application entrypoint, route wiring & graceful shutdown
│ ├── internal/
│ │ ├── config/ # Environment loader with type validation
│ │ ├── database/
│ │ │ ├── mongodb/ # MongoDB connection lifecycle & health ping
│ │ │ └── redis/ # Redis connection lifecycle & health ping
│ │ ├── health/ # Dependency health check endpoint (/health & /api/health)
│ │ ├── middleware/ # Structured slog logger, panic recovery, CORS handler
│ │ ├── response/ # Standardized JSON envelopes & structured error codes
│ │ ├── auth/ # User registration, bcrypt hashing, JWT issuance & auth middleware
│ │ ├── polls/ # Poll domain model, CRUD, creator ownership & lifecycle
│ │ ├── votes/ # Dual-layer voting engine (MongoDB audit log + Redis hash counters)
│ │ └── websocket/ # Dynamic PollHub registry, Redis Pub/Sub listener & WSS broadcaster
│ ├── Dockerfile # Multi-stage Alpine container build
│ ├── go.mod # Go module dependencies
│ └── go.sum # Cryptographic checksums
└── frontend/
├── src/
│ ├── api/
│ │ ├── client.js # Centralized fetch wrapper with JWT bearer injection & error normalization
│ │ ├── auth.js # Authentication endpoints (register, login, getMe)
│ │ ├── polls.js # Poll management endpoints (create, getPublic, getMy, update, close, delete)
│ │ └── votes.js # Voting and results endpoints (castVote, getResults)
│ ├── components/
│ │ ├── Alert.jsx # Dismissible notification banner
│ │ ├── Footer.jsx # Application branding and navigation footer
│ │ ├── Icons.jsx # Handcrafted SVG icon library (Zero external font dependencies)
│ │ ├── LiveBadge.jsx # Real-time connection indicator (Connected, Connecting, Reconnecting, Offline)
│ │ ├── Navbar.jsx # Navigation bar with dynamic authentication state
│ │ ├── PollCard.jsx # Creator dashboard card with one-click link sharing & actions
│ │ ├── PollResults.jsx # Animated result bars with W3C ARIA progress semantics
│ │ └── ProtectedRoute.jsx # Client-side route guard with session restoration
│ ├── context/
│ │ └── AuthContext.jsx # Authentication state provider with automatic session verification
│ ├── hooks/
│ │ └── usePollWebSocket.js # WebSocket hook with bounded exponential backoff & cleanup
│ ├── pages/
│ │ ├── HomePage.jsx # Landing page with architectural overview & interactive product preview
│ │ ├── LoginPage.jsx # Creator sign-in with password toggle & validation
│ │ ├── RegisterPage.jsx # Creator registration with 8-char validation & auto-login
│ │ ├── DashboardPage.jsx # Creator poll management dashboard with search, metrics & filters
│ │ ├── CreatePollPage.jsx # Dynamic poll builder (2–10 options) with share modal
│ │ ├── PublicPollPage.jsx # Public voting interface & live animated results
│ │ └── ManagePollPage.jsx # Creator poll administration console (close, delete, edit)
│ ├── test/ # Vitest component & integration test suite
│ ├── App.jsx # React Router route hierarchy
│ ├── index.css # Linear-inspired design system with CSS custom properties
│ └── main.jsx # Application mount
├── Dockerfile # Production Nginx container build
├── package.json # Node.js dependencies and scripts
└── vite.config.js # Vite build & test configuration
| Setting | Local Development | Production Cloud Deployment |
|---|---|---|
| Frontend Host | Vite Dev Server (http://localhost:5173) |
Render Static Site (https://pulsepoll-frontend.onrender.com) |
| Backend Host | Local Go Process (http://localhost:8080) |
Render Docker Web Service (https://pulsepoll-backend.onrender.com) |
| WebSocket Scheme | Unencrypted WebSocket (ws://localhost:8080/api/...) |
TLS Encrypted WebSocket (wss://pulsepoll-backend.onrender.com/api/...) |
| MongoDB | Local Docker Container (mongodb://localhost:27017) |
MongoDB Atlas Managed Replica Set (mongodb+srv://...) |
| Redis | Local Docker Container (redis://localhost:6380) |
Render KeyValue Managed Redis (rediss://...) |
| Session Cookies | SameSite=Lax, Secure=false |
SameSite=None, Secure=true, HttpOnly=true |
| CORS Origins | http://localhost:5173,http://127.0.0.1:5173 |
https://pulsepoll-frontend.onrender.com |
- Go 1.23+
- Node.js 20+ and npm
- Docker and Docker Compose
docker compose up -d
- MongoDB is mapped to
localhost:27017 - Redis is mapped to
localhost:6380(avoids colliding with default port 6379)
cp backend/.env.example backend/.env
cd backend
go run cmd/server/main.goVerify the server is running:
curl http://localhost:8080/health
Response:
{
"status": "ok",
"services": {
"mongodb": "ok",
"redis": "ok"
}
}cd frontend
cp .env.example .env
npm install
npm run devOpen http://localhost:5173 in your browser.
PulsePoll implements secure, state-free authentication for poll creators using bcrypt (cost 10) for password hashing and signed JWT (HMAC-SHA256) for request authorization.
| Method | Endpoint | Auth Required | Description |
|---|---|---|---|
POST |
/api/auth/register |
No | Creates a creator account; enforces unique normalized email & minimum 8-char password |
POST |
/api/auth/login |
No | Validates credentials; returns signed JWT and safe user profile DTO |
GET |
/api/auth/me |
Yes (Bearer <token>) |
Returns profile information for the authenticated creator |
- Password Hashing: Passwords are saved only as bcrypt hashes. Plaintext passwords are never logged or stored.
- Email Normalization: Emails are trimmed and converted to lowercase before uniqueness verification, preventing case-manipulation duplicates (
[email protected]vs[email protected]). - Timing-Safe Generic Errors: Login returns a generic
401 Unauthorized(Invalid email or password) to eliminate account enumeration attacks. - JWT Verification: Tokens include standard
iss,sub,iat, andexpclaims with strict signature validation against HMAC-SHA256.
PulsePoll provides a structured domain model and REST API for poll creation, audience discovery, and ownership-guarded poll administration.
{
"id": "6aa9eac27795b69d0e40874d",
"creator_id": "6aa9eac27795b69d0e408747",
"question": "Which architecture pattern fits your team best?",
"options": [
{ "id": "6aa9eac27795b69d0e408749", "text": "Modular Monolith" },
{ "id": "6aa9eac27795b69d0e40874a", "text": "Microservices" },
{ "id": "6aa9eac27795b69d0e40874b", "text": "Event-Driven Serverless" }
],
"status": "active",
"created_at": "2026-09-16T01:02:58.775Z",
"updated_at": "2026-09-16T01:02:58.775Z"
}Option Stability: Each poll option is assigned a stable, globally unique ObjectID at creation time. This ID remains consistent across all voting submissions, Redis counters, and WebSocket broadcast payloads.
- JWT Identity: The creator identity is extracted strictly from the verified JWT claim (
sub), preventing unauthorized manipulation ofcreator_id. - Ownership Verification: Mutating operations (
PATCH,DELETE, status transitions) verify thatpoll.creator_id == authenticated_user_id. Unauthorized requests receive403 Forbidden. - Scoped Dashboard:
GET /api/my/pollsreturns only polls belonging to the authenticated user, ordered newest first.
| Method | Endpoint | Auth Required | Description |
|---|---|---|---|
POST |
/api/polls |
Yes (Bearer <token>) |
Creates a new active poll with 2–10 options |
GET |
/api/polls/:id |
No (Public) | Retrieves sanitized poll details for audience view |
GET |
/api/my/polls |
Yes (Bearer <token>) |
Returns paginated list of polls owned by the creator |
PATCH |
/api/polls/:id |
Yes (Owner only) | Updates question or option texts while preserving stable IDs |
PATCH |
/api/polls/:id/status |
Yes (Owner only) | Transitions lifecycle status (e.g. {"status": "closed"}) |
POST |
/api/polls/:id/close |
Yes (Owner only) | Dedicated endpoint to idempotently close a poll |
DELETE |
/api/polls/:id |
Yes (Owner only) | Soft-deletes poll; preserves audit integrity for vote records |
PulsePoll features a concurrency-safe, dual-layer voting system combining durable audit records in MongoDB with in-memory atomic counters in Redis.
{
"_id": ObjectId("6aa9ed250cf658f70a932a88"),
"poll_id": "6aa9ed250cf658f70a932a87",
"option_id": "6aa9ed250cf658f70a932a84",
"voter_id": "9be105f2ec74d293a2a62ba8f97706c6",
"created_at": ISODate("2026-09-16T01:13:09.181Z")
}Live vote counting is executed in-memory using Redis Hashes:
- Key Schema:
poll:{pollID}:votes - Fields:
{optionID} -> {count} - Atomic Mutation: Increments are performed strictly via
HINCRBY poll:{pollID}:votes {optionID} 1(preventing read-modify-write lost updates).
redis-cli HGETALL poll:6aa9ed250cf658f70a932a87:votes 1) "6aa9ed250cf658f70a932a84" 2) "42" 3) "6aa9ed250cf658f70a932a85" 4) "18"
- Session Resolution: Audience participants receive a cryptographically random 128-bit session token generated server-side.
- Dual Transmission: Stored in an
HttpOnlycookie (pulsepoll_voter_id) and mirrored inX-Voter-IDresponse headers for programmatic clients. - Database Concurrency Barrier: MongoDB enforces a unique compound index on
(poll_id, voter_id). Concurrent requests from the same session race at the database layer; exactly one insert succeeds, while duplicate submissions return409 Conflict(DUPLICATE_VOTE).
- Write Order: MongoDB durable persistence occurs first. If MongoDB rejects the vote (due to duplicate key or validation error), Redis is never touched.
- Crash Reconciliation: If Redis restarts or drops in-memory keys, the service detects the missing hash and reconstructs counters directly from MongoDB aggregation pipelines using
HSETNX.
| Method | Endpoint | Auth Required | Description |
|---|---|---|---|
POST |
/api/polls/:id/vote |
No (Public) | Casts a vote; validates voter session; persists to MongoDB; increments Redis live count |
GET |
/api/polls/:id/results |
No (Public) | Returns vote tallies and calculated percentages from Redis live counters |
| Component | Responsibility |
|---|---|
| MongoDB | Durable source of truth for users, polls, options, and immutable vote records. |
Redis Hash (poll:{id}:votes) |
Authoritative live counter aggregation. Modified strictly via atomic HINCRBY. |
Redis Pub/Sub (poll:{id}:updates) |
Realtime event transport distributing vote notifications across server instances. |
Go WebSocket Gateway (PollHub) |
Concurrency-safe client registry. Pre-validates polls before upgrade. Dynamically provisions Redis subscriptions on first client join; cancels them on last client exit. Dispatches ping/pong keepalives and isolates slow clients via buffered channels. |
| React Frontend Client | Consumer of WebSocket streams. Merges initial snapshot and incremental live vote updates into UI state without page reload. |
- Access: Public audience endpoint (no creator auth required).
- Pre-Validation: Checks hex ObjectID format and verifies poll existence in MongoDB before completing the HTTP-to-WebSocket upgrade.
- Closed Poll Support: Audience members can connect to closed polls to view final results. When an active poll is closed by its creator, a terminal
poll_closedevent is broadcast to all connected viewers while preserving the connection.
Sent immediately upon WebSocket connection to establish the baseline:
{
"type": "results_snapshot",
"poll_id": "6aa9ed250cf658f70a932a87",
"options": [
{
"option_id": "6aa9ed250cf658f70a932a84",
"text": "Go",
"count": 12,
"votes": 12,
"percentage": 60.0
},
{
"option_id": "6aa9ed250cf658f70a932a85",
"text": "Rust",
"count": 8,
"votes": 8,
"percentage": 40.0
}
],
"total_votes": 20
}Broadcast whenever an audience member casts a valid vote:
{
"type": "vote_update",
"poll_id": "6aa9ed250cf658f70a932a87",
"option_id": "6aa9ed250cf658f70a932a84",
"count": 13,
"total_votes": 21,
"timestamp": "2026-09-16T01:38:25.619Z"
}Privacy Note: Realtime update events never include voter identifiers, session cookies, JWTs, or IP addresses.
Broadcast when the creator closes the poll:
{
"type": "poll_closed",
"poll_id": "6aa9ed250cf658f70a932a87",
"timestamp": "2026-09-16T01:38:38.572Z"
}PulsePoll features a modern, responsive single-page web interface built with React 19, Vite, and a cohesive dark-mode design system inspired by tools like Linear and GitHub.
Important
Homepage Product Preview vs. Production Polls: The homepage features an interactive Product Preview card designed strictly for product demonstration and onboarding. It simulates the voting interaction locally in the browser with sample options to illustrate the user experience.
In contrast, actual polls accessed via /polls/:id and /polls/:id/manage connect directly to the production Go/Gin backend and Redis Pub/Sub WebSocket streaming infrastructure (wss://pulsepoll-backend.onrender.com/api/polls/:id/ws).
- Handcrafted SVG Icon System (
Icons.jsx): Comprehensive set of vector icons crafted specifically for PulsePoll, eliminating external font dependencies or icon bloat. - Centralized API Client (
client.js): Handles URL configuration, JWT bearer injection, cookie credential transmission, and structured error code normalization. - Resilient WebSocket Hook (
usePollWebSocket.js): Implements bounded exponential backoff (1s, 2s, 4s, up to 10s), ping/pong resilience, and React 19 StrictMode cleanup. - Smooth Animations: Real-time result progress bars update smoothly using CSS transitions (
transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1)). - Accessibility: W3C ARIA progressbar semantics, visible keyboard focus rings (
:focus-visible), labeled inputs, and@media (prefers-reduced-motion: reduce)support.
| Route | Access | Purpose |
|---|---|---|
/ |
Public | Marketing landing page with interactive preview & architecture walkthrough |
/login |
Public | Creator sign-in with password toggle & validation |
/register |
Public | Creator registration with auto-login into dashboard |
/polls/:id |
Public | Public audience voting & live real-time results (No authentication required) |
/dashboard |
Protected | Creator dashboard listing all created polls, metrics, and filters |
/polls/create |
Protected | Dynamic poll builder (2 to 10 options) with share modal |
/polls/:id/manage |
Protected | Creator poll administration console (close, delete, update question) |
PulsePoll is deployed using Render's Infrastructure as Code blueprint (render.yaml):
[ React SPA (Render Static Site) ]
│
HTTPS / WSS
│
▼
[ Go / Gin API Server ]
(Render Docker Service)
/ \
/ \
▼ ▼
[ MongoDB Atlas Cluster0 ] [ Render KeyValue Redis ]
(Durable Persistence) ├── Live Counters (Hash)
└── Realtime Broker (Pub/Sub)
│
▼
[ Go WebSocket Hub ]
│ (wss://)
▼
[ Active Browser Clients ]
- REST Calls: The frontend automatically routes requests to
https://pulsepoll-backend.onrender.com/api. - WebSocket Connections: Dynamically resolves to
wss://pulsepoll-backend.onrender.com/api/polls/:id/ws. - Cross-Site Cookies: The anonymous voter session cookie (
pulsepoll_voter_id) usesSameSite=None; Secure=true; HttpOnly=true; Path=/when served over HTTPS, allowing session persistence across distinct Render domains.
For self-hosted environments, PulsePoll includes docker-compose.prod.yml:
# Launch self-hosted production stack
docker compose -f docker-compose.prod.yml up -d --buildThis deploys containerized MongoDB with persistent volumes, Redis with append-only file (AOF) persistence, the Go API server, and Nginx serving the production React bundle with SPA routing.
From the backend/ directory:
# Run all unit and integration tests with Go race detector enabled go test -race -count=1 ./... # Run static analysis go vet ./...
Result: 100% of internal packages (auth, config, health, middleware, polls, response, votes, websocket) pass with zero race conditions or vet warnings.
From the frontend/ directory:
# Run Vitest test suite npm test -- --run # Run Oxlint static analysis npm run lint # Build production bundle npm run build
Result: 16/16 Vitest tests passing, 0 linter errors, and clean production asset bundling.
PulsePoll includes a 19-step automated production test suite verifying the live Render deployment:
go run verify_public_deployment.go
Test Coverage:
- Health check returns MongoDB and Redis status as
ok. - Creator registration and login via JWT.
- Authenticated session validation (
/api/auth/me). - Poll creation with multiple options.
- Creator dashboard retrieval (
/api/my/polls). - Unauthenticated public poll access (
/api/polls/:id). - Multi-client WebSocket connection over WSS (
Client AandClient B). - Initial state snapshot delivery upon connection.
- Bidirectional live vote updates propagated over WSS without page refresh.
- Duplicate vote rejection (
HTTP 409 DUPLICATE_VOTE). - Creator poll closure and broadcast of
poll_closedevent over WSS. - Vote rejection on closed polls (
HTTP 409 POLL_CLOSED). - Direct SPA route navigation without 404s.
| # | Assignment Requirement | Implementation Detail | Verified Status |
|---|---|---|---|
| 1 | React Frontend | Built with React 19, Vite, responsive Linear-inspired design system | Verified |
| 2 | Go / Gin Backend | REST API and WebSocket gateway built with Go 1.23 & Gin | Verified |
| 3 | MongoDB Persistence | MongoDB 7.0 (Atlas M0 in prod) stores users, polls, options & vote audit logs | Verified |
| 4 | Redis Realtime Engine | Redis 7.0 handles atomic counters (HINCRBY) and Pub/Sub event distribution |
Verified |
| 5 | Poll Creation | Creator form supports 2–10 options, dynamic option management, and instant link generation | Verified |
| 6 | Shareable Public Link | Public route /polls/:id accessible by anyone without login or signup |
Verified |
| 7 | Audience Voting Flow | Public audience selects option, submits vote, and receives immediate confirmation | Verified |
| 8 | Realtime Updates Without Refresh | Connected clients receive live vote updates via WebSockets and animated progress bars | Verified |
| 9 | Creator Authentication | JWT-protected routes for poll creation, dashboard, editing, closing, and deletion | Verified |
| 10 | Input & Concurrency Validation | Backend validates question length, option limits, and enforces single-vote rules | Verified |
| 11 | Public Cloud Deployment | Frontend & Backend deployed on Render; MongoDB on Atlas; Redis on Render KeyValue | Verified |
| 12 | Public GitHub Repository | Complete source code, Docker configs, documentation, and tests on GitHub | Verified |
For evaluator demonstrations and video recordings, follow this sequence:
- Open Public Application: Navigate to
https://pulsepoll-frontend.onrender.com. Point out the system architecture and the interactive demo preview. - Register/Login Creator: Click Sign In or Get Started. Log in with creator credentials (or register a new account).
- Explore Dashboard: View existing polls, status badges (Active/Closed), and total vote metrics.
- Create a New Poll: Click Create Poll. Enter a question (e.g. "Which distributed caching architecture do you prefer?") with 3 options:
- Option 1:
Redis Cluster - Option 2:
Memcached Distributed - Option 3:
Dragonfly In-Memory
- Option 1:
- Copy Shareable Link: Click Create Poll & Get Link, then use the Copy Link button from the share modal.
- Open Split-Screen Audience View: Open two browser windows side by side (e.g., standard browser as Client A, incognito/private window as Client B) navigating to the public poll URL
/polls/:id. - Inspect Real-Time Indicator: Show the green Live badge indicating active WebSocket connection over WSS.
- Vote from Client A: Cast a vote for Option 1 in Client A.
- Observe Realtime Propagation: Point out that Client B's progress bar and vote tally update immediately without any page refresh.
- Vote from Client B: Cast a vote for Option 2 in Client B. Observe Client A updating immediately.
- Demonstrate Duplicate Protection: Attempt to vote again in Client A. Show the friendly duplicate prevention alert: "You have already voted in this poll."
- Close Poll from Creator Console: Switch to the Creator Dashboard/Manage screen and click Close Poll.
- Observe Closed Broadcast: Both audience screens receive the
poll_closedevent, transitioning the status badge to Voting Closed and disabling the vote button. - Architecture Summary: Conclude by explaining the technical separation: durable MongoDB vote audit logs + in-memory Redis atomic counters + Redis Pub/Sub WebSocket event distribution.
- Render Free-Tier Cold Starts: On Render's free tier, the backend web service spins down after 15 minutes of inactivity. The first request after a sleep cycle may experience an initial spin-up latency (~30–50 seconds). Once warm, requests respond normally.
- Cross-Site Cookie Privacy Settings: In strict privacy browsers (e.g. Brave shields or Safari with cross-site tracking blocked), third-party cookies across differing domains (
onrender.com) may be restricted. PulsePoll gracefully handles this by falling back tolocalStorageandX-Voter-IDheaders. - In-Memory Cache Reconciliation: Redis is treated as an ephemeral live counter cache, while MongoDB remains the durable source of truth. In the event of a Redis restart, the application automatically reconstructs counters directly from MongoDB vote aggregation.