josuelima / election_results

A simple election system built with Node, Express, Redis, Axon and Socket.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Election Results

This is a pet project I made to play with Node.js and Websockets.

It's composed by two modules:

  • Server: Registers the candidates and the votes, and broadcasts the information to the subscribers via websockets
  • Client: Send register requests for candidates and votes to the server, and subscribe to the publisher to receive updates

The goal is to update all the client subscribers whenever a new vote is registered at the server, making it a real time application.

Built with

Server

All API methods receives and returns JSON

Method Path Params Description Returns
GET /candidates List registered candidates [{name, tag, img_url}]
POST /candidates name, img_url Register a new candidate
GET /votes List candidates total votes [{tag}]
POST /votes candidate_tag Register a vote for a candidate

img_url: URL to the candidate photo, tag: Candidate name parameterized

After registering a candidate or a vote, the server broadcasts the registers to the subscribers.

Client

The client main page lists the candidates and votes. It subscribes to the publisher socket and when a new candidate or vote is registered the interface is automatically update without refresh.

home

The dashboard page also lists the candidates and votes, but has options to register new candidates and add votes.

dashboard

Install & Run

In order to run this project you need to have both Node.js and Redis installed on your machine, then:

  1. Clone this repo into you machine
  2. On the server folder run: node install node app
  3. On the client folder run: node install node app
  4. Go to your browser and access http://localhost:3000 (/dashboard to add candidates and votes)

About

A simple election system built with Node, Express, Redis, Axon and Socket.io


Languages

Language:JavaScript 95.6%Language:CSS 4.4%