Welcome to the Election Simulator App! This project is a full-stack application designed to simulate an election process, allowing users to create, manage, and participate in elections. The backend server is built with NestJS, TypeORM, Swagger, and Zod, while the frontend client is developed using Next.js, ShadCN, and server actions.
- Create and manage elections
- Cast votes and view results
- Secure authentication and authorization
- Interactive user interface
- NestJS: A progressive Node.js framework for building efficient, reliable, and scalable server-side applications.
- TypeORM: An ORM for TypeScript and JavaScript (ES7, ES6, ES5) that supports many database systems.
- Swagger: A tool to visualize and interact with the API’s resources.
- Zod: A TypeScript-first schema declaration and validation library.
- Next.js: A React framework for production.
- ShadCN: A collection of beautiful and reusable React components.
- Server Actions: For handling server-side logic directly in your Next.js application.
Make sure you have the following installed on your machine:
- Node.js (v14 or higher)
- npm or yarn
- PostgreSQL (or any other TypeORM compatible database)
-
Clone the repository:
git clone https://github.com/Guxxtavoww/election-simulator.git cd election-simulator
-
Install dependencies for both server and client:
cd server pnpm install cd ../client pnpm install
-
Set up your environment variables. Create a
.env
file in theserver
directory and add the following:DATABASE_ROOT_PASSWORD=randon-password DATABASE_DATABASE_NAME="election_simulator-db" DB_PORT=5432 DATABASE_HOST="localhost" DB_USER="root" JWT_SECRET=secret JWT_EXPIRES_IN=1d PORT=5000 ENV=dev
-
Run database migrations:
npm run typeorm migration:run
-
Start the server:
npm run start:dev
The server should now be running at http://localhost:5000
.
-
Set up your environment variables. Create a
.env.local
file in theclient
directory and add the following:NEXT_PUBLIC_API_BASE_URL="http://localhost:5000/server"
-
Start the client:
npm run dev
The client should now be running at http://localhost:3000
.
- Open your browser and go to
http://localhost:3000
. - Sign up or log in to access the application.
- Create and manage elections, cast votes, and view results through the interactive interface.
API documentation is available through Swagger. Once the server is running, navigate to http://localhost:5000/server#/
to explore the API endpoints and their usage.
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature
). - Make your changes.
- Commit your changes (
git commit -am 'Add your feature'
). - Push to the branch (
git push origin feature/your-feature
). - Create a new Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
Thank you for using the Election Simulator App! If you have any questions or need further assistance, feel free to reach out.