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.
- User Registration and Authentication
- Admin Controls to Add Candidates
- Secure Voting System
- Prevention of Duplicate Voting
- Error Handling and Logging
- API Documentation with Swagger
-
Clone the repository:
git clone https://github.com/Eve-SatOrU/mukou-chosen.git cd mukou-chosen
-
Install dependencies:
npm install
-
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
-
Set up the database:
npx prisma migrate dev --name init npx prisma generate
-
studio:
npx prisma studio
-
Start the server:
npm start
POST /users/register
Content-Type: application/json
{
"username": "yourusername",
"password": "yourpassword",
"role": "user" // or "admin"
}
POST /users/login
Content-Type: application/json
{
"username": "yourusername",
"password": "yourpassword"
}
POST /candidates/add
Content-Type: application/json
Authorization: Bearer <your_jwt_token>
{
"name": "Candidate Name"
}
POST /votes
Content-Type: application/json
Authorization: Bearer <your_jwt_token>
{
"candidateId": "some-string-id"
}
API documentation is available via Swagger. After starting the server, visit:
http://localhost:3000/api-docs
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
- 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.
We welcome contributions! Please fork the repository and create a pull request with your changes.