{"id":31675060,"url":"https://github.com/rudranshfly/realtime-polling","last_synced_at":"2025-10-08T04:59:37.259Z","repository":{"id":314701124,"uuid":"1055237859","full_name":"RUDRANSHFLY/realtime-polling","owner":"RUDRANSHFLY","description":"a realtime polling where users can create pole and view polls ","archived":false,"fork":false,"pushed_at":"2025-10-04T03:02:40.000Z","size":584,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-04T05:24:02.156Z","etag":null,"topics":["nestjs","prisma","prismaorm","typescript","websocket"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RUDRANSHFLY.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-12T01:26:58.000Z","updated_at":"2025-10-04T03:03:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"125b406d-e45b-45a8-a81a-73038ad8b4f9","html_url":"https://github.com/RUDRANSHFLY/realtime-polling","commit_stats":null,"previous_names":["rudranshfly/realtime-polling"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RUDRANSHFLY/realtime-polling","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RUDRANSHFLY%2Frealtime-polling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RUDRANSHFLY%2Frealtime-polling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RUDRANSHFLY%2Frealtime-polling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RUDRANSHFLY%2Frealtime-polling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RUDRANSHFLY","download_url":"https://codeload.github.com/RUDRANSHFLY/realtime-polling/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RUDRANSHFLY%2Frealtime-polling/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278891741,"owners_count":26063856,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nestjs","prisma","prismaorm","typescript","websocket"],"created_at":"2025-10-08T04:59:36.243Z","updated_at":"2025-10-08T04:59:37.248Z","avatar_url":"https://github.com/RUDRANSHFLY.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Realtime Polling 🎯\n\nA full-stack **NestJS + Prisma + Socket.IO** app for creating polls, voting, and seeing results update in real time.\n\n---\n\n## Features\n\n* **Authentication** (JWT-based):\n\n  * Sign up and log in with email/password\n* **Poll Management**:\n\n  * Create polls with options\n  * Publish or keep drafts\n  * List all polls or only published ones\n  * Get all polls created by the logged-in user\n* **Voting**:\n\n  * Vote for options via REST API\n  * See live vote counts via WebSocket broadcasts\n* **User Management**:\n\n  * View all users (admin/debug route)\n* **Realtime Updates**:\n\n  * Clients in a poll room get notified immediately when someone votes\n\n---\n\n## Tech Stack\n\n* **Backend**: NestJS (TypeScript)\n* **Database**: Prisma ORM\n* **Realtime**: Socket.IO Gateway\n* **Auth**: JWT (jsonwebtoken)\n* **Other**: ESLint, Prettier, Jest\n\n---\n\n## Installation\n\n1. Clone repository:\n\n   ```bash\n   git clone https://github.com/RUDRANSHFLY/realtime-polling.git\n   cd realtime-polling\n   ```\n\n2. Install dependencies:\n\n   ```bash\n   npm install\n   ```\n\n3. Configure environment:\n\n   Create `.env`:\n\n   ```\n   DATABASE_URL=postgresql://user:password@localhost:5432/realtime_polling\n   JWT_SECRET=123456\n   PORT=3000\n   ```\n\n4. Setup Prisma:\n\n   ```bash\n   npx prisma migrate dev\n   npx prisma generate\n   ```\n\n5. Run project:\n\n   ```bash\n   npm run start:dev\n   ```\n\n---\n\n## API Documentation\n\n👉 After starting the server, open [http://localhost:3000/api](http://localhost:3000/api) to explore **Swagger API docs**.\n\n---\n\n## REST API Endpoints\n\nAll routes are prefixed with `/api`.\n\n### Auth\n\n| Method | Endpoint           | Description       | Body Example                                                            |\n| ------ | ------------------ | ----------------- | ----------------------------------------------------------------------- |\n| POST   | `/api/auth/signup` | Register new user | `{ \"name\": \"John\", \"email\": \"john@example.com\", \"password\": \"secret\" }` |\n| POST   | `/api/auth/signin` | Login user        | `{ \"email\": \"john@example.com\", \"password\": \"secret\" }`                 |\n\n---\n\n### Users\n\n| Method | Endpoint     | Description   |\n| ------ | ------------ | ------------- |\n| GET    | `/api/users` | Get all users |\n\n---\n\n### Poll\n\n| Method | Endpoint                | Description                             |\n| ------ | ----------------------- | --------------------------------------- |\n| GET    | `/api/poll`             | Get all published polls                 |\n| GET    | `/api/poll/me`          | Get all polls created by logged-in user |\n| POST   | `/api/poll`             | Create a poll with options              |\n| PATCH  | `/api/poll/:id/publish` | Publish a draft poll                    |\n\n---\n\n### Vote\n\n| Method | Endpoint    | Description                   | Body Example                                           |\n| ------ | ----------- | ----------------------------- | ------------------------------------------------------ |\n| POST   | `/api/vote` | Cast a vote for a poll option | `{ \"pollId\": \"\u003cpoll-id\u003e\", \"optionId\": \"\u003coption-id\u003e\" }` |\n\n---\n\n## WebSocket (Realtime)\n\n1. Connect with token:\n\n   ```js\n   import { io } from \"socket.io-client\";\n\n   const socket = io(\"http://localhost:3000\", {\n     auth: { token: \"123456\" } // JWT token\n   });\n\n   socket.on(\"connect\", () =\u003e {\n     console.log(\"Connected:\", socket.id);\n   });\n   ```\n\n2. Join a poll room:\n\n   ```js\n   socket.emit(\"watchPoll\", \"7951b232-51ff-4f99-9cfe-2ca3d1d3049b\");\n   ```\n\n3. Listen for vote updates:\n\n   ```js\n   socket.on(\"voteUpdate\", (data) =\u003e {\n     console.log(\"Vote update:\", data);\n     // { pollId, counts: [{ id, text, voteCount }] }\n   });\n   ```\n\n---\n\n## Testing Flow\n\n1. **Sign up / Sign in** → get JWT token\n2. **Create poll** → with options\n3. **Publish poll** (`PATCH /api/poll/:id/publish`)\n4. **Connect client via WebSocket** (`watchPoll`)\n5. **Vote via REST** (`POST /api/vote`)\n6. **See realtime updates** pushed to connected clients 🎉\n\n---\n\n## Future Improvements\n\n* Role-based access (e.g. only poll owner can publish)\n* Allow multiple-choice polls\n* Add frontend client (React/Next.js) for demo\n* Admin dashboard for managing polls\n\n---\n\n## License\n\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frudranshfly%2Frealtime-polling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frudranshfly%2Frealtime-polling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frudranshfly%2Frealtime-polling/lists"}