Skip to content

devsteppe9/voting_app

Repository files navigation

Voting App

A simple distributed voting application orchestrated with Docker containers.

This project is inspired by Docker samples and enhanced with Spring Boot and Kafka integration. The application enables users to vote between two options and demonstrates a microservices architecture.

Demo

demonstration

Getting started

Download Docker Desktop for Mac or Windows. Docker Compose will be automatically installed. On Linux, make sure you have the latest version of Compose.

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:

docker compose up

The vote app will be running at http://localhost:8080, and the results will be at http://localhost:8081/results/{session_id}. 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.)

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:

kubectl delete -f k8s-specifications/

Architecture

Architecture diagram

  • A front-end web app Spring Boot/Thymeleaf for submitting votes and lets you create multiple voting sessions
  • A Kafka message broker for handling vote events
  • A Spring Boot worker service to process and persist votes in a Postgres database.
  • A Spring Boot REST API for managing voting sessions
  • A Postgres database
  • A Node.js 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.

About

A simple distributed voting application orchestrated with Docker containers.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •