{"id":20295834,"url":"https://github.com/afrith/election-map-backend","last_synced_at":"2025-03-04T05:41:03.601Z","repository":{"id":42879136,"uuid":"189569468","full_name":"afrith/election-map-backend","owner":"afrith","description":"Backend service for interactive SA election result map","archived":false,"fork":false,"pushed_at":"2024-06-12T13:17:27.000Z","size":491,"stargazers_count":7,"open_issues_count":3,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-14T09:55:45.755Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/afrith.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":"2019-05-31T09:42:43.000Z","updated_at":"2024-06-12T13:17:31.000Z","dependencies_parsed_at":"2024-11-14T15:39:10.408Z","dependency_job_id":"2f415dab-81f7-421e-b3c2-f6192a7d2eb3","html_url":"https://github.com/afrith/election-map-backend","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afrith%2Felection-map-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afrith%2Felection-map-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afrith%2Felection-map-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afrith%2Felection-map-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afrith","download_url":"https://codeload.github.com/afrith/election-map-backend/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241794114,"owners_count":20021189,"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":"2024-11-14T15:36:22.923Z","updated_at":"2025-03-04T05:41:03.582Z","avatar_url":"https://github.com/afrith.png","language":"PLpgSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is the backend that serves map tiles and data for the election map which\nis deployed at https://elections.adrianfrith.com/. The repository for the\nfrontend is at https://github.com/afrith/election-map-frontend.\n\n## Service\n\nThe service provides Mapbox Vector Tiles (MVTs) for five levels of electoral geography: province, district council, municipality, ward, and voting district. The tiles include selected data points from the election results for ease of rendering. The tiles are provided at URLs of the form `/tiles/{level}_{election}/{z}/{x}/{y}/tile.mvt`, where:\n\n* `{level}` is one of \"prov\", \"dist\", \"muni\", \"ward\" or \"vd\", corresponding to the five levels of electoral geography listed above.\n* `{election}` is be one of \"npe2004\", \"npe2009\", \"npe2014\" or \"npe2019\".\n\nThe service also provides an endpoint to fetch full details of election results for any electoral geography as a JSON document. This endpoint is provided at URLs of the form `/{election}/{ballot}/{level}/{code}`, where:\n\n* `{level}` and `{election}` are as described above.\n* `{ballot}` is either \"nat\" or \"prov\", for the national and provincial ballot results respectively.\n* `{code}` is the unique code identifying a geography, which can also be found in the `code` property of objects in the  MVTs.\n\n## Tech stack\n\n* Data store\n  * PostgreSQL\n  * PostGIS\n* Service\n  * Node.js\n  * Express.js\n  * [TileStrata](https://github.com/naturalatlas/tilestrata)\n  * `tilestrata-postgismvt` slightly modified (see [repo](https://github.com/afrith/tilestrata-postgismvt))\n\n## Running\n\nTo run the service you need the data, which can be downloaded [here](https://stuff.adrianfrith.com/election-results-20190530.pg_dump) as a 1GB PostgreSQL dump file. Then you need to set three environment variables.\n\n* `DATABASE_URL` is the URL of the PostgreSQL database (e.g. `postgres://localhost/election-results`).\n* `TILECACHE_DIR` is the location of a directory to use to cache MVTs - since the data is unchanging the tiles never expire; if you need to clear the cache, delete the contents of this directory.\n* `PORT` is the port on which the service will listen (defaults to 3000).\n\nThen you can run `yarn build \u0026\u0026 yarn start` to run the service.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafrith%2Felection-map-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafrith%2Felection-map-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafrith%2Felection-map-backend/lists"}