Skip to content

Gaurav-205/LetsSpiceUp

Repository files navigation

🎭 Prank Wizard

A full-stack web application for planning and managing personalized pranks. Built with Next.js and Express.js, featuring a modern UI, secure authentication, comprehensive prank planning wizard, and admin dashboard.

Next.js React TypeScript Express MongoDB

✨ Features

🎯 Core Features

  • Prank Planning Wizard - Multi-step form to create personalized prank plans with comprehensive target information
  • Prank Management - View, manage, and track all your prank submissions
  • User Dashboard - Personalized home page with quick access to features
  • Profile Management - View and manage your account information
  • Admin Dashboard - Comprehensive admin panel for managing users and pranks
    • User management (view, delete users)
    • Prank management (view details, delete pranks)
    • Statistics dashboard (user counts, prank counts, recent activity)
    • Pagination support for large datasets

πŸ“ Prank Form Features

  • Planner Information: Name, phone, email
  • Target Information:
    • Name, age, phone (required), email
    • Relationship, gender, location
    • Personality types (multi-select)
  • Prank Details: Type selection, additional information
  • Form Persistence: Auto-saves progress to local storage
  • Validation: Real-time form validation with error messages

πŸ” Authentication & Security

  • βœ… User Registration with email validation
  • βœ… Secure Login with JWT tokens
  • βœ… Password Reset via email
  • βœ… Google OAuth integration
  • βœ… Protected routes and API endpoints
  • βœ… Admin role-based access control
  • βœ… Password strength indicator
  • βœ… Session management with MongoDB store
  • βœ… Rate limiting on API endpoints
  • βœ… Input sanitization and validation
  • βœ… Security headers (Helmet)
  • βœ… CORS configuration
  • βœ… Environment variable validation

🎨 User Interface

  • Modern, responsive design with Tailwind CSS v4
  • Dark theme with glassmorphism effects
  • Smooth animations and transitions (GSAP)
  • Interactive 3D background (Three.js Ballpit component)
  • Mobile-first responsive layout
  • Mobile Optimizations:
    • Prevents unwanted zoom on input focus
    • Minimum 16px font size for inputs
    • Touch-friendly interface
  • Accessible components (ARIA labels, keyboard navigation)
  • Toast notifications for user feedback
  • Loading states and error handling
  • Error boundaries for graceful error handling
  • Custom favicon with brand logo

πŸš€ Production Ready

  • TypeScript for type safety
  • Error boundaries and centralized error handling
  • Structured logging
  • Environment variable validation
  • Docker support with multi-stage builds
  • CI/CD with GitHub Actions
  • SEO optimized (sitemap, robots.txt, metadata, structured data)
  • Performance optimizations (code splitting, lazy loading, image optimization)
  • Health check endpoints for monitoring
  • Keep-alive workflow for free tier hosting

πŸ› οΈ Tech Stack

Frontend

  • Framework: Next.js 16 (App Router)
  • UI Library: React 19
  • Language: TypeScript
  • Styling: Tailwind CSS v4
  • State Management: React Context API
  • HTTP Client: Axios
  • Animations: GSAP, Three.js (Ballpit component)
  • Form Management: Local storage persistence

Backend

  • Framework: Express.js
  • Language: TypeScript
  • Database: MongoDB with Mongoose
  • Authentication: JWT, Passport.js (Google OAuth)
  • Security: Helmet, CORS, bcrypt, express-rate-limit
  • Email: Nodemailer, SendGrid support
  • Session: express-session with MongoDB store (connect-mongo)
  • Validation: Custom validators with express-validator patterns

DevOps & Deployment

  • Frontend Hosting: Netlify
  • Backend Hosting: Render
  • Containerization: Docker & Docker Compose
  • CI/CD: GitHub Actions
    • Automated linting (ESLint)
    • Type checking
    • Build verification
    • Security audits
    • Keep-alive workflow for backend

πŸš€ Quick Start

Prerequisites

  • Node.js 20.9.0 or higher
  • npm 9.0.0 or higher
  • MongoDB (local or MongoDB Atlas)

