A complete Next.js application for managing events with user registration and random winner drawing. Built with TypeScript, Prisma, PostgreSQL, Redis, and DaisyUI.
- Authentication: JWT-based login system
- Event Management: Create, edit, delete events with status transitions
- Drawing System: Cryptographically secure random winner selection
- Real-time Monitoring: View participants as they register
- QR Code Generation: Fullscreen QR codes for easy registration
- Admin Management: Create and manage multiple admin accounts
- Easy Registration: Register with just a name via QR code or link
- Status Tracking: Real-time event status updates (polling every 3s)
- Winner Notification: Confetti animation for winners
- Cancel Registration: Users can cancel while registration is open
- TypeScript: Strict mode, no
anytypes - Server Components: React Server Components by default
- Theme System: Light/dark mode with OS detection
- Database: PostgreSQL with Prisma ORM
- Redis: Ready for WebSocket scaling
- Docker: Complete Docker Compose setup
- Production Ready: Optimized multi-stage Dockerfile
- Node.js 22 LTS
- Docker and Docker Compose
-
Clone and setup:
npm install cp .env.example .env
-
Start services:
docker-compose up -d postgres redis
-
Run migrations and seed:
npm run db:migrate npm run db:seed
-
Start development server:
npm run dev
-
Access the application:
- Admin: http://localhost:3004/admin/login
- Default credentials:
admin/password
├── app/
│ ├── admin/(dashboard)/ # Protected admin routes
│ │ ├── events/ # Event management
│ │ └── admins/ # Admin management
│ ├── admin/(auth)/ # Public admin routes
│ │ └── login/ # Login page
│ ├── events/[id]/ # Public user routes
│ │ ├── register/ # Registration page
│ │ └── status/ # Status/waiting page
│ └── api/ # API routes
├── components/ # React components
├── lib/ # Utilities
│ ├── auth/ # JWT & middleware
│ └── db/ # Prisma client
├── prisma/ # Database schema & migrations
└── types/ # TypeScript types
- Login: Navigate to
/admin/login - Create Event: Click "create event" button
- Open Registration: Change status to "REGISTRATION_OPEN"
- Share QR Code: Use fullscreen QR or copy link
- Close Registration: Change status to "REGISTRATION_CLOSED"
- Start Drawing: Change status to "DRAWING"
- Draw Winners: Click "draw next winner" for each winner
- Close Event: Click "close event" when done
- Register: Scan QR code or open registration link
- Wait: View real-time status updates
- Result: See confetti if you win!
INIT → REGISTRATION_OPEN → REGISTRATION_CLOSED → DRAWING → CLOSED
↑_________________↓
(bidirectional)
POST /api/admin/login- Admin loginPOST /api/admin/logout- Admin logoutGET /api/admin/me- Get current adminGET /api/admin/events- List all eventsPOST /api/admin/events- Create eventGET /api/admin/events/[id]- Get event detailsPUT /api/admin/events/[id]- Update eventDELETE /api/admin/events/[id]- Delete eventPOST /api/admin/events/[id]/status- Update statusPOST /api/admin/events/[id]/draw- Draw winnerDELETE /api/admin/events/[id]/participants/[participantId]- Remove participant
GET /api/events/[id]- Get event infoPOST /api/events/[id]/register- Register participantDELETE /api/events/[id]/register/[participantId]- Cancel registrationGET /api/events/[id]/status/[participantId]- Get participant status
# Database
DATABASE_URL=postgresql://eventuser:eventpass@localhost:5433/event_management
# Redis
REDIS_URL=redis://localhost:6380
# JWT
JWT_SECRET=your-secure-secret-key-here
JWT_EXPIRES_IN=7d
# Next.js
NEXT_PUBLIC_BASE_URL=http://localhost:3004npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
npm run format # Format code with Prettier
npm run type-check # TypeScript type checking
npm run db:migrate # Run Prisma migrations
npm run db:seed # Seed default admin
npm run db:studio # Open Prisma Studio# Start all services
docker-compose up -d
# Start only database and redis
docker-compose up -d postgres redis
# Stop all services
docker-compose down
# View logs
docker-compose logs -f
# Rebuild containers
docker-compose up -d --build-
Build the application:
npm run build
-
Set environment variables:
- Generate secure JWT_SECRET:
openssl rand -base64 32 - Update DATABASE_URL for production
- Set NEXT_PUBLIC_BASE_URL to your domain
- Generate secure JWT_SECRET:
-
Deploy with Docker:
docker-compose up -d
-
Run migrations:
docker-compose exec app npx prisma migrate deploy docker-compose exec app npx prisma db seed
- Framework: Next.js 15 (App Router)
- Language: TypeScript 5 (strict mode)
- Database: PostgreSQL 16
- ORM: Prisma 6
- Cache: Redis 7
- Authentication: JWT with httpOnly cookies
- Styling: Tailwind CSS + DaisyUI
- Validation: Zod
- QR Codes: qrcode.react
- Confetti: canvas-confetti
- No
anytypes: All TypeScript is strictly typed - Comments: English, lowercase, brief
- Commits: Lowercase conventional commits (feat/fix/chore)
- Server Components: Used by default, client components only when needed