{"id":13754106,"url":"https://github.com/garystafford/voter-service","last_synced_at":"2025-07-03T23:34:08.264Z","repository":{"id":74259264,"uuid":"73577435","full_name":"garystafford/voter-service","owner":"garystafford","description":"The Voter Spring Boot RESTful Web Service, backed by MongoDB, and uses RabbitMQ for IPC","archived":false,"fork":false,"pushed_at":"2018-05-04T19:10:24.000Z","size":64338,"stargazers_count":66,"open_issues_count":1,"forks_count":41,"subscribers_count":6,"default_branch":"gke","last_synced_at":"2024-10-29T14:20:49.009Z","etag":null,"topics":["microservice","mongodb","mongodb-database","rabbitmq","rest-api","restful","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/garystafford.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}},"created_at":"2016-11-12T20:43:43.000Z","updated_at":"2024-06-14T13:17:30.000Z","dependencies_parsed_at":"2024-01-17T15:02:59.096Z","dependency_job_id":"d31611c5-9bd3-4ad2-a3af-80bafcf03ebd","html_url":"https://github.com/garystafford/voter-service","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/garystafford/voter-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garystafford%2Fvoter-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garystafford%2Fvoter-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garystafford%2Fvoter-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garystafford%2Fvoter-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/garystafford","download_url":"https://codeload.github.com/garystafford/voter-service/tar.gz/refs/heads/gke","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garystafford%2Fvoter-service/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263421504,"owners_count":23464013,"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":["microservice","mongodb","mongodb-database","rabbitmq","rest-api","restful","spring-boot"],"created_at":"2024-08-03T09:01:40.533Z","updated_at":"2025-07-03T23:34:08.216Z","avatar_url":"https://github.com/garystafford.png","language":"Java","funding_links":[],"categories":["spring-boot"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/garystafford/voter-service.svg?branch=gke)](https://travis-ci.org/garystafford/voter-service) [![Dependencies](https://app.updateimpact.com/badge/817200262778327040/voter-service.svg?config=compile)](https://app.updateimpact.com/latest/817200262778327040/voter-service) [![Layers](https://images.microbadger.com/badges/image/garystafford/voter-service.svg)](https://microbadger.com/images/garystafford/voter-service \"Get your own image badge on microbadger.com\") [![Version](https://images.microbadger.com/badges/version/garystafford/voter-service.svg)](https://microbadger.com/images/garystafford/voter-service \"Get your own version badge on microbadger.com\")\n\n# Voter Service\n\n## Introduction\n\nThe Voter [Spring Boot](https://projects.spring.io/spring-boot/) Service is a RESTful Web Service, backed by MongoDB, using Atlas on GCP, and RabbitMQ, using CloudAMQP on GCP. It is part of the Voter API (see diagram below). The Voter service exposes several HTTP API endpoints, listed below. API users can review a list candidates, submit a vote, view voting results, and inspect technical information about the running service.\n\n![Architecture](GKE_AMPQ_v1.png)\n\n## Voter Service Endpoints\n\nThe service uses a context path of `/voter`. All endpoints must be are prefixed with this sub-path.\n\nPurpose                                                                                                                  | Method  | Endpoint\n------------------------------------------------------------------------------------------------------------------------ | :------ | :-----------------------------------------------------\nList All Service Endpoints                                                                                               | GET     | [/voter/mappings](http://localhost:8099/voter/mappings)\nCreate Vote                                                                                                              | POST    | [/voter/voters](http://localhost:8099/voter/voters)\nRead Vote                                                                                                                | GET     | [/voter/voters/{id}](http://localhost:8099/voter/voters/{id})\nRead Votes                                                                                                               | GET     | [/voter/voters](http://localhost:8099/voter/voters)\nUpdate Vote                                                                                                              | PUT     | [/voter/voters/{id}](http://localhost:8099/voter/voters/{id})\nDelete Vote                                                                                                              | DELETE  | [/voter/voters/{id}](http://localhost:8099/voter/voters/{id})\nList Candidates                                                                                                          | GET     | [/voter/candidates/{election}](http://localhost:8099/voter/candidates/db/{election})\nView Voting Results                                                                                                      | GET     | [/voter/results/{election}](http://localhost:8099/voter/results/{election})\nView Total Votes                                                                                                         | GET     | [/voter/results/{election}/votes](http://localhost:8099/voter/results/{election}/votes)\nView Winner(s)                                                                                                           | GET     | [/voter/winners/{election}](http://localhost:8099/voter/winners/{election})\nView Winning Vote Count                                                                                                  | GET     | [/voter/winners/{election}/votes](http://localhost:8099/voter/winners/{election}/votes)\nDrop All Candidates                                                                                                      | POST    | [/voter/drop/candidates](http://localhost:8099/voter/drop/candidates)\nDrop All Votes                                                                                                           | POST    | [/voter/drop/votes](http://localhost:8099/voter/drop/votes)\nService Info                                                                                                             | GET     | [/voter/info](http://localhost:8099/voter/info)\nService Health                                                                                                           | GET     | [/voter/health](http://localhost:8099/voter/health)\nOther [Spring Actuator](http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready) endpoints | GET     | `voter/actuator`, `voter/metrics`, `voter/env`, `voter/configprops`, etc.\nOther [HATEOAS](https://spring.io/guides/gs/rest-hateoas) endpoints for `/voter/votes`                                   | Various | page sort, size, etc.\n\nThe [HAL Browser](https://github.com/mikekelly/hal-browser) API browser for the `hal+json` media type is installed alongside the service. It can be accessed at `http://localhost:8099/voter/actuator/`.\n\n## Voting\n\nSubmitting a new candidate requires an HTTP `POST` request to the `/voter/votes` endpoint, as follows:\n\nHTTPie\n\n```bash\nhttp POST http://localhost:8099/voter/votes \\\n  candidate=\"Jill Stein\" \\\n  election=\"2016 Presidential Election\"\n```\n\ncURL\n\n```bash\ncurl -X POST \\\n  -H \"Content-Type: application/json\" \\\n  -d '{ \"candidate\": \"Jill Stein\", \"election\": \"2016 Presidential Election\" }' \\\n  \"http://localhost:8099/voter/votes\"\n```\n\nwget\n\n```bash\nwget --method POST \\\n  --header 'content-type: application/json' \\\n  --body-data '{ \"candidate\": \"Jill Stein\", \"election\": \"2016 Presidential Election\" }' \\\n  --no-verbose \\\n  --output-document - http://localhost:8099/voter/votes\n```\n\n## Sample Output\n\nAPI users can also create random voting data by calling the `/voter/simulation` endpoint. Using [HTTPie](https://httpie.org/) command line HTTP client.\n\n```bash\nhttp http://localhost:8099/voter/simulation/2016%20Presidential%20Election\n```\n\n```json\n{\n    \"message\": \"Simulation data created!\"\n}\n```\n\n```bash\nhttp http://localhost:8099/voter/candidates/db/2016%20Presidential%20Election\n```\n\n```json\n{\n    \"candidates\": [\n        {\n            \"election\": \"2016 Presidential Election\",\n            \"fullName\": \"Darrell Castle\",\n            \"politicalParty\": \"Constitution Party\"\n        },\n        {\n            \"election\": \"2016 Presidential Election\",\n            \"fullName\": \"Hillary Clinton\",\n            \"politicalParty\": \"Democratic Party\"\n        },\n        {\n            \"election\": \"2016 Presidential Election\",\n            \"fullName\": \"Gary Johnson\",\n            \"politicalParty\": \"Libertarian Party\"\n        }\n    ]\n}\n```\n\n```bash\nhttp http://localhost:8099/voter/results/2016%20Presidential%20Election\n```\n\n```json\n{\n    \"results\": [\n        {\n            \"candidate\": \"Darrell Castle\",\n            \"votes\": 19\n        },\n        {\n            \"candidate\": \"Donald Trump\",\n            \"votes\": 15\n        },\n        {\n            \"candidate\": \"Gary Johnson\",\n            \"votes\": 15\n        },\n        {\n            \"candidate\": \"Jill Stein\",\n            \"votes\": 13\n        }\n    ]\n}\n```\n\n```bash\nhttp http://localhost:8099/voter/results/2016%20Presidential%20Election/votes\n```\n\n```json\n{\n    \"votes\": 80\n}\n```\n\n```bash\nhttp http://localhost:8099/voter/winners/2016%20Presidential%20Election\n```\n\n```json\n{\n    \"results\": [\n        {\n            \"candidate\": \"Darrell Castle\",\n            \"votes\": 19\n        }\n    ]\n}\n```\n\n```bash\nhttp http://localhost:8099/voter/winners/2016%20Presidential%20Election/votes\n```\n\n```json\n{\n    \"votes\": 19\n}\n```\n\n```bash\nhttp POST http://localhost:8099/voter/votes \\\n    candidate=\"Jill Stein\" \\\n    election=\"2016 Presidential Election\"\n```\n\n```json\n{\n    \"_links\": {\n        \"self\": {\n            \"href\": \"http://localhost:8099/voter/votes/590548541b8ebf700f9c2a62\"\n        },\n        \"candidate\": {\n            \"href\": \"http://localhost:8099/voter/votes/590548541b8ebf700f9c2a62\"\n        }\n    },\n    \"candidate\": \"Jill Stein\",\n    \"election\": \"2016 Presidential Election\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarystafford%2Fvoter-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgarystafford%2Fvoter-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarystafford%2Fvoter-service/lists"}