A full-stack authentication system built with React (frontend) and Node.js/Express (backend) with MongoDB database.
- 🔐 Secure Authentication: JWT-based authentication with password hashing
- 👤 User Management: Registration, login, profile management
- 🔑 Password Reset: Email-based password reset functionality
- 🛡️ Security: Rate limiting, CORS protection, helmet security headers
- 📱 Responsive Design: Mobile-first responsive UI
- ⚡ Modern Stack: React 18, Vite, Express.js, MongoDB
- React 18 - Modern React with hooks
- Vite - Fast build tool and dev server
- CSS3 - Modern styling with gradients and animations
- Context API - State management for authentication
- Node.js - JavaScript runtime
- Express.js - Web framework
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling
- JWT - JSON Web Tokens for authentication
- bcryptjs - Password hashing
- Helmet - Security middleware
- CORS - Cross-origin resource sharing
SPOT-Q/
├── backend/
│ ├── config/
│ │ └── database.js # Database configuration
│ ├── middleware/
│ │ └── auth.js # Authentication middleware
│ ├── models/
│ │ └── user.js # User model and schema
│ ├── routes/
│ │ └── auth.js # Authentication routes
│ ├── .env # Environment variables
│ ├── .env.example # Environment template
│ ├── package.json # Backend dependencies
│ └── server.js # Main server file
├── frontend/
│ ├── src/
│ │ ├── Components/
│ │ │ └── Dashboard.jsx # Dashboard component
│ │ ├── context/
│ │ │ └── AuthContext.jsx # Authentication context
│ │ ├── pages/
│ │ │ └── Login.jsx # Login/Register page
│ │ └── styles/
│ │ └── PageStyles/
│ │ └── Login.css # Login page styles
│ ├── .env # Frontend environment variables
│ ├── .env.example # Frontend environment template
│ ├── index.html # HTML template
│ ├── main.jsx # React entry point
│ ├── app.jsx # Main app component
│ ├── app.css # Global styles
│ ├── package.json # Frontend dependencies
│ └── vite.config.js # Vite configuration
└── README.md # This file
- Node.js (v14 or higher)
- MongoDB (local or cloud)
- npm or yarn
-
Clone the repository
git clone <repository-url> cd SPOT-Q
-
Setup Backend
cd backend npm install cp .env.example .env # Edit .env with your configuration
-
Setup Frontend
cd ../frontend npm install cp .env.example .env # Edit .env with your configuration
-
Start MongoDB
# If using local MongoDB mongod -
Run the Application
Terminal 1 - Backend:
cd backend npm run devTerminal 2 - Frontend:
cd frontend npm run dev -
Access the Application
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
NODE_ENV=development
PORT=5000
MONGODB_URI=mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/loginapp?retryWrites=true&w=majority
JWT_SECRET=replace-with-a-long-random-string
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-password
FRONTEND_URL=http://localhost:3000Important: In production the server will refuse to start if
JWT_SECRETis not set. Use a strong value (at least 32 random bytes). On Windows PowerShell you can generate one like this:
[Convert]::ToBase64String((New-Object System.Security.Cryptography.RNGCryptoServiceProvider).GetBytes(32))On macOS/Linux:
openssl rand -base64 32Then set it in your environment (examples):
$env:JWT_SECRET="<paste-generated-secret>"; $env:NODE_ENV="production"; node server.jsexport JWT_SECRET="<paste-generated-secret>" NODE_ENV=production && node server.jsVITE_API_URL=http://localhost:5000/api
VITE_APP_NAME=Secure Login System
VITE_APP_VERSION=1.0.0POST /api/auth/register- User registrationPOST /api/auth/login- User loginPOST /api/auth/forgot-password- Request password resetPOST /api/auth/reset-password- Reset password with tokenGET /api/auth/verify- Verify JWT tokenGET /api/auth/profile- Get user profilePUT /api/auth/profile- Update user profile
- Password Hashing: bcrypt with salt rounds
- JWT Tokens: Secure token-based authentication
- Rate Limiting: Prevents brute force attacks
- CORS Protection: Configurable cross-origin policies
- Helmet: Security headers
- Input Validation: Server-side validation
- Account Lockout: Temporary lockout after failed attempts
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request