Skip to content

codebydurvesh/mystery-message

Repository files navigation

πŸ•΅οΈ Mystery Message

πŸ”— Live Demo: mystery-message-roby.vercel.app

πŸ“£ LinkedIn Post: mystery-message-linkedin-post

πŸ“¬ Send Me a Feedback here: mystery-message-roby.vercel.app/u/codebydurvesh


πŸ“– Overview

Mystery Message is a full-stack anonymous feedback platform built with Next.js. Users sign up, get a unique shareable profile link, and anyone β€” logged in or not β€” can send them anonymous messages through that link. The receiver can manage which messages they accept, view all received messages, and delete individual ones β€” all without senders ever revealing who they are.


✨ Features

πŸ” Authentication & Verification

  • Sign Up with a unique username, email, and password
  • Real-time username availability check (debounced) as you type
  • Email OTP verification via Resend β€” a 6-digit code is sent to your inbox after sign-up
  • Sign In with credentials through NextAuth.js
  • Protected routes β€” unauthenticated users are redirected to /signin; unverified users are redirected to /verify/:username

πŸ“¬ Anonymous Messaging

  • Every user gets a unique public profile URL: /u/<username>
  • Anyone (no account required) can visit this URL and send an anonymous message
  • Messages are limited to 300 characters with a live character counter
  • The sender's identity is never stored or revealed

πŸ€– AI-Suggested Questions

  • On the send-message page, users can fetch AI-suggested question prompts to inspire their anonymous messages
  • Three random question suggestions are served from a curated dataset via /api/suggest-messages

πŸ—‚οΈ Dashboard

  • View all received messages in a responsive card grid (1 / 2 / 3 columns)
  • Delete individual messages with a single click (with instant UI update)
  • Copy your unique profile link to clipboard with one click
  • Toggle message acceptance β€” turn off incoming messages with a toggle switch; senders are notified the user is not accepting messages
  • Unverified users see a prompt to verify their account before they can toggle message acceptance

🎨 UI & UX

  • Built with shadcn/ui components (Card, Button, Switch, Separator, Form, Input, etc.)
  • Dark / light mode support via next-themes
  • Animated carousel on the homepage showcasing sample anonymous messages (auto-plays every 2 seconds)
  • Subtle conic-gradient animated button on the landing page
  • Toast notifications (via Sonner) for all success and error events
  • Fully responsive layout β€” mobile-first design

πŸ”„ Application Workflow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        NEW USER FLOW                            β”‚
β”‚                                                                 β”‚
β”‚  1. Visit /signup                                               β”‚
β”‚     └─ Enter username (real-time uniqueness check), email,     β”‚
β”‚        and password β†’ Submit                                    β”‚
β”‚                                                                 β”‚
β”‚  2. Account created (unverified) β†’ Redirected to /verify/:user β”‚
β”‚     └─ OTP email sent via Resend                               β”‚
β”‚                                                                 β”‚
β”‚  3. Enter 6-digit OTP on /verify/:username                     β”‚
β”‚     └─ Account marked as verified β†’ Redirected to /dashboard   β”‚
β”‚                                                                 β”‚
β”‚  4. Dashboard loads:                                            β”‚
β”‚     β”œβ”€ Profile link displayed & copyable                        β”‚
β”‚     β”œβ”€ Accept Messages toggle (ON by default)                  β”‚
β”‚     └─ Message grid (empty for a new user)                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      SENDER FLOW                                β”‚
β”‚                                                                 β”‚
β”‚  1. Receive a shared link β†’ /u/<username>                       β”‚
β”‚                                                                 β”‚
β”‚  2. Type an anonymous message (up to 300 chars)                β”‚
β”‚     └─ Optionally click "Suggest" for AI-generated prompts     β”‚
β”‚                                                                 β”‚
β”‚  3. Hit "Send Message"                                          β”‚
β”‚     β”œβ”€ If user is accepting β†’ message saved, success toast     β”‚
β”‚     └─ If user is not accepting β†’ error shown to sender        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    RETURNING USER FLOW                          β”‚
β”‚                                                                 β”‚
β”‚  1. Visit /signin β†’ Enter credentials β†’ Redirected to /dashboardβ”‚
β”‚                                                                 β”‚
β”‚  2. Dashboard shows all received messages                       β”‚
β”‚     β”œβ”€ Click "Copy" to copy profile URL                        β”‚
β”‚     β”œβ”€ Toggle acceptance on/off                                β”‚
β”‚     └─ Delete any message                                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Layer Technology
Framework Next.js 15 (App Router)
Language TypeScript
Database MongoDB via Mongoose
Auth NextAuth.js v4 (Credentials provider)
Email Resend + React Email
UI Components shadcn/ui + Radix UI
Styling Tailwind CSS v4
Forms React Hook Form + Zod
Carousel Embla Carousel with Autoplay
HTTP Client Axios
Toasts Sonner
Password Hashing bcryptjs
Deployment Vercel

