{"id":19153386,"url":"https://github.com/alexandrecpedro/real-time-voting-system","last_synced_at":"2025-06-25T14:36:05.981Z","repository":{"id":222013142,"uuid":"755762192","full_name":"alexandrecpedro/real-time-voting-system","owner":"alexandrecpedro","description":"Real-time voting system built with Node.js - developed during Rocketseat's NLW Expert (aka NLW week)","archived":false,"fork":false,"pushed_at":"2024-08-05T12:44:50.000Z","size":1249,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-14T15:46:58.677Z","etag":null,"topics":["docker","fastify","hoppscotch","nlw-expert","nodejs","postgres","prisma","pub-sub","redis","rest-client","rocketseat","typescript","websocket","zod"],"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/alexandrecpedro.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}},"created_at":"2024-02-11T00:54:06.000Z","updated_at":"2025-05-18T12:06:14.000Z","dependencies_parsed_at":"2024-02-11T20:12:13.058Z","dependency_job_id":"ddd1e8f2-ce87-4220-880c-da77a1340629","html_url":"https://github.com/alexandrecpedro/real-time-voting-system","commit_stats":null,"previous_names":["alexandrecpedro/real-time-voting-system"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alexandrecpedro/real-time-voting-system","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandrecpedro%2Freal-time-voting-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandrecpedro%2Freal-time-voting-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandrecpedro%2Freal-time-voting-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandrecpedro%2Freal-time-voting-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexandrecpedro","download_url":"https://codeload.github.com/alexandrecpedro/real-time-voting-system/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandrecpedro%2Freal-time-voting-system/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261892482,"owners_count":23225938,"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","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":["docker","fastify","hoppscotch","nlw-expert","nodejs","postgres","prisma","pub-sub","redis","rest-client","rocketseat","typescript","websocket","zod"],"created_at":"2024-11-09T08:22:56.370Z","updated_at":"2025-06-25T14:36:05.950Z","avatar_url":"https://github.com/alexandrecpedro.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e \n  \u003ca href=\"https://www.rocketseat.com.br/eventos/nlw/\"\u003e\n    \u003cimg\n      src=\"https://www.rocketseat.com.br/eventos/nlw/_next/static/media/nlw-header-logo.2e1779ba.svg\"\n      width=\"322\"\n      height=\"auto\"\n    /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n# NLW Expert (NodeJS) ![NodeJS Logo](https://cdn.jsdelivr.net/gh/devicons/devicon@latest/devicon.min.css)\n\n\u003cdiv align=\"center\"\u003e \n  \u003cimg src=\"./project/websocket.png\" width=\"1604\" height=\"auto\" /\u003e\n\u003c/div\u003e\n\n## Project\n\nThis project was developed as part of the NLW Expert event organized by Rocketseat. It is an API for a real-time voting system where users can create polls and cast their votes.\nThe system dynamically generates a ranking among the poll options and updates the votes in real-time.\n\n## Project Diagram\n\n![Diagrama](./project/projectDiagram.jpg)\n\n## Features\n\n- Users can create polls;\n- Community members can vote on polls;\n- Real-time updating of votes and ranking;\n- API-based architecture for easy integration;\n\n## Requirements\n\n- Docker;\n- NodeJS;\n\n## Setup\n\n- Clone the repository\n\n```bash\ngit clone https://github.com/alexandrecpedro/real-time-voting-system.git\n```\n\n- Install dependencies\n\n```bash\n npm install\n```\n\n- Setup PostgreSQL and Redis\n\n```bash\n docker compose up -d\n```\n\n- Copy `.env.example` file\n\n```bash\n cp .env.example .env\n```\n\n- Run application\n\n```bash\n npm run dev\n```\n\n- Test it!\n  - [Hoppscotch](https://hoppscotch.io/).\n  - [Postman](https://www.postman.com/).\n\n## HTTP\n\n### POST `/polls`\n\nCreate a new poll.\n\n#### Request body\n\n```json\n{\n  \"title\": \"Qual a melhor linguagem de programação?\",\n  \"options\": [\"JavaScript\", \"Java\", \"PHP\", \"C#\"]\n}\n```\n\n#### Response body\n\n```json\n{\n  \"pollId\": \"194cef63-2ccf-46a3-aad1-aa94b2bc89b0\"\n}\n```\n\n### GET `/polls/:pollId`\n\nReturn data from a single poll.\n\n#### Response body\n\n```json\n{\n  \"poll\": {\n    \"id\": \"e4365599-0205-4429-9808-ea1f94062a5f\",\n    \"title\": \"Qual a melhor linguagem de programação?\",\n    \"options\": [\n      {\n        \"id\": \"4af3fca1-91dc-4c2d-b6aa-897ad5042c84\",\n        \"title\": \"JavaScript\",\n        \"score\": 1\n      },\n      {\n        \"id\": \"780b8e25-a40e-4301-ab32-77ebf8c79da8\",\n        \"title\": \"Java\",\n        \"score\": 0\n      },\n      {\n        \"id\": \"539fa272-152b-478f-9f53-8472cddb7491\",\n        \"title\": \"PHP\",\n        \"score\": 0\n      },\n      {\n        \"id\": \"ca1d4af3-347a-4d77-b08b-528b181fe80e\",\n        \"title\": \"C#\",\n        \"score\": 0\n      }\n    ]\n  }\n}\n```\n\n### POST `/polls/:pollId/votes`\n\nAdd a vote to specific poll.\n\n#### Request body\n\n```json\n{\n  \"pollOptionId\": \"31cca9dc-15da-44d4-ad7f-12b86610fe98\"\n}\n```\n\n## WebSockets\n\n### ws `/polls/:pollId/results`\n\nNumber of votes of one poll.\n\n### Message\n\n```json\n{\n  \"pollOptionId\": \"da9601cc-0b58-4395-8865-113cbdc42089\",\n  \"votes\": 2\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandrecpedro%2Freal-time-voting-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexandrecpedro%2Freal-time-voting-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandrecpedro%2Freal-time-voting-system/lists"}