1. Clone the Repository

git clone <your-repo-url>
cd BaseProject_Nextjs_LoginSignup-main

2. Install Dependencies

# Backend
cd backend
npm install

# Frontend
cd ../frontend
npm install

3. Configure Environment Variables

Backend - Create backend/.env:

Option 1 - Automated setup (Recommended):

cd backend
npm run setup:env
# Then edit the created .env file with your values

Option 2 - Manual setup:

cd backend
cp env.example .env  # On Windows: copy env.example .env

Required Backend Variables:

# Database (REQUIRED)
MONGODB_URI=mongodb://localhost:27017/prank-wizard
# Or for MongoDB Atlas: mongodb+srv://user:pass@cluster.mongodb.net/prank-wizard

# JWT & Session (REQUIRED)
JWT_SECRET=your-secret-key-min-32-characters  # Generate: openssl rand -base64 32
SESSION_SECRET=your-session-secret-min-32-characters  # Generate: openssl rand -base64 32

# Frontend URL (REQUIRED)
FRONTEND_URL=http://localhost:3000

# Server Configuration (OPTIONAL)
PORT=5000
NODE_ENV=development
JWT_EXPIRES_IN=7d

# Google OAuth (OPTIONAL)
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_CALLBACK_URL=http://localhost:5000/api/auth/google/callback

# Email Configuration (OPTIONAL - for password reset)
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-password
EMAIL_FROM=noreply@yourapp.com

# SendGrid (OPTIONAL - alternative to SMTP)
SENDGRID_API_KEY=your-sendgrid-api-key

# Admin Configuration (OPTIONAL)
# Comma-separated list of admin emails
# Defaults to: gauravkhandelwal205@gmail.com,ananykoranne0@gmail.com
ADMIN_EMAILS=gauravkhandelwal205@gmail.com,ananykoranne0@gmail.com

Frontend - Create frontend/.env.local:

# API Configuration (REQUIRED)
NEXT_PUBLIC_API_URL=http://localhost:5000

# Site URL (REQUIRED)
NEXT_PUBLIC_SITE_URL=http://localhost:3000

# Discord Invite Link (OPTIONAL - for success page)
NEXT_PUBLIC_DISCORD_INVITE_LINK=https://discord.gg/your-invite-link

4. Start Development Servers

# Terminal 1 - Backend
cd backend
npm run dev

# Terminal 2 - Frontend
cd frontend
npm run dev

Visit http://localhost:3000 to see the application.

πŸ“ Project Structure

