A full-stack poll application built with Next.js, NextAuth, and Supabase. Users can create polls, vote on them, and view real-time results with proper authentication and authorization.
Deployed on Vercel: Comming Soon
📖 For detailed deployment instructions: See PRODUCTION_DEPLOYMENT.md
-
Fork/Clone this repository
-
Connect to Vercel:
- Go to vercel.com
- Sign in with your GitHub account
- Click "New Project"
- Import your
poll-applicationrepository
-
Configure Environment Variables in Vercel: Go to your project settings in Vercel and add these environment variables:
NEXT_PUBLIC_SUPABASE_URL=https://lymdzzecuwprowhuvnku.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=your_actual_anon_key SUPABASE_SERVICE_ROLE_KEY=your_actual_service_role_key NEXTAUTH_URL=https://your-vercel-url.vercel.app NEXTAUTH_SECRET=your_random_secret_key_32_chars_min ALLOW_UNCONFIRMED_EMAIL=false
-
Apply Database Schema:
- Run the SQL from
database-schema.sqlin your Supabase SQL editor
- Run the SQL from
-
Deploy: Vercel will automatically build and deploy your application!
- Node.js 18+ installed
- A Supabase account and project
- Clone and install dependencies:
git clone https://github.com/amitesh-maurya/poll-application.git
cd poll-application
npm install-
Set up your Supabase project:
- Go to https://app.supabase.com
- Create a new project or use an existing project
- Navigate to Settings > API
- Copy your project URL and API keys
-
Configure environment variables: Create a .env.local file in the root directory:
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key SUPABASE_SERVICE_ROLE_KEY=your_service_role_key NEXTAUTH_URL=http://localhost:3000 NEXTAUTH_SECRET=your_secret_key_for_local_dev
-
Set up the database schema: Run the SQL commands from
database-schema.sqlin your Supabase SQL editor. -
Start the development server:
npm run devVisit http://localhost:3000 and start creating polls!
- Authentication: Secure user authentication using NextAuth with Supabase backend
- Poll Management: Create, edit, and delete polls with multiple options
- Voting System: One vote per user per poll with backend enforcement
- Real-time Results: View poll results with vote counts and percentages
- Responsive Design: Mobile-friendly interface built with Tailwind CSS
- Route Protection: Protected routes for authenticated users only
- Frontend: Next.js 15, React 19, TypeScript, Tailwind CSS
- Backend: Next.js API Routes, Supabase (PostgreSQL)
- Authentication: NextAuth.js with Supabase adapter
- Database: Supabase (PostgreSQL with Row Level Security)
- Styling: Tailwind CSS
- Form Handling: React Hook Form with Zod validation
- Icons: Lucide React
The application uses 4 main tables:
- profiles - User profile information
- polls - Poll data with title, description, creator
- poll_options - Individual options for each poll
- votes - User votes with unique constraint per poll
- Node.js 18+
- npm or yarn
- Supabase account
- Clone and Install:
git clone https://github.com/amitesh-maurya/poll-application.git
cd poll-application
npm install
npm run dev- Start Using: Visit
http://localhost:3001and sign in with any email/password!
For production use with persistent data:
git clone https://github.com/amitesh-maurya/poll-application.git
cd poll-applicationnpm install- Create a new project at supabase.com
- Go to Settings > Database and find your connection details
- Go to Settings > API and find your URL and anon key
- Go to Settings > API and find your service role key
- In the SQL Editor, run the contents of
database-schema.sqlto create tables and policies
Create a .env.local file in the root directory:
# Supabase Configuration
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
# NextAuth Configuration
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your_random_secret_string
# Email Configuration (optional - for email provider)
EMAIL_SERVER_HOST=smtp.example.com
EMAIL_SERVER_PORT=587
EMAIL_SERVER_USER=your_email_user
EMAIL_SERVER_PASSWORD=your_email_password
EMAIL_FROM=noreply@example.comnpx auth secretCopy the generated secret to your .env.local file.
npm run devThe application will be available at http://localhost:3000
- Sign Up/Sign In: Create an account or sign in with existing credentials
- Dashboard: View all polls and your created polls
- Create Poll: Click "Create Poll" to make a new poll with multiple options
- Vote: Click on any poll to view details and vote (if you haven't already)
- View Results: After voting, see real-time results with percentages
- Manage Polls: Edit or delete your own polls from the dashboard
The application uses NextAuth.js with two providers:
- Credentials Provider: Simple email/password authentication with automatic user profile creation
- Email Provider: Magic link authentication (requires email configuration)
User profiles are automatically created in the Supabase database when users sign in with credentials. All routes except authentication pages are protected and require login.
- Row Level Security (RLS) is enabled on all tables
- Users can only see and modify their own data where appropriate
- Votes are enforced at the database level with unique constraints
- All API endpoints validate user permissions
GET /api/polls- Fetch all polls or user's pollsPOST /api/polls- Create a new pollGET /api/polls/[id]- Get poll details with options and user's votePUT /api/polls/[id]- Update a poll (owner only)DELETE /api/polls/[id]- Soft delete a poll (owner only)POST /api/votes- Submit a vote for a poll
During development, I used GitHub Copilot and Claude AI to:
- Generate boilerplate code for API routes and components
- Debug TypeScript type issues
- Create a comprehensive database schema with proper relationships
- Optimise SQL queries and database policies
- Generate consistent styling with Tailwind CSS classes
- NextAuth with Custom Implementation: Used NextAuth for session management, but implemented custom user creation in Supabase
- API Routes: Used Next.js API routes for backend logic rather than direct Supabase calls
- TypeScript: Full TypeScript implementation for type safety
- Tailwind CSS: Utility-first CSS for rapid UI development
- Simplified RLS: Database-level security with simplified policies for demo purposes
For production deployment:
- Set up production Supabase project
- Configure environment variables on your hosting platform
- Set up a proper email provider for magic links
- Consider adding Google/GitHub OAuth providers
- Enable Supabase RLS policies
- Set up proper error monitoring
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This chat application was designed and developed by Amitesh Maurya.
© 2025 Amitesh Maurya — All rights reserved.
This project is shared publicly for portfolio and learning purposes only.
Unauthorised commercial use or redistribution is strictly prohibited.