Skip to content

Distributed Voting System in a microservice architecture using gRPC and Kafka

License

Notifications You must be signed in to change notification settings

dthx2710/csc3004-group24-2023

Repository files navigation

CSC3004 Group 24 Project

Distributed Voting System using Cloud Native Technology utilizing gRPC and Kafka

GitHub Repository can be found here, and Releases are found here

Group24 Members

Name Student ID Role Github
Dylan Tok 2101372 Backend Lead @dthx2710
Xu Xueli 2101812 Databases and Analytics @xx-ue
Derick Kwok 2100689 Docker and Deployment @zyferis
Zhang XiangHui 2101993 Backend and Testing @XiangHui556
Yong Kai En 2100658 Frontend Lead @kaiiennn
Samantha Lee 2102066 Frontend and Testing @slqy

Introduction

This project is a cloud-native solution that leverages gRPC and Kafka to create a scalable and distributed voting platform; with a efficient and reliable voting processes across multiple nodes.

In this prototype, users are able to log into the system as an user or a system admin to view the polls of their GRC (Group representation constituency) location. Users will also be able to vote on these polls. Admins will be able to view the results of these polls, while also being able create and delete them.

Implementation

The system is designed as a microservices architecture, with distinct services for our business logic.

By utilizing gRPC, a high-performance RPC framework, the system ensures secure and seamless communication between client applications and voting servers, enabling users to cast their votes efficiently.

To enable data-queuing and event-driven architecture, the system incorporates Kafka, a distributed streaming platform. Kafka facilitates the smooth transmission of vote-related events across distributed nodes, enabling real-time updates and result aggregation. Kafka also helps with fault tolerance and data integrity of the payload.

Security and anonymity has been enhanced with the use of JSON Web Tokens (JWT) for authorization and authentication, hashing and salting for passwords and voters so identities cannot be tracked back.

Designed with cloud-native principles in mind, the Distributed Voting System can be effortlessly deployed and scaled on modern cloud platforms. With the help of containerization technologies like Docker and Kubernetes, deployment and management across various cloud environments become simplified. Additionally, our project is also deployed on the cloud using Google Kubernetes Engine.

In summary, the Distributed Voting System combines cloud-native technologies, gRPC, and Kafka to provide a scalable and secure voting solution. It aims to deliver an efficient and transparent voting experience, ensuring the integrity of the entire voting process in real time.

Requirements

  • A machine running Windows or Linux operating system
  • Docker
  • NodeJS and Go if you want to run the services manually (optional)

Directory

  • ./frontend - Contains the frontend code for the web application
  • ./gateway - Contains the gRPC gateway code
  • ./user-service - Contains the user-service code
  • ./poll-service - Contains the poll-service code
  • ./result-service - Contains the result-service code
  • ./vote-service - Contains the vote producer and consumer
  • ./nginx - Contains the nginx configuration file
  • ./kubernetes - Contains the kubernetes configuration files
  • ./docker-compose.yml - Contains the docker-compose configuration for the services

Quickstart Steps

  1. Clone the repository or download release from here
  2. Configure the environment variables in the .env file:
    • You can use the .env.sample file as a template (copy and rename as .env)
    • !IMPORTANT! Add Database Credentials to the .env file, based on the details provided in the submission email/pdf:
      • DATABASE_URL={provided string}
  3. Start Docker
  4. Build the container (optional) npm run build
  5. Run the container npm run up
  6. With this, the Docker-Compose Stack will be up and running
    • The frontend will be available at localhost or wherever you are hosting/deploying this on (HTTP - port 80)
    • The gateway will be available at localhost:8080, and acts as a internal proxy for the other api services on ports (e.g. 50051-50054)
    • We have an NGINX reverse proxy running on port 80 to route the traffic to the frontend and gateway

Software Architecture and Diagrams

System Architecture gRPC Flow JWT Exchange Kafka

Application & Other Screenshots

Login Page User Polls Vote Admin Polls Results Kubernetes Services Load Testing Utilization Anonymity and Privacy

Developer Additions

Generating Protobuf files

The protobuf files are already generated, but if you want to generate them yourself, you can do so by following the steps below:

  1. Install protoc, protoc-gen-go, protoc-gen-grpc-web, make
  2. Find the proto files in the proto directory
  3. You can simply run make protoc-all to generate the gateway files
  4. Or alternatively, copy the commands in Makefile to run them individually if you prefer This will generate the Protobuf files for gRPC communications

Running the services manually

We recommend using Docker to run the services instead, but if you want to run the services manually (NOT recommended), you can do so by following the steps below:

  1. Install NodeJS, go
  2. Configure environment files for each folder
  3. Start frontend, gateway, user, poll, result, voteproducer/consumer + kafka/zookeeper compose container services in separate terminals

About

Distributed Voting System in a microservice architecture using gRPC and Kafka

Resources

License

Stars

Watchers

Forks

Packages

No packages published