Skip to content

satyam-software-developer/FeedbackAI-Nextjs

Repository files navigation

True Feedback (Mstrymessage)

A full-stack anonymous feedback messaging platform built with Next.js, TypeScript, MongoDB, NextAuth, OpenAI, and Resend.

Users can create accounts, share their public profile links, receive anonymous messages, manage messages, and use AI-powered suggestions to generate conversation starters.


🌐 Live Demo

Live Application: https://feedback-ai-nextjs-ruby.vercel.app/


πŸš€ Features

Authentication

  • User registration
  • Email verification using OTP
  • Secure password hashing with bcrypt
  • Login using username or email
  • JWT-based authentication with NextAuth

Anonymous Messaging

  • Generate a public profile link
  • Receive anonymous messages
  • View received messages
  • Delete messages
  • Control whether users can send messages

AI Features

  • AI-generated anonymous question suggestions
  • Powered by OpenAI API

Email System

  • Verification emails
  • OTP-based account verification
  • Resend email service integration

UI Features

  • Responsive design
  • Tailwind CSS styling
  • Shadcn UI components
  • Toast notifications
  • Form validation

πŸ›  Tech Stack

Frontend

  • Next.js 16
  • React 19
  • TypeScript
  • Tailwind CSS
  • Shadcn UI
  • React Hook Form
  • Zod Validation
  • Axios

Backend

  • Next.js App Router API Routes
  • MongoDB
  • Mongoose
  • NextAuth.js
  • bcryptjs

Services

  • OpenAI API
  • Resend Email API

πŸ“‚ Project Structure

mstrymessage
β”‚
β”œβ”€β”€ src
β”‚   β”‚
β”‚   β”œβ”€β”€ app
β”‚   β”‚   β”œβ”€β”€ api
β”‚   β”‚   β”‚   β”œβ”€β”€ auth
β”‚   β”‚   β”‚   β”œβ”€β”€ register
β”‚   β”‚   β”‚   β”œβ”€β”€ verify-code
β”‚   β”‚   β”‚   β”œβ”€β”€ send-message
β”‚   β”‚   β”‚   β”œβ”€β”€ delete-message
β”‚   β”‚   β”‚   β”œβ”€β”€ get-messages
β”‚   β”‚   β”‚   β”œβ”€β”€ accept-messages
β”‚   β”‚   β”‚   └── suggest-messages
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ dashboard
β”‚   β”‚   β”œβ”€β”€ sign-in
β”‚   β”‚   β”œβ”€β”€ sign-up
β”‚   β”‚   └── verify
β”‚   β”‚
β”‚   β”œβ”€β”€ components
β”‚   β”‚   β”œβ”€β”€ ui
β”‚   β”‚   β”œβ”€β”€ Navbar.tsx
β”‚   β”‚   └── MessageCard.tsx
β”‚   β”‚
β”‚   β”œβ”€β”€ context
β”‚   β”‚   └── AuthProvider.tsx
β”‚   β”‚
β”‚   β”œβ”€β”€ helpers
β”‚   β”‚   └── sendVerificationEmail.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ lib
β”‚   β”‚   β”œβ”€β”€ dbConnect.ts
β”‚   β”‚   └── resend.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ model
β”‚   β”‚   └── User.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ schemas
β”‚   β”‚   β”œβ”€β”€ signUpSchema.ts
β”‚   β”‚   β”œβ”€β”€ signInSchema.ts
β”‚   β”‚   β”œβ”€β”€ messageSchema.ts
β”‚   β”‚   └── verifySchema.ts
β”‚   β”‚
β”‚   └── types
β”‚       └── ApiResponse.ts
β”‚
β”œβ”€β”€ .env.local
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── README.md

βš™οΈ Installation

Clone the repository:

git clone <your-repository-url>

Move into project folder:

cd mstrymessage

Install dependencies:

npm install

πŸ” Environment Variables

Create a file:

.env.local

Add:

NEXTAUTH_URL=http://localhost:3000

MONGODB_URI=your_mongodb_connection_string

NEXTAUTH_SECRET=your_nextauth_secret

RESEND_API_KEY=your_resend_api_key

OPENAI_API_KEY=your_openai_api_key

πŸ—„ Database Setup

This project uses MongoDB.

You can use:

  • MongoDB Local
  • MongoDB Atlas

Example local connection:

MONGODB_URI=mongodb://localhost:27017/mstrymessage

The application automatically creates the required collections.


▢️ Run Development Server

Start development:

npm run dev

Open:

http://localhost:3000

πŸ— Production Build

Create production build:

npm run build

Start production server:

npm start

πŸ”‘ Authentication Flow

Registration

  1. User enters:

    • Username
    • Email
    • Password
  2. Password is hashed using bcrypt.

  3. Verification OTP is generated.

  4. OTP is sent using Resend.


Verification

User enters OTP.

The server checks:

  • Verification code
  • Expiry time

After successful verification:

isVerified = true

Login

Users can login using:

  • Username
  • Email

NextAuth creates a JWT session.


πŸ“‘ API Routes

Authentication

Register

POST /api/register

Creates a new user.


Verify Account

POST /api/verify-code

Verifies OTP.


Login

POST /api/auth/[...nextauth]

Handles authentication.


Messages

Send Anonymous Message

POST /api/send-message

Body:

{
  "username": "example",
  "content": "Your message"
}

Get Messages

GET /api/get-messages

Returns authenticated user's messages.


Delete Message

DELETE /api/delete-message/:messageid

Deletes a message.


Toggle Message Acceptance

POST /api/accept-messages

Updates whether the user accepts messages.


AI Suggestions

POST /api/suggest-messages

Generates anonymous question suggestions using OpenAI.


🧠 AI Message Suggestions

The application uses:

OpenAI Responses API

to generate:

  • Friendly questions
  • Anonymous conversation starters
  • Feedback prompts

πŸ“§ Email Verification

Email service:

Resend

Features:

  • OTP generation
  • Verification emails
  • Account activation

πŸ”’ Security Features

Implemented:

  • Password hashing
  • JWT authentication
  • Protected API routes
  • Input validation using Zod
  • MongoDB validation
  • Environment variables

Recommended before production:

  • Add API rate limiting
  • Add CAPTCHA for signup
  • Rotate exposed API keys
  • Enable HTTPS

πŸš€ Deployment

Recommended platforms:

  • Vercel (Frontend + API)
  • MongoDB Atlas (Database)
  • Resend (Email)

Before deployment:

Update:

NEXTAUTH_URL=https://your-domain.com

πŸ“Œ Future Improvements

Possible upgrades:

  • Real-time messaging
  • User profile customization
  • Message reactions
  • Image attachments
  • Admin dashboard
  • Analytics
  • Push notifications

πŸ‘¨β€πŸ’» Author

Satyam Kumar


πŸ“„ License

This project is licensed under the MIT License.

About

A full-stack anonymous feedback messaging platform built with Next.js, TypeScript, MongoDB, NextAuth, OpenAI, and Resend. Users can create profiles, receive anonymous messages, manage feedback, and generate AI-powered message suggestions.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages