{"id":15697316,"url":"https://github.com/jim60105/simple-poll-system","last_synced_at":"2025-07-24T23:41:11.967Z","repository":{"id":214748216,"uuid":"737269165","full_name":"jim60105/simple-poll-system","owner":"jim60105","description":"This is a POC aiming to create a cost-efficient and high-capacity real-time poll system. (Cloudflare Page Functions, Cloudflare D1, Vue.js)","archived":false,"fork":false,"pushed_at":"2024-09-28T01:59:28.000Z","size":172,"stargazers_count":9,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T21:13:31.896Z","etag":null,"topics":["cloudflare","cloudflare-d1","cloudflare-pages","cloudflare-pages-functions","cloudflare-workers","vue3"],"latest_commit_sha":null,"homepage":"https://simple-poll-system.pages.dev/","language":"Vue","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jim60105.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-12-30T12:18:45.000Z","updated_at":"2025-03-26T17:36:26.000Z","dependencies_parsed_at":"2024-02-02T11:25:31.464Z","dependency_job_id":"457620ae-0dbb-4806-a437-608ea9ffa9f3","html_url":"https://github.com/jim60105/simple-poll-system","commit_stats":null,"previous_names":["jim60105/simple-poll-system"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim60105%2Fsimple-poll-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim60105%2Fsimple-poll-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim60105%2Fsimple-poll-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim60105%2Fsimple-poll-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jim60105","download_url":"https://codeload.github.com/jim60105/simple-poll-system/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253149617,"owners_count":21861739,"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":["cloudflare","cloudflare-d1","cloudflare-pages","cloudflare-pages-functions","cloudflare-workers","vue3"],"created_at":"2024-10-03T19:16:12.284Z","updated_at":"2025-05-08T21:14:00.700Z","avatar_url":"https://github.com/jim60105.png","language":"Vue","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Poll System\n\nTry it here 👉 \u003chttps://simple-poll-system.pages.dev\u003e\n\nThis project serves as a proof of concept for learning purposes. It is aiming to create a cost-efficient and high-capacity real-time poll system. Poll is just a simple topic, you can modify it to other applications that involve front-end, back-end, and database.\n\nTo achieve this, I built the solution with [Cloudflare Pages](https://developers.cloudflare.com/pages), [Cloudflare Page Functions](https://developers.cloudflare.com/pages/functions/), and [Cloudflare D1](https://developers.cloudflare.com/d1/).\n\nCloudflare handles the traffic of the webpage itself, and there are no charges for webpage traffic on Cloudflare Pages. [The primary limitation of Cloudflare Pages are the frequency of builds and file size](https://developers.cloudflare.com/pages/platform/limits/), both of which are unlikely to surpass the free quota during regular usage. I did not find any limitations in docs regarding the page carrying capacity; however, it is Cloudflare. I don't think they will encounter traffic bottlenecks on static webpage access.\n\n[Requests to the Functions are billed as Cloudflare Workers requests.](https://developers.cloudflare.com/pages/functions/pricing/) Cloudflare provides 100,000 free requests per day, and any additional requests are charged at a rate of $0.15 per million requests. It's incredibly affordable compared to any other backend solutions with nearly no cold starts!\n\n[Cloudflare D1 pricing](https://developers.cloudflare.com/d1/platform/pricing/#billing-metrics) includes 100,000 free writes per day and 5 million free reads per day. The sufficiency of this allowance depends on the volume of requests and how you structure your table schema and system.\n\nWhen designing the system, it is crucial to consider the frequency of API access and the read/write operations on the databases, especially if the website experiences high traffic.\n\n\u003e It is worth noting that each question response is stored as a row in this project's table design, which may result in redundant database operations when there are numerous questions. This design may not be ideal for the pricing structure mentioned. However, this is just a quick POC project and modifications should be made for production purposes.\n\n\u003e [!Important]\n\u003e It is important to note that _D1 is currently in public beta_.  \n\u003e It is not advisable to utilize beta products for large production workloads.  \n\u003e Also, please star🌟 and watch👀 this repo to stay updated with our future modifications.\n\n## Setup\n\n### Fork this repo on GitHub\n\nThis project is meant to be deployed individually for each profile/user. Fork this repo to your own account.\n\n### Setup Cloudflare Pages\n\n[Follow these steps on the docs](https://developers.cloudflare.com/pages/get-started/guide/#connect-your-git-provider-to-pages) to setup your new Cloudflare Pages. Connect your Git provider(GitHub) and select the repo you just forked.\n\nBuild Settings:\n\n- Framework preset: None\n- Build command: `npm run build`\n- Build output directory: /`dist`\n\n### Prepare your new D1 Database\n\nCreate a new D1 Database and obtain the `database_id` from the execution result of the command. Following these steps:\n\n#### Step 1: Create a new D1 Database\n\nCreate a new D1 Database with the name `simple-poll-system`.\n\n```bash\nwrangler d1 create simple-poll-system\n```\n\nYou will get a response with the `database_id` like this:\n\n```bash\n✅ Successfully created DB 'simple-poll-system' in region APAC\nCreated your database using D1's new storage backend. The new storage backend is not yet recommended for production\nworkloads, but backs up your data via point-in-time restore.\n\n[[d1_databases]]\nbinding = \"DB\" # i.e. available in your Worker on env.DB\ndatabase_name = \"simple-poll-system\"\ndatabase_id = \"631aae6c-ace8-4d73-bc75-453abaad85fb\"\n```\n\n#### Step 2: Update database_id\n\n\u003e [!NOTE]\n\u003e This step is actually only used in locally debugging, since we used the Git provider to deploy our code.\n\nFill the `database_id` property in `wrangler.toml` with the id you got in the previous step.\n\n```toml\n[[d1_databases]]\nbinding = \"SimplePollSystem\"\ndatabase_id = \"631aae6c-ace8-4d73-bc75-453abaad85fb\"\ndatabase_name = \"simple-poll-system\"\n```\n\nChange the `wrangler-dev` npm script in `package.json`:\n\n```text\n\"wrangler-dev\": \"wrangler pages dev --d1 SimplePollSystem=631aae6c-ace8-4d73-bc75-453abaad85fb -- vite --host\",\n```\n\n#### Step 3: Create the table\n\nCreate a table named `Poll1` in db named `simple-poll-system` with `init_database.sql`\n\n\u003e [!IMPORTANT]  \n\u003e Execute the following command in your working directory.\n\n```bash\nwrangler d1 execute simple-poll-system --file=./init_database.sql\n```\n\nSuccess response for example:\n\n```bash\n🌀 Mapping SQL input into an array of statements\n🌀 Parsing 3 statements\n🌀 Executing on remote database simple-poll-system (631aae6c-ace8-4d73-bc75-453abaad85fb):\n🌀 To execute on your local development database, pass the --local flag to 'wrangler d1 execute'\n🚣 Executed 3 commands in 0.6084ms\n```\n\nYou may also want to create the table in your local development environment:\n\n```bash\nwrangler d1 execute simple-poll-system --local --file=./init_database.sql\n```\n\n\u003e [!NOTE]  \n\u003e I hardcoded the table name in the code for this simple POC project.  \n\u003e You can perform a project-wide search for `Poll1` and replace it with your desired table name. Alternatively, you can extract it to a variable.\n\n### Bind your D1 Database to your Cloudflare Pages\n\nGo to your Cloudflare Pages project settings → Functions → D1 database bindings, and bind the `simple-poll-system` database to your page.\n\n- Variable name: `SimplePollSystem`\n- D1 database: `simple-poll-system`\n\n![2024-01-03 00 30 42](https://github.com/jim60105/simple-poll-system/assets/16995691/bfa70cd7-87ae-48a8-a99d-ac7b70a680c3)\n\n\u003e [!IMPORTANT]  \n\u003e Bindings will work on the next build. So we need to trigger a new build to make it work.\n\n### Deploy\n\nSave the file and push a new commit into `master` and wait for the Cloudflare Page to deploy your webpage.\n\nConfirm that things can work, and then dive into the code to see how it works!\n\n![2024-01-03 00 32 54](https://github.com/jim60105/simple-poll-system/assets/16995691/cd870e27-1191-4718-b905-b20b6168d32b)\n\n## LICENSE\n\n\u003cimg src=\"https://github.com/jim60105/simple-poll-system/assets/16995691/72ee6dc7-c41e-4b1d-a839-5c2ff8a48799\" alt=\"agpl\" width=\"300\" /\u003e\n\n[GNU AFFERO GENERAL PUBLIC LICENSE Version 3](LICENSE)\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License along with this program. If not, see \u003chttps://www.gnu.org/licenses/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjim60105%2Fsimple-poll-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjim60105%2Fsimple-poll-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjim60105%2Fsimple-poll-system/lists"}