Giter Site home page Giter Site logo

mukou-chosen's Introduction

Mukou Chōsen (無効挑戦)

Welcome to Mukou Chōsen (無効挑戦) - a fun and secure voting system where users can register, vote for candidates, and view results. This system includes authentication, admin controls, and ensures that users can only vote once , ensure security staff.

Features

  • User Registration and Authentication
  • Admin Controls to Add Candidates
  • Secure Voting System
  • Prevention of Duplicate Voting
  • Error Handling and Logging
  • API Documentation with Swagger

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/Eve-SatOrU/mukou-chosen.git
    cd mukou-chosen
  2. Install dependencies:

    npm install
  3. Set up environment variables: Create a .env file in the root directory and add the following:

    DATABASE_URL=mysql://user:password@localhost:5432/mydb
    JWT_SECRET=your_jwt_secret
    
  4. Set up the database:

    npx prisma migrate dev --name init
    npx prisma generate
  5. studio:

    npx prisma studio
  6. Start the server:

    npm start

Usage

Register a New User

POST /users/register
Content-Type: application/json

{
  "username": "yourusername",
  "password": "yourpassword",
  "role": "user" // or "admin"
}

Login

POST /users/login
Content-Type: application/json

{
  "username": "yourusername",
  "password": "yourpassword"
}

Add a Candidate (Admin only)

POST /candidates/add
Content-Type: application/json
Authorization: Bearer <your_jwt_token>

{
  "name": "Candidate Name"
}

Vote for a Candidate

POST /votes
Content-Type: application/json
Authorization: Bearer <your_jwt_token>

{
  "candidateId": "some-string-id"
}

API Documentation

API documentation is available via Swagger. After starting the server, visit:

http://localhost:3000/api-docs

Project Structure

Mukou-Chosen/
├── prisma/
│   ├── migrations/
│   └── schema.prisma
├── routes/
│   ├── candidate.js
│   ├── user.js
│   └── vote.js
├── middleware/
│   └── auth.js
├── util/
│   └── logger.js
│   └── swagger.yaml
├── .env
├── app.js
├── package.json
├── swagger.js
└── README.md

Extra Features

  • Authentication System: Secure login and registration using JWT.
  • Admin Role: Admins can add new candidates to the voting system.
  • Error Handling: Custom error pages and logging for server-side errors.
  • Swagger UI: Easy-to-use API documentation interface.

Contributing

We welcome contributions! Please fork the repository and create a pull request with your changes.

mukou-chosen's People

Contributors

eve-satoru 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.