Giter Club home page Giter Club logo

rajuranjan00 / real-time-voting-system Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 1.9 MB

The code repository encompasses a real-time election voting system constructed with Python, Kafka, Spark Streaming, Postgres, and Streamlit. Docker Compose is employed to effortlessly launch the necessary services within Docker containers.

License: MIT License

Python 100.00%
apache-kafka bigdata docker-compose postgresql realtime-analytics realtime-election realtime-voting-system streamlit-dashboard apache-spark

real-time-voting-system's Introduction

Realtime Voting System

This repository contains the code for a realtime election voting system. The system is built using Python, Kafka, Spark Streaming, Postgres and Streamlit. The system is built using Docker Compose to easily spin up the required services in Docker containers.

System Architecture

system_architecture.jpg

System Components

  • main.py: This is the main Python script that creates the required tables on postgres (candidates, voters and votes), it also creates the Kafka topic and creates a copy of the votes table in the Kafka topic. It also contains the logic to consume the votes from the Kafka topic and produce data to voters_topic on Kafka.
  • voting.py: This is the Python script that contains the logic to consume the votes from the Kafka topic (voters_topic), generate voting data and produce data to votes_topic on Kafka.
  • spark-streaming.py: This is the Python script that contains the logic to consume the votes from the Kafka topic (votes_topic), enrich the data from postgres and aggregate the votes and produce data to specific topics on Kafka.
  • streamlit-app.py: This is the Python script that contains the logic to consume the aggregated voting data from the Kafka topic as well as postgres and display the voting data in realtime using Streamlit.

Setting up the System

This Docker Compose file allows you to easily spin up Zookkeeper, Kafka and Postgres application in Docker containers.

Prerequisites

  • Python 3.9 or above installed on your machine
  • Docker Compose installed on your machine
  • Docker installed on your machine

Steps to Run

  1. Clone this repository.
  2. Navigate to the root containing the Docker Compose file.
  3. Run the following command:
docker-compose up -d

This command will start Zookeeper, Kafka and Postgres containers in detached mode (-d flag). Kafka will be accessible at localhost:9092 and Postgres at localhost:5432.

Additional Configuration

If you need to modify Zookeeper configurations or change the exposed port, you can update the docker-compose.yml file according to your requirements.

Running the App

  1. Install the required Python packages using the following command:
pip install -r requirements.txt
  1. Creating the required tables on Postgres and generating voter information on Kafka topic:
python main.py
  1. Consuming the voter information from Kafka topic, generating voting data and producing data to Kafka topic:
python voting.py
  1. Consuming the voting data from Kafka topic, enriching the data from Postgres and producing data to specific topics on Kafka:
python spark-streaming.py
  1. Running the Streamlit app:
streamlit run streamlit-app.py

Screenshots

Candidates and Parties information

candidates_and_party.png

Voters

voters.png

Voting

voting.png

real-time-voting-system's People

Contributors

rajuranjan00 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.