β”œβ”€β”€ frontend/                 # Next.js frontend application
β”‚   β”œβ”€β”€ app/                  # Next.js App Router pages
β”‚   β”‚   β”œβ”€β”€ page.tsx          # Landing page with Ballpit animation
β”‚   β”‚   β”œβ”€β”€ layout.tsx        # Root layout with metadata & fonts
β”‚   β”‚   β”œβ”€β”€ login/            # Login page
β”‚   β”‚   β”œβ”€β”€ signup/           # Signup page
β”‚   β”‚   β”œβ”€β”€ home/             # Protected dashboard
β”‚   β”‚   β”œβ”€β”€ profile/          # User profile
β”‚   β”‚   β”œβ”€β”€ admin/            # Admin dashboard (protected)
β”‚   β”‚   β”œβ”€β”€ prank-wizard/     # Prank planning wizard
β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx      # Multi-step form
β”‚   β”‚   β”‚   └── success/      # Success page with Discord link
β”‚   β”‚   β”œβ”€β”€ pranks/           # Prank management pages
β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx      # List all pranks
β”‚   β”‚   β”‚   └── [id]/         # Individual prank details
β”‚   β”‚   β”œβ”€β”€ forgot-password/  # Password reset request
β”‚   β”‚   β”œβ”€β”€ reset-password/   # Password reset form
β”‚   β”‚   β”œβ”€β”€ auth/             # OAuth callback
β”‚   β”‚   β”œβ”€β”€ favicon.ico       # Brand favicon
β”‚   β”‚   β”œβ”€β”€ sitemap.ts        # Dynamic sitemap
β”‚   β”‚   └── robots.ts         # Robots.txt generator
β”‚   β”œβ”€β”€ components/           # Reusable React components
β”‚   β”‚   β”œβ”€β”€ ui/               # UI components (Button, Input, etc.)
β”‚   β”‚   β”œβ”€β”€ PrankWizard/      # Wizard-specific components
β”‚   β”‚   β”‚   β”œβ”€β”€ ProgressBar.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ MultiSelectPills.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ RadioButtonGroup.tsx
β”‚   β”‚   β”‚   └── Mascot.tsx
β”‚   β”‚   β”œβ”€β”€ Navbar.tsx        # Navigation component
β”‚   β”‚   β”œβ”€β”€ Ballpit.tsx       # Three.js interactive background
β”‚   β”‚   β”œβ”€β”€ ErrorBoundary.tsx # Error boundary component
β”‚   β”‚   β”œβ”€β”€ ToastProvider.tsx # Toast notification system
β”‚   β”‚   β”œβ”€β”€ ProtectedRoute.tsx # Route protection
β”‚   β”‚   └── AdminRoute.tsx    # Admin-only route protection
β”‚   β”œβ”€β”€ contexts/             # React contexts
β”‚   β”‚   └── AuthContext.tsx   # Authentication state management
β”‚   β”œβ”€β”€ lib/                  # Utilities & API clients
β”‚   β”‚   β”œβ”€β”€ api-client.ts    # Base API client
β”‚   β”‚   β”œβ”€β”€ auth-api.ts      # Authentication API
β”‚   β”‚   β”œβ”€β”€ prank-api.ts     # Prank API
β”‚   β”‚   β”œβ”€β”€ admin-api.ts     # Admin API
β”‚   β”‚   β”œβ”€β”€ constants/        # Constants and defaults
β”‚   β”‚   β”‚   β”œβ”€β”€ form.ts      # Form data structure
β”‚   β”‚   β”‚   └── prank.ts     # Prank types and personalities
β”‚   β”‚   └── utils/            # Utility functions
β”‚   └── types/                # TypeScript type definitions
β”‚
β”œβ”€β”€ backend/                  # Express.js backend API
β”‚   └── src/
β”‚       β”œβ”€β”€ index.ts          # Main entry point
β”‚       β”œβ”€β”€ models/           # Mongoose models
β”‚       β”‚   β”œβ”€β”€ User.ts       # User model
β”‚       β”‚   └── Prank.ts      # Prank model
β”‚       β”œβ”€β”€ routes/           # API routes
β”‚       β”‚   β”œβ”€β”€ index.ts     # Route aggregator
β”‚       β”‚   β”œβ”€β”€ auth.ts      # Authentication routes
β”‚       β”‚   β”œβ”€β”€ pranks.ts    # Prank routes
β”‚       β”‚   └── admin.ts     # Admin routes
β”‚       β”œβ”€β”€ services/         # Business logic services
β”‚       β”‚   β”œβ”€β”€ authService.ts
β”‚       β”‚   β”œβ”€β”€ prankService.ts
β”‚       β”‚   β”œβ”€β”€ tokenService.ts
β”‚       β”‚   └── emailService.ts
β”‚       β”œβ”€β”€ middleware/       # Express middleware
β”‚       β”‚   β”œβ”€β”€ auth.ts       # Authentication middleware
β”‚       β”‚   β”œβ”€β”€ admin.ts     # Admin authorization
β”‚       β”‚   β”œβ”€β”€ errorHandler.ts # Error handling
β”‚       β”‚   β”œβ”€β”€ rateLimiter.ts # Rate limiting
β”‚       β”‚   β”œβ”€β”€ sanitize.ts   # Input sanitization
β”‚       β”‚   β”œβ”€β”€ requestId.ts  # Request ID tracking
β”‚       β”‚   β”œβ”€β”€ monitoring.ts # Request monitoring
β”‚       β”‚   └── notFound.ts   # 404 handler
β”‚       β”œβ”€β”€ config/           # Configuration
β”‚       β”‚   β”œβ”€β”€ index.ts     # Environment config
β”‚       β”‚   β”œβ”€β”€ database.ts  # MongoDB connection
β”‚       β”‚   └── passport.ts  # Passport.js setup
β”‚       β”œβ”€β”€ validators/       # Input validation
β”‚       β”‚   β”œβ”€β”€ authValidator.ts
β”‚       β”‚   └── prankValidator.ts
β”‚       β”œβ”€β”€ types/            # TypeScript types
β”‚       β”‚   β”œβ”€β”€ errors.ts
β”‚       β”‚   └── prank.ts
β”‚       └── utils/            # Utilities
β”‚           β”œβ”€β”€ logger.ts
β”‚           └── env-validator.ts
β”‚
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       β”œβ”€β”€ ci.yml           # CI/CD pipeline
β”‚       └── keep-alive.yml   # Backend keep-alive
β”œβ”€β”€ docs/                    # Documentation
β”œβ”€β”€ docker-compose.yml       # Docker Compose configuration
β”œβ”€β”€ Dockerfile              # Multi-stage Docker build
β”œβ”€β”€ netlify.toml            # Netlify deployment config
└── render.yaml             # Render deployment config

