This is a full-stack Next.js application for managing and running a simple election, such as for a Class Representative. It provides an admin dashboard for managing candidates and voters, and a public-facing portal for students to cast their votes.
- Framework: Next.js (App Router)
- UI: React with TypeScript
- Styling: Tailwind CSS
- UI Components: ShadCN UI
- AI Features: Google AI (Gemini) via Genkit
- State Management: React Hooks (
useState,useActionState)
This application is intended as a demonstration and uses a local JSON file (src/lib/data.json) for data storage. This is great for simplicity and running the app locally.
However, on most hosting platforms (like Vercel, Render, etc.), the filesystem is ephemeral. This means the data.json file will be reset every time the application is deployed or restarted, and all your data will be lost.
Before using this in a live production environment, you MUST replace the file-based storage with a persistent database service like Firebase Firestore or Supabase.
Follow these instructions to get the project up and running on your local machine for development and testing purposes.
First, get the project code onto your local machine.
Navigate into the project's root directory in your terminal and install the required npm packages:
npm installThe application uses environment variables for the admin password.
- Create a new file named
.envin the root of your project. - Add the following lines to your new
.envfile, changing the credentials to whatever you want:
# Admin credentials for accessing the /admin dashboard
ADMIN_USERNAME=admin
ADMIN_PASSWORD=password
# Optional: You can get a Google AI API key for the "Election Insights" feature.
# Get a key from AI Studio: https://aistudio.google.com/app/apikey
# GEMINI_API_KEY=your_google_ai_api_key_hereStart the Next.js development server:
npm run devThe application should now be running at http://localhost:9002.
I cannot push the code for you, but you can do it yourself with these terminal commands from your project folder.
-
Create a New Repository on GitHub: Go to github.com/new, create a new repository (without a README), and copy its HTTPS URL.
-
Run these commands:
# Initialize a new Git repository
git init -b main
# Add all the files to be tracked
git add .
# Create the first commit
git commit -m "Initial commit of the CR Vote app"
# Add your new GitHub repository as the remote
# (Replace the URL with the one you copied)
git remote add origin https://github.com/your-username/your-repo-name.git
# Push your code to GitHub
git push -u origin main