A real-time polling application built with TypeScript, NodeJS, Express, WebSocket, Kafka, and Prisma.
- Node.js (v18 or higher)
- Docker
-
Clone the repository
git clone https://github.com/yshplsngh/polling-system.git cd polling-system
-
Start Kafka, Zookeeper, Postgres, and Backend
docker-compose up
- you have to stop local postgres service if it is running on port 5432.
-
Install Frontend Dependencies
cd client npm install
-
Run Frontend
cd client npm run dev
-
Access the application
- Frontend: http://localhost:5173
- Backend: http://localhost:4000
- The
polling-topic
is divided into 3 partitions. Each partition is consumed by only one consumer in the same consumer group, it enable theparallel processing
of votes. - Three consumers (kafkaConsumer1, kafkaConsumer2, kafkaConsumer3) are initialized in the same consumer group. so that they can concurrently consume the votes from different partitions.
- we can also add more group with more consumers, but I have not added in this project.
- I have added 1
Replication factor
for 1 broker for fault tolerance.