https://github.com/devsteppe9/voting_app
A simple distributed voting application orchestrated with Docker containers.
https://github.com/devsteppe9/voting_app
distributed-computing docker kafka microservices postgresql spring-boot
Last synced: 9 months ago
JSON representation
A simple distributed voting application orchestrated with Docker containers.
- Host: GitHub
- URL: https://github.com/devsteppe9/voting_app
- Owner: devsteppe9
- Created: 2025-05-18T17:15:18.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-06-17T22:20:35.000Z (9 months ago)
- Last Synced: 2025-06-17T22:37:17.688Z (9 months ago)
- Topics: distributed-computing, docker, kafka, microservices, postgresql, spring-boot
- Language: Java
- Homepage:
- Size: 2.7 MB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Voting App
A simple distributed voting application orchestrated with Docker containers.
This project is inspired by [Docker samples](https://github.com/dockersamples/example-voting-app) and enhanced with Spring Boot and Kafka integration. The application enables users to vote between two options and demonstrates a microservices architecture.
## Demo

## Getting started
Download [Docker Desktop](https://www.docker.com/products/docker-desktop) for Mac or Windows. [Docker Compose](https://docs.docker.com/compose) will be automatically installed. On Linux, make sure you have the latest version of [Compose](https://docs.docker.com/compose/install/).
This solution uses Spring Boot, Node.js with Kafka for messaging and Postgres for storage.
Run in this directory to build and run the app:
```shell
docker compose up
```
The `vote` app will be running at [http://localhost:8080](http://localhost:8080), and the `results` will be at [http://localhost:8081/results/{session_id}](http://localhost:8081/results/1). Replace `{session_id}` in the URL with the ID of the voting session you want to see results for (e.g., `http://localhost:8081/results/1` for session ID 1).
## Run the app in Kubernetes
The folder k8s-specifications contains the YAML specifications of the Voting App's services.
Run the following command to create the deployments and services. Note it will create these resources in your current namespace (`default` if you haven't changed it.)
```shell
kubectl create -f k8s-specifications/
```
The `vote` web app is then available on port 31000 on each host of the cluster, the `result` web app is available on port 31001.
To remove them, run:
```shell
kubectl delete -f k8s-specifications/
```
## Architecture

* A front-end web app [Spring Boot/Thymeleaf](/vote) for submitting votes and lets you create multiple voting sessions
* A [Kafka](https://hub.docker.com/_/redis/) message broker for handling vote events
* A [Spring Boot](/worker/) worker service to process and persist votes in a Postgres database.
* A [Spring Boot](/vote-session) REST API for managing voting sessions
* A [Postgres](https://hub.docker.com/_/postgres/) database
* A [Node.js](/result) web app for displaying real-time results
## Notes
The voting application only accepts one vote per client browser. It does not register additional votes if a vote has already been submitted from a client.