πŸ“š Documentation

Authentication Setup

πŸ”Œ API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - User login
  • POST /api/auth/forgot-password - Request password reset
  • POST /api/auth/reset-password - Reset password with token
  • GET /api/auth/me - Get current user (protected)
  • GET /api/auth/google - Google OAuth initiation
  • GET /api/auth/google/callback - Google OAuth callback
  • POST /api/auth/logout - Logout user

Pranks

  • POST /api/pranks - Create new prank plan (protected)
  • GET /api/pranks - Get all user's pranks (protected)
  • GET /api/pranks/:id - Get prank details (protected)

Admin (Protected - Admin Only)

  • GET /api/admin/stats - Get dashboard statistics
  • GET /api/admin/users - Get all users (paginated)
  • GET /api/admin/users/:id - Get user by ID
  • DELETE /api/admin/users/:id - Delete user
  • GET /api/admin/pranks - Get all pranks (paginated)
  • GET /api/admin/pranks/:id - Get prank by ID
  • DELETE /api/admin/pranks/:id - Delete prank

Health

  • GET /health - Health check endpoint (always returns 200)

🎯 Application Flow

  1. Landing Page (/) β†’ Marketing page with hero section and interactive Ballpit background
  2. Sign Up (/signup) β†’ Create new account
  3. Login (/login) β†’ Authenticate user
  4. Home (/home) β†’ Protected dashboard
  5. Prank Wizard (/prank-wizard) β†’ Multi-step prank planning form
    • Step 1: Your Information
    • Step 2: Target's Information (name, age, phone, email, relationship, gender, location)
    • Step 3: Personality & Prank Type
    • Step 4: Additional Details
  6. Success Page (/prank-wizard/success) β†’ Confirmation with Discord invite link
  7. My Pranks (/pranks) β†’ View all prank submissions
  8. Prank Details (/pranks/:id) β†’ View detailed prank information
  9. Profile (/profile) β†’ User profile and settings
  10. Admin Dashboard (/admin) β†’ Admin-only management panel

🐳 Docker Deployment

Using Docker Compose

# Build and start all services
docker-compose up -d

# View logs
docker-compose logs -f

# Stop services
docker-compose down

Individual Services

# Backend only
docker build -t prank-wizard-backend --target backend-prod .
docker run -p 5000:5000 --env-file backend/.env prank-wizard-backend

# Frontend only
docker build -t prank-wizard-frontend --target frontend-prod .
docker run -p 3000:3000 --env-file frontend/.env.local prank-wizard-frontend

☁️ Cloud Deployment

Netlify (Frontend) + Render (Backend)

See DEPLOYMENT_NETLIFY_RENDER.md for complete instructions.

