A secure voting platform that enables authenticated users to vote for their preferred cloud provider.
- Clone and Configure
git clone https://github.com/yourusername/cloud-summit-2025.git
cd cloud-summit-2025
# Edit .env.local with your values- Setup and Run
npm run local:setup # Installs dependencies and mongodb locally, stops any running MongoDB instance, sets up fresh DB
npm run dev # Starts development serverVisit http://localhost:3000 to see the application.
-
Create Environment File
cp .env.example .env.local
-
Configure OAuth (GitHub)
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set callback URL to
http://localhost:3000/api/auth/callback/github - Add credentials to
.env.local:GITHUB_ID=your-github-oauth-id GITHUB_SECRET=your-github-oauth-secret
-
Configure OAuth (Google)
- Go to Google Cloud Console
- Create OAuth 2.0 credentials
- Set callback URL to
http://localhost:3000/api/auth/callback/google - Add credentials to
.env.local:GOOGLE_ID=your-google-oauth-id GOOGLE_SECRET=your-google-oauth-secret
-
Configure Admin Access
ADMIN_EMAILS="your-email@example.com"
-
Set Required Environment Variables
APP_ENV=development NEXTAUTH_URL=http://localhost:3000 NEXTAUTH_SECRET=$(openssl rand -base64 32) DATABASE_URL=mongodb://localhost:27017/cloud-summit
The local:setup command performs these steps:
-
Install Dependencies
npm install
-
Stop Existing MongoDB
npm run local:db:stop
-
Initialize MongoDB
npm run local:db:setup
-
Push Schema
npm run local:db:push
-
Seed Database
npm run local:db:seed
You can run these steps manually if needed, or use the combined command:
npm run local:setup-
Start MongoDB (if not running)
npm run local:db:start
-
Start Development Server
npm run dev
-
Check MongoDB
# Verify MongoDB is running brew services list | grep mongodb # Test connection mongosh --eval "db.runCommand({ ping: 1 })"
-
Check Application
- Open http://localhost:3000
- Try signing in with GitHub/Google
- Verify admin access if configured
-
MongoDB Connection Failed
# Restart MongoDB npm run local:db:restart # Check logs tail -f /opt/homebrew/var/log/mongodb/mongo.log
-
OAuth Login Failed
- Verify callback URLs in GitHub/Google settings
- Check environment variables
- Ensure development server is running on correct port
-
Admin Access Issues
- Verify email in
ADMIN_EMAILSmatches OAuth email exactly - Check Authentication for more details
- Verify email in
For more detailed information about:
- Database management: See Database Management
- Authentication setup: See Authentication
- System configuration: See Voting System
- Contact luisheratm@gmail.com
- Local: Development environment with local MongoDB
- Staging: Railway deployment from
voting-systembranch - Production: Vercel deployment from
mainbranch
- Node.js and npm
- macOS (for local MongoDB setup)
- Homebrew package manager
- At least 1GB of free disk space
- GitHub account (for authentication)
- Google Cloud account (for authentication)
npm run dev # Start development server (runs local:dev)
npm run start # Start production server (runs prod:start)
npm run build # Build for production (runs prod:build)
npm run lint # Run ESLint (runs local:lint)# Core Commands
npm run local:dev # Start development server
npm run local:start # Start production server locally
npm run local:build # Build for local testing
npm run local:lint # Run ESLint
# Setup and Reset
npm run local:setup # Complete first-time setup (stops MongoDB if running, installs, sets up fresh DB)
# MongoDB Service
npm run local:db:start # Start MongoDB service
npm run local:db:stop # Stop MongoDB service
npm run local:db:restart # Restart MongoDB service
# Database Management
npm run local:db:setup # Set up local MongoDB
npm run local:db:push # Push schema to database
npm run local:db:seed # Seed development data
npm run local:db:clean # Clean development data
npm run local:db:studio # Open database GUI# Core Commands
npm run staging:build # Build for Railway (includes Prisma)
npm run staging:start # Start on Railway
# Database Management
npm run staging:db:seed # Seed staging data
npm run staging:db:clean # Clean staging datanpm run prod:build # Build for production
npm run prod:start # Start production server- Starting Fresh
npm run local:setup # Stops existing MongoDB, sets up fresh instance
npm run dev # Start development server- Regular Start
npm run local:db:start # Start MongoDB
npm run dev # Start development server- Ending Development
# Stop the development server (Ctrl+C)
npm run local:db:stop # Stop MongoDB- View Data:
npm run local:db:studio - Reset Data:
npm run local:db:clean && npm run local:db:seed - Update Schema:
npm run local:db:push
- MongoDB Won't Start
# Check status
brew services list | grep mongodb
# Restart service
npm run local:db:restart
# Check logs
tail -f /opt/homebrew/var/log/mongodb/mongo.log- Port Already in Use
# Check port
lsof -i :27017
# Stop MongoDB
npm run local:db:stop- Connection Failed
# Verify service
brew services list | grep mongodb
# Test connection
mongosh --eval "db.runCommand({ ping: 1 })"- Database Setup
npm run local:db:setup
npm run local:db:push
npm run local:db:seed- Start Development
npm run local:dev # or npm run dev-
Prerequisites
- Railway account
- Access to project's Railway team
- MongoDB add-on in Railway
-
Environment Setup
- Configure in Railway dashboard:
DATABASE_URL=<railway-mongodb-url> GITHUB_ID=<staging-github-id> GITHUB_SECRET=<staging-github-secret> GOOGLE_ID=<staging-google-id> GOOGLE_SECRET=<staging-google-secret> NEXTAUTH_URL=<railway-app-url> NEXTAUTH_SECRET=<your-secret>
- Configure in Railway dashboard:
-
Deployment
- Push to
voting-systembranch - Railway automatically:
- Runs
staging:build(includes Prisma generation) - Deploys the application
- Runs
- Run
npm run staging:db:seedif needed
- Push to
-
Prerequisites
- Vercel account
- MongoDB Atlas cluster
- Production OAuth credentials
-
Environment Setup
- Configure in Vercel dashboard:
DATABASE_URL=<atlas-mongodb-url> GITHUB_ID=<prod-github-id> GITHUB_SECRET=<prod-github-secret> GOOGLE_ID=<prod-google-id> GOOGLE_SECRET=<prod-google-secret> NEXTAUTH_URL=<production-domain> NEXTAUTH_SECRET=<your-secret>
- Configure in Vercel dashboard:
-
Deployment
- Push to
mainbranch - Vercel automatically:
- Runs
prod:build - Generates Prisma client
- Deploys the application
- Runs
- Push to
DATABASE_URL=mongodb://localhost:27017/cloud-summit
GITHUB_ID=<github-oauth-id>
GITHUB_SECRET=<github-oauth-secret>
GOOGLE_ID=<google-oauth-id>
GOOGLE_SECRET=<google-oauth-secret>
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=<generated-secret>- MongoDB URL provided by Railway add-on
- OAuth credentials for staging environment
- NEXTAUTH_URL points to Railway deployment
- MongoDB Atlas connection string
- Production OAuth credentials
- NEXTAUTH_URL points to production domain
# Database
DATABASE_URL=mongodb://localhost:27017/cloud-summit
# Authentication
GITHUB_ID=<github-oauth-id>
GITHUB_SECRET=<github-oauth-secret>
GOOGLE_ID=<google-oauth-id>
GOOGLE_SECRET=<google-oauth-secret>
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=<generated-secret>
# Admin Access
ADMIN_EMAILS="admin@example.com,another-admin@example.com" # Comma-separated list of admin emails
# Environment
APP_ENV=development # development, staging, or productionOur documentation is split into three main areas that work together:
-
- Database models and relationships
- API endpoints and caching strategy
- Voting process flow
- Error handling
- Security measures
- Integration with authentication
-
- OAuth configuration
- Session management
- Protected routes
- Admin access control
- Integration with database
-
- Environment-specific behavior
- Available commands
- Seeding and data management
- Admin configuration
- Integration with voting system
- Troubleshooting guide
- Admin Configuration
- Environment Setup
- Authentication Flow
- API Documentation
- Database Models
- Troubleshooting
To configure admin access:
- Add admin email addresses to
ADMIN_EMAILSin your environment variables - Ensure emails match exactly with OAuth provider (GitHub/Google) emails
- Admins will have access to:
- Admin dashboard at
/admin - Database management
- System configuration
- Analytics
- Admin dashboard at
For more details, see Database Management.
-
Environment Variables
- Never commit
.envfiles - Keep
ADMIN_EMAILSlist secure - Use strong
NEXTAUTH_SECRET
- Never commit
-
Database Access
- Restrict MongoDB access
- Use strong passwords
- Enable authentication
-
Admin Access
- Regularly audit admin list
- Use secure email providers
- Monitor admin actions
To learn more about Next.js, take a look at the following resources:
The easiest way to deploy your Next.js app is to use the Vercel Platform.
Check out our Next.js deployment documentation for more details.