GithubHelp home page GithubHelp logo

jayaprakash9603 / votingsystem Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 733 KB

This repository contains the source code for a simple voting system developed in Java using the Spring Boot framework. The system allows users to enter candidate names, cast votes for their preferred candidates, and retrieve information such as the total votes for a candidate and the overall winner.

Java 100.00%
backend java sourcecode voting-system

votingsystem's Introduction

Introduction

The Voter Spring Boot RESTful Web Service is used for Springboot testing. The Voter service exposes several HTTP API endpoints, listed below. API users can review a static list votes , cast a vote, view voting results.

Quick Start for Local Development

The Voter service can runs locally, on port 8080. To clone, build, test, and run the Voter service locally:

git clone --depth 1 --branch master \
  https://github.com/jayaprakash9603/VotingSystem.git

Getting Started with the API

The easiest way to get started with the Voter service API is to test the api's in the postman based on the HTTP method type.

The API entercandidate shall take a name as a parameter and save that into a table with a a count(vote count) initialized to 0.

Use local variables instead of a database to store the data.

The API castvote shall take a name as a parameter and increment the vote count and return it. It should enter vote only for a valid candidate.

The API countvote shall take a name as a parameter and should return the latest vote count. Validate candidate name.

The API listvote should return all names and votecounts. The return value is in JSON.

The API getwinner should return the name of the candidate who got the largest number of votes.

APIs shall be simultaneously executed by multi-users.

Implement unit testing

Example API usage

http://localhost:8080/entercandidate?name=ajay

http://localhost:8080/castvote?name=ajay

http://localhost:8080/countvote?name=ajay

http://localhost:8080/listvote

http://localhost:8080/getwinner

Service Endpoints

By default, the service runs on localhost, port 8080.

Purpose Method Endpoint
Enter Candidate POST /entercandidate
Cast Vote POST /castvote
Count Vote POST /countvote
List Vote GET /listvote
Get Winner GET /getwinner

Voting

Submitting a new vote, requires an HTTP POST request to the /votes endpoint, and pass the candidate name as follows:

http POST http://localhost:8080/castvote?name=ajay

Sample Output

http http://localhost:8080/entercandidate

{
  "message": "candidate added"
}

http http://localhost:8080/castvote

{
  "candidates": [
    "Chris Keniston",
    "Darrell Castle",
    "Donald Trump",
    "Gary Johnson",
    "Hillary Clinton",
    "Jill Stein"
  ]
}

http http://localhost:8080/countvote

{
  "results": [
    {
      "candidate": "Gary Johnson",
      "votes": 20
    },
    {
      "candidate": "Hillary Clinton",
      "votes": 15
    },
    {
      "candidate": "Donald Trump",
      "votes": 11
    },
    {
      "candidate": "Jill Stein",
      "votes": 8
    },
    {
      "candidate": "Chris Keniston",
      "votes": 3
    },
    {
      "candidate": "Darrell Castle",
      "votes": 2
    }
  ]
}

http http://localhost:8080/listvote

{
  "kiran": 14,
  "ajay": 20,
  "sunil": 22,
  "kishore": 34,
  "kamal": 69
}

http http://localhost:8080/getwinner

{
  "results": [
    {
      "candidate": "Gary Johnson",
      "votes": 20
    }
  ]
}

OUTPUT

1. Enter Candidate

Enter Candidate photo

2. Casting Vote

Cast Vote photo

3. Count Vote

Count Vote Photo

4. List Votes

List Votes Photo

5. Get Winner

Get Winner Photo ...

References

votingsystem's People

Contributors

jayaprakash9603 avatar

Watchers

 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.