Quick Steps:

  1. Deploy backend to Render (see render.yaml)
  2. Deploy frontend to Netlify (see netlify.toml)
  3. Configure environment variables in both platforms
  4. Set up MongoDB Atlas
  5. Update CORS settings in backend
  6. Configure GitHub Actions secrets for keep-alive workflow

πŸ§ͺ Testing

# Backend tests
cd backend
npm test

# Frontend tests
cd frontend
npm test

# Run all tests
npm test --workspaces

πŸ”§ Development Scripts

Backend

npm run dev          # Start development server with hot reload
npm run build        # Build for production
npm start            # Start production server
npm run lint         # Run ESLint
npm run lint:fix     # Fix linting issues automatically
npm test             # Run tests
npm run type-check   # TypeScript type checking
npm run setup:env    # Generate .env file from template

Frontend

npm run dev          # Start development server
npm run build        # Build for production
npm start            # Start production server
npm run lint         # Run ESLint
npm run lint:fix     # Fix linting issues automatically
npm test             # Run tests
npm run type-check   # TypeScript type checking

πŸ”’ Security Features

  • JWT-based authentication with secure token storage
  • Password hashing with bcrypt (10 rounds)
  • Rate limiting on API endpoints (prevents brute force)
  • Input sanitization (XSS prevention)
  • CORS configuration (production-ready)
  • Security headers (Helmet)
  • XSS protection
  • CSRF protection via SameSite cookies
  • SQL injection prevention (NoSQL injection protection)
  • Environment variable validation
  • Admin role-based access control
  • Request ID tracking for debugging
  • Error message sanitization in production

πŸ“Š Performance Optimizations

  • Next.js Image Optimization
  • Code splitting and lazy loading
  • Font optimization (reduced weights, preload critical fonts)
  • Compression middleware
  • MongoDB connection pooling
  • Caching strategies
  • CDN-ready static assets
  • Deferred loading of non-critical components (Ballpit)
  • Webpack optimizations
  • Package import optimizations (axios, three, gsap)
  • Production source maps disabled for smaller bundles

πŸš€ CI/CD Pipeline

The project includes a comprehensive GitHub Actions workflow:

Automated Checks

  • Linting: ESLint for both frontend and backend
  • Type Checking: TypeScript compilation checks
  • Build Verification: Ensures production builds succeed
  • Security Audit: npm audit for dependency vulnerabilities

Workflows

  • CI Pipeline (.github/workflows/ci.yml): Runs on push/PR to main/develop
  • Keep-Alive (.github/workflows/keep-alive.yml): Pings backend every 14 minutes to prevent free tier spin-down

Environment Variables in CI

  • Backend build requires: MONGODB_URI, JWT_SECRET, FRONTEND_URL, SESSION_SECRET, ADMIN_EMAILS
  • Frontend build requires: NEXT_PUBLIC_API_URL, NEXT_PUBLIC_DISCORD_INVITE_LINK

🎨 Recent Improvements

Mobile Experience

  • Fixed unwanted zoom on input focus
  • Enforced minimum 16px font size for all inputs
  • Disabled user scaling in viewport meta tag
  • Touch-friendly interface

Admin Features

  • Admin dashboard with statistics
  • User management (view, delete)
  • Prank management (view details, delete)
  • Pagination for large datasets
  • Modal for detailed prank information

UI/UX Enhancements

  • Brand favicon in browser tab
  • Discord invite link on success page
  • Form data persistence in local storage
  • Enhanced error messages
  • Improved loading states

Performance

  • Optimized font loading
  • Reduced bundle sizes
  • Improved Lighthouse scores
  • Better code splitting

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

MIT License - see LICENSE file for details.

πŸ™ Acknowledgments

  • Next.js team for the amazing framework
  • Express.js for the robust backend framework
  • MongoDB for the flexible database
  • All open-source contributors

πŸ“ž Support

For issues, questions, or contributions, please open an issue on GitHub.


Built with ❀️ using Next.js, Express.js, and TypeScript

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors