A Next.js application with MongoDB authentication for AI-powered scam detection and cybersecurity protection.
- User Authentication: Complete signup/login system with MongoDB
- AI Scam Analysis: Google Gemini AI integration for content analysis
- User Dashboard: Personalized dashboard with analysis history
- Cybercrime Reporting: Secure reporting system for cybercrime incidents
- Profile Management: User profile with statistics and settings
- Frontend: Next.js 14, React 18, TypeScript
- Database: MongoDB with Mongoose
- Authentication: JWT tokens with HTTP-only cookies
- AI: Google Generative AI (Gemini 2.0)
- Styling: Tailwind CSS + Custom CSS
- UI Components: Radix UI (shadcn/ui)
- Node.js 18+ installed
- MongoDB database (local or MongoDB Atlas)
- Google AI API key
-
Clone the repository
git clone <your-repo-url> cd SIH-Cyber-project
-
Install dependencies
npm install
-
Environment Variables Create a
.env.localfile in the root directory:# MongoDB Connection MONGODB_URI=mongodb://localhost:27017/ai-scam-shield # For MongoDB Atlas: mongodb+srv://username:[email protected]/ai-scam-shield # JWT Secret (Generate a strong secret key) JWT_SECRET=your-super-secret-jwt-key-here-make-it-long-and-random # Google AI API Key GOOGLE_API_KEY=your-google-api-key-here # Environment NODE_ENV=development
-
MongoDB Setup
Option A: Local MongoDB
- Install MongoDB locally
- Start MongoDB service
- Use:
MONGODB_URI=mongodb://localhost:27017/ai-scam-shield
Option B: MongoDB Atlas (Recommended)
- Create account at MongoDB Atlas
- Create a new cluster
- Get connection string and replace in
.env.local - Whitelist your IP address
-
Google AI API Key
- Go to Google AI Studio
- Create a new API key
- Add it to your
.env.localfile
-
Run the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000
- New Users: Visit
/auth→ Sign Up → Automatic login - Existing Users: Visit
/auth→ Sign In - Protected Routes: All main pages require authentication
- Logout: Click logout button in header
├── app/
│ ├── api/auth/ # Authentication API routes
│ ├── auth/ # Login/Signup page
│ ├── calculator/ # AI analysis tool
│ ├── profile/ # User profile & settings
│ ├── report/ # Cybercrime reporting
│ └── page.tsx # Dashboard/Home
├── components/ui/ # Reusable UI components
├── hooks/ # Custom React hooks
├── lib/ # Utility functions
├── models/ # MongoDB models
└── types/ # TypeScript types
- Password Hashing: bcryptjs with salt rounds
- JWT Tokens: Secure authentication with HTTP-only cookies
- Input Validation: Server-side validation for all inputs
- Protected Routes: Authentication required for all main features
- Environment Variables: Sensitive data stored securely
- Sign Up/Login: Create account or login at
/auth - Dashboard: View scam alerts and navigate features
- Analyze Content: Use
/calculatorto check suspicious emails/messages - View Profile: Check your statistics and analysis history at
/profile - Report Scams: Submit cybercrime reports at
/report
- Minimum 6 characters
- At least 1 uppercase letter
- At least 1 lowercase letter
- At least 1 number
POST /api/auth/register- User registrationPOST /api/auth/login- User loginPOST /api/auth/logout- User logoutGET /api/auth/me- Get current userPOST /api/analyze- AI content analysis
MongoDB Connection Issues:
- Check your MongoDB URI in
.env.local - Ensure MongoDB service is running (local)
- Check network access in MongoDB Atlas
Authentication Issues:
- Clear browser cookies
- Check JWT_SECRET in environment variables
- Verify API endpoints are working
AI Analysis Issues:
- Verify Google API key is valid
- Check API quota limits
- Ensure content is not too long (10k chars max)
- User data is automatically populated in forms
- Real-time authentication state management
- Responsive design for all screen sizes
- Error handling with user-friendly messages
- Loading states for better UX
- Environment Variables: Set all required env vars in production
- Database: Use MongoDB Atlas for production
- Security: Ensure HTTPS in production for secure cookies
- Build: Run
npm run buildbefore deployment
This project is part of Smart India Hackathon (SIH) cybersecurity initiative.