The purpose of this application is to streamline the application and nomination processes for senators at SGA (Student Government Association).
Frontend & Backend:
- Next.js 16 - React framework with App Router
- React 19 - UI library
- TypeScript - Type safety
Database:
- Prisma - Modern ORM for PostgreSQL
- PostgreSQL - Relational database
UI Components:
- Material UI - Component library
- styled-components - CSS-in-JS
This is a modern Next.js 16 application with:
- No API routes - All data access happens server-side
- Server Functions - Direct database queries from React Server Components
- Server Actions - Form submissions with
'use server'directive - Prisma ORM - Type-safe database access
/
├── app/ # Next.js App Router
│ ├── layout.tsx # Root layout
│ ├── page.tsx # Home page
│ └── (pages)/ # Application pages (to be migrated)
├── lib/ # Server-side code
│ ├── db.ts # Prisma client singleton
│ ├── data/ # Data access layer
│ │ ├── applications.ts
│ │ ├── nominations.ts
│ │ └── users.ts
│ └── actions/ # Server actions for mutations
│ ├── applications.ts
│ └── nominations.ts
├── components/ # React components (to be migrated)
├── prisma/
│ └── schema.prisma # Database schema
└── package.json
The application manages three main entities:
- Applications - Senator applications from students
- Nominations - Nominations for senator candidates
- Users - System users with roles (Admin, Applicant, Standard)
-
Node.js (v18 or higher)
-
Docker Desktop (for local database)
- Required for running the local PostgreSQL database
- To check if it's installed:
docker --version
- Clone the repository:
git clone https://github.com/b-at-neu/nomination-system.git
cd nomination-system- Install dependencies:
npm install- Set up your environment variables:
cp .env.example .env.localThe .env.example file comes pre-configured with local database settings. For local development, you can use these defaults as-is.
For production or if you want to use a different database:
DATABASE_URL="postgresql://user:password@host:port/database"
DIRECT_URL="postgresql://user:password@host:port/database"
NEXT_PUBLIC_SUPABASE_URL="your-supabase-project-url"
NEXT_PUBLIC_SUPABASE_ANON_KEY="your-supabase-anon-key"
SUPABASE_SERVICE_ROLE_KEY="your-supabase-service-role-key"
To get your Supabase credentials:
- Create a project at Supabase
- Go to Project Settings > API
- Copy the Project URL and anon/public key
- Copy the service_role key (this is needed for user management - keep it secret!)
This project uses Docker to run a local PostgreSQL database for development. This allows you to test database schema changes locally before deploying to production.
- Docker Desktop must be installed and running
- Ensure port 5432 is available on your machine
- Make sure you have copied
.env.exampleto.env.local:
cp .env.example .env.localThe default local database connection is already configured in .env.example:
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/senate_path_dev?schema=public"
DIRECT_URL="postgresql://postgres:postgres@localhost:5432/senate_path_dev?schema=public"
- Start the local PostgreSQL database:
npm run db:start- Run Prisma migrations to create the database schema:
npm run prisma:migrateYou're now ready to develop! The local database will persist data between restarts.
| Command | Description |
|---|---|
npm run db:start |
Start the Docker PostgreSQL container in the background |
npm run db:stop |
Stop the Docker container (data is preserved) |
npm run db:reset |
Stop container, remove all data, start fresh, and run migrations |
npm run prisma:migrate |
Create and apply a new Prisma migration (will prompt for migration name) |
npm run prisma:studio |
Open Prisma Studio to visually browse and edit your local database |
npm run prisma:generate |
Regenerate Prisma client after schema changes |
- Create a new branch for your work:
git checkout -b 123-add-new-feature- Start the local database (if not already running):
npm run db:start-
Make changes to your Prisma schema in
prisma/schema.prisma -
Create and apply the migration:
npm run prisma:migratePrisma will prompt you for a migration name (e.g., "add_user_role_field")
- Test your changes locally using Prisma Studio or your application:
npm run prisma:studio # Visual database browser
npm run dev # Start Next.js dev server- Commit both your schema changes AND the migration files:
git add prisma/schema.prisma prisma/migrations/
git commit -m "#123 add new feature"
git pushPort 5432 already in use
- Mac/Linux: Check if PostgreSQL is running:
sudo lsof -i :5432 - Windows: Check port usage:
netstat -ano | findstr :5432 - Stop the existing PostgreSQL service or change the port in
docker-compose.yml
Container won't start
- Make sure Docker Desktop is running
- Check Docker logs:
docker logs senate-path-db - Try removing the container:
docker compose down -vthennpm run db:start
Database connection errors
- Verify the container is running:
docker ps - Check your
.env.localfile has the correctDATABASE_URL - Try restarting the container:
npm run db:stop && npm run db:start
Need to start fresh
- Use
npm run db:resetto completely reset your local database - This will delete all data and re-run migrations
Migration conflicts
- If you have uncommitted migrations, you may need to reset:
npm run db:reset - Delete problematic migration folders from
prisma/migrations/and re-create them
- Local database is completely separate from production/staging databases
- Migration files in
prisma/migrations/are version controlled - Migrations run automatically on deployment when merged to
devormainbranches
For development:
npm run devThe application will be available at http://localhost:3000/
For production build:
npm run build
npm startnpm run dev- Start development servernpm run build- Build for productionnpm start- Start production servernpm run lint- Run ESLint
npm run db:start- Start local Docker PostgreSQL containernpm run db:stop- Stop local Docker containernpm run db:reset- Reset local database (removes all data and re-runs migrations)
npm run prisma:generate- Generate Prisma clientnpm run prisma:migrate- Create and apply database migrationsnpm run prisma:studio- Open Prisma Studio for database inspection
- Application Submission - Students can submit their senator applications
- Nomination System - Constituents can nominate candidates
- Admin Dashboard - View and manage all applications and nominations (protected by authentication)
- Nomination Approval System - Admins can review and approve/reject nominations
- Dedicated nominations management page at
/admin/nominations - Filter nominations by status (Pending, Approved, Rejected) or by specific nominee
- Search across all nomination fields (nominee, nominator, email, college, major)
- Sort nominations by date, nominee name, or status
- Bulk approve or reject multiple nominations at once
- View statistics: total, pending, approved, rejected nominations and unique nominees
- New nominations are created with PENDING status and require admin approval
- Dedicated nominations management page at
- User Management - Admin page to create and remove authentication accounts
- Create new admin users with email and password
- Delete existing users (cannot delete your own account)
- View all registered users and their activity
- Authentication - Secure password-based login via Supabase Auth
- Email and password authentication
- Admin pages are protected and only accessible to logged-in users
- Admin link only visible in navbar for authenticated users
- Constituency Validation - Ensures nominators and nominees are in the same constituency
- Duplicate Prevention - Prevents duplicate nominations and applications
The application uses Supabase Auth with email and password for authentication:
- Users click "Login" in the navbar
- They enter their email address and password
- Once authenticated, users can access the Admin Dashboard and User Management
- Admin users can create new accounts from the User Management page (
/admin/users)
The admin page (/admin) is protected by middleware and requires authentication to access.
This Next.js application can be deployed to:
Make sure to set the following environment variables in your deployment platform:
DATABASE_URL- PostgreSQL database connection stringDIRECT_URL- Direct PostgreSQL connection string (for Prisma migrations)NEXT_PUBLIC_SUPABASE_URL- Supabase project URLNEXT_PUBLIC_SUPABASE_ANON_KEY- Supabase anonymous/public keySUPABASE_SERVICE_ROLE_KEY- Supabase service role key (required for user management)
- All data fetching uses React Server Components
- Form submissions use Next.js Server Actions
- No client-side API calls needed
- Prisma provides full type safety from database to UI
- Database migrations are managed through Prisma Migrate