Poll Application
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.
🌐 Live Demo
Deployed on Vercel: Comming Soon
🚀 Quick Deploy to Vercel
One-Click Deploy (Production Ready)

📖 For detailed deployment instructions: See PRODUCTION_DEPLOYMENT.md
Manual Deployment Steps
- Fork/Clone this repository
- Connect to Vercel:
- Go to vercel.com
- Sign in with your GitHub account
- Click “New Project”
- Import your
poll-application repository
- 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.sql in your Supabase SQL editor
- Deploy: Vercel will automatically build and deploy your application!
🛠️ Local Development
Prerequisites
- Node.js 18+ installed
- A Supabase account and project
Setup Instructions
- 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.sql in your Supabase SQL editor.
- Start the development server:
Visit http://localhost:3000 and start creating polls!
Features
- 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
Tech Stack
- 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
Database Schema
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
Prerequisites
- Node.js 18+
- npm or yarn
- Supabase account
Setup Instructions
Option 1: Demo Mode (Recommended for Testing)
- 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:3001 and sign in with any email/password!
Option 2: Production Mode with Supabase
For production use with persistent data:
1. Clone the Repository
git clone https://github.com/amitesh-maurya/poll-application.git
cd poll-application
2. Install Dependencies
3. Set up Supabase
- 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.sql to create tables and policies
4. Environment Variables
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.com
5. Generate NextAuth Secret
Copy the generated secret to your .env.local file.
6. Run the Application
The application will be available at http://localhost:3000
Usage
- 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
Authentication
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.
Database Security
- 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
API Endpoints
GET /api/polls - Fetch all polls or user’s polls
POST /api/polls - Create a new poll
GET /api/polls/[id] - Get poll details with options and user’s vote
PUT /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
Development Notes
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
Architecture Decisions
- 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
Production Deployment
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
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
💫 Credits & Ownership
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.