πŸ“ Project Structure

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ (app)/
β”‚   β”‚   β”œβ”€β”€ page.tsx              # Landing page with carousel
β”‚   β”‚   β”œβ”€β”€ layout.tsx            # App layout with Navbar
β”‚   β”‚   β”œβ”€β”€ dashboard/page.tsx    # User dashboard
β”‚   β”‚   └── u/[username]/page.tsx # Public send-message page
β”‚   β”œβ”€β”€ (auth)/
β”‚   β”‚   β”œβ”€β”€ signin/page.tsx       # Sign in form
β”‚   β”‚   β”œβ”€β”€ signup/page.tsx       # Sign up form
β”‚   β”‚   └── verify/[username]/page.tsx # OTP verification
β”‚   └── api/
β”‚       β”œβ”€β”€ auth/[...nextauth]/   # NextAuth route handler
β”‚       β”œβ”€β”€ signup/               # Register new user + send OTP
β”‚       β”œβ”€β”€ verify-code/          # Validate OTP
β”‚       β”œβ”€β”€ chech-username-unique/# Check username availability
β”‚       β”œβ”€β”€ accept-messages/      # GET/POST toggle acceptance
β”‚       β”œβ”€β”€ send-message/         # Send anonymous message
β”‚       β”œβ”€β”€ get-messages/         # Fetch all messages for user
β”‚       β”œβ”€β”€ delete-message/       # Delete a specific message
β”‚       └── suggest-messages/     # Return random question prompts
β”œβ”€β”€ model/
β”‚   └── User.ts                   # Mongoose User + Message schema
β”œβ”€β”€ schemas/                      # Zod validation schemas
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ Navbar.tsx
β”‚   β”œβ”€β”€ MessageCard.tsx
β”‚   └── ui/                       # shadcn/ui components
β”œβ”€β”€ emails/
β”‚   └── VerificationEmail.tsx     # React Email OTP template
β”œβ”€β”€ helpers/                      # sendVerificationEmail helper
β”œβ”€β”€ lib/                          # dbConnect, auth options
β”œβ”€β”€ data/                         # Sample messages & question sets
β”œβ”€β”€ types/                        # ApiResponse type
└── middleware.ts                 # Route protection logic

πŸš€ Getting Started Locally

Prerequisites

  • Node.js 18+
  • A MongoDB database (Atlas free tier works)
  • A Resend account and API key

1. Clone the repository

git clone https://github.com/codebydurvesh/mystery-message.git
cd mystery-message

2. Install dependencies

npm install

3. Configure environment variables

Copy .env.example to .env and fill in your values:

cp .env.example .env
MONGO_URI=your_mongodb_connection_string
RESEND_API_KEY=your_resend_api_key
NEXT_AUTH_SECRET=a_long_random_secret_string

4. Run the development server

npm run dev

Open http://localhost:3000 in your browser.


🌐 API Reference

Method Endpoint Auth Required Description
POST /api/signup ❌ Register a new user; sends OTP email
POST /api/verify-code ❌ Verify OTP and activate account
GET /api/chech-username-unique ❌ Check if a username is available
GET /api/accept-messages βœ… Get current accept-messages setting
POST /api/accept-messages βœ… Toggle accept-messages on/off
POST /api/send-message ❌ Send an anonymous message to a user
GET /api/get-messages βœ… Retrieve all messages for the signed-in user
DELETE /api/delete-message/:id βœ… Delete a specific message by ID
GET /api/suggest-messages ❌ Get 3 random AI-style question suggestions

πŸ”’ Security Highlights

  • Passwords are hashed with bcryptjs before storage β€” plain-text passwords are never saved
  • OTP codes are time-limited (stored with an expiry date)
  • Route-level protection is enforced in middleware.ts β€” unauthenticated and unverified users are automatically redirected
  • Session tokens are signed using NEXT_AUTH_SECRET

πŸ“„ License

This project is open-source and available under the MIT License.


Made by Durvesh

Releases

No releases published

Packages

 
 
 

Contributors

Languages