{"id":25541401,"url":"https://github.com/asdotdev/polling-app","last_synced_at":"2026-02-04T08:30:20.319Z","repository":{"id":277805754,"uuid":"933544942","full_name":"asdotdev/polling-app","owner":"asdotdev","description":"Polling app where a users can vote on polls created by users.","archived":false,"fork":false,"pushed_at":"2025-02-16T08:42:30.000Z","size":73,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T09:19:18.572Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://polling-app-teal-one.vercel.app","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/asdotdev.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":"2025-02-16T08:09:35.000Z","updated_at":"2025-02-16T08:42:33.000Z","dependencies_parsed_at":"2025-02-16T09:19:21.472Z","dependency_job_id":"d2b784d1-1d48-44b1-8bce-b2b71895dac6","html_url":"https://github.com/asdotdev/polling-app","commit_stats":null,"previous_names":["asdotdev/polling-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asdotdev%2Fpolling-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asdotdev%2Fpolling-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asdotdev%2Fpolling-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asdotdev%2Fpolling-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asdotdev","download_url":"https://codeload.github.com/asdotdev/polling-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239793099,"owners_count":19697891,"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":[],"created_at":"2025-02-20T06:37:05.516Z","updated_at":"2026-02-04T08:30:20.284Z","avatar_url":"https://github.com/asdotdev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polling App\n\n## Overview\n\nA simple polling app where users can:\n\n-   Create a poll with a question and multiple options.\n-   Vote on a poll.\n-   View poll results in real-time (auto-refresh every 5 seconds).\n-   Delete a poll.\n\n## Tech Stack\n\n-   **Frontend:** Next.js 15 (with TypeScript, Tailwind CSS)\n-   **Backend:** Next.js API routes (using Mongoose for MongoDB)\n-   **Database:** MongoDB (Atlas or Local)\n\n---\n\n## Installation \u0026 Setup\n\n### **1. Clone the Repository**\n\n```sh\ngit clone https://github.com/asdotdev/polling-app.git\ncd polling-app\n```\n\n### **2. Install Dependencies**\n\n```sh\nnpm install\n```\n\n### **3. Setup Environment Variables**\n\nCreate a `.env.local` file in the root directory and add:\n\n```env\nDB_CONN_STRING=your-mongodb-connection-string\nNEXT_PUBLIC_API_BASE_URL=https://your-vercel-project.vercel.app\n\n```\n\n### **4. Run the Development Server**\n\n```sh\nnpm run dev\n```\n\nApp will be available at `http://localhost:3000`\n\n---\n\n## API Endpoints\n\n### **1. Get All Polls**\n\n```http\nGET /api/polls\n```\n\n**Response:**\n\n```json\n[\n    {\n        \"_id\": \"12345\",\n        \"question\": \"What's your favorite programming language?\",\n        \"options\": [\n            { \"text\": \"JavaScript\", \"votes\": 10 },\n            { \"text\": \"Python\", \"votes\": 8 }\n        ]\n    }\n]\n```\n\n### **2. Get a Single Poll**\n\n```http\nGET /api/polls?id={pollId}\n```\n\n**Response:**\n\n```json\n{\n    \"_id\": \"12345\",\n    \"question\": \"What's your favorite programming language?\",\n    \"options\": [\n        { \"text\": \"JavaScript\", \"votes\": 10 },\n        { \"text\": \"Python\", \"votes\": 8 }\n    ]\n}\n```\n\n### **3. Create a Poll**\n\n```http\nPOST /api/polls\n```\n\n**Request Body:**\n\n```json\n{\n    \"question\": \"What's your favorite programming language?\",\n    \"options\": [\"JavaScript\", \"Python\", \"C++\"]\n}\n```\n\n**Response:**\n\n```json\n{\n    \"_id\": \"12345\",\n    \"question\": \"What's your favorite programming language?\",\n    \"options\": [\n        { \"text\": \"JavaScript\", \"votes\": 0 },\n        { \"text\": \"Python\", \"votes\": 0 },\n        { \"text\": \"C++\", \"votes\": 0 }\n    ]\n}\n```\n\n### **4. Vote on a Poll**\n\n```http\nPUT /api/polls\n```\n\n**Request Body:**\n\n```json\n{\n    \"pollId\": \"12345\",\n    \"optionIndex\": 0\n}\n```\n\n**Response:**\n\n```json\n{\n    \"_id\": \"12345\",\n    \"question\": \"What's your favorite programming language?\",\n    \"options\": [\n        { \"text\": \"JavaScript\", \"votes\": 11 },\n        { \"text\": \"Python\", \"votes\": 8 }\n    ]\n}\n```\n\n### **5. Delete a Poll**\n\n```http\nDELETE /api/polls?id={pollId}\n```\n\n**Response:**\n\n```json\n{\n    \"message\": \"Poll deleted successfully\"\n}\n```\n\n---\n\n## Database Schema\n\n### **Poll Model (`Poll.ts`)**\n\n```typescript\nimport mongoose, { Schema, Document } from \"mongoose\";\n\ninterface Option {\n    text: string;\n    votes: number;\n}\n\nexport interface IPoll extends Document {\n    question: string;\n    options: Option[];\n}\n\nconst PollSchema: Schema = new Schema({\n    question: { type: String, required: true },\n    options: [\n        {\n            text: { type: String, required: true },\n            votes: { type: Number, default: 0 },\n        },\n    ],\n});\n\nexport default mongoose.models.Poll ||\n    mongoose.model\u003cIPoll\u003e(\"Poll\", PollSchema);\n```\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasdotdev%2Fpolling-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasdotdev%2Fpolling-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasdotdev%2Fpolling-app/lists"}