Readme.md
Admin Dashboard with Authentication & Product Management
A full-stack admin dashboard built using Node.js, Express, MongoDB, and React, supporting:
- User registration and login
- Forgot and reset password via email
- Product management (CRUD)
- Frontend admin UI with product image, price, and quantity controls
Project Structure
.
├── backend/
│ ├── app.js
│ ├── .env
│ ├── models/
│ │ └── Product.js
│ ├── controllers/
│ │ └── authController.js
│ ├── routes/
│ │ ├── authRoutes.js
│ │ └── productRoutes.js
│ ├── utils/
│ │ └── emailUtils.js
│ └── ...
├── frontend/
│ ├── src/
│ │ ├── App.js
│ │ └── components/
│ │ └── AdminDashboard.js
│ └── ...
# Backend Setup
Prerequisites
Node.js
MongoDB
Gmail account (for sending reset emails)
1. Clone & Install
bash
Copy
Edit
cd backend
npm install
2. Configure .env
Create a .env file in the backend directory:
env
Copy
Edit
PORT=5000
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USER=[email protected]
MAIL_PASS=your-app-password
JWT_SECRET=your-jwt-secret
JWT_EXPIRY=15m
# Use an App Password if you're using Gmail with 2FA.
3. Start MongoDB
bash
Copy
Edit
mongod
4. Run the Server
bash
Copy
Edit
node app.js
# Frontend Setup
1. Navigate to Frontend
bash
Copy
Edit
cd frontend
npm install
2. Start React App
bash
Copy
Edit
npm start
Authentication Routes (API)
POST /api/auth/register – Register a new user
POST /api/auth/login – Login with email and password
POST /api/auth/forgot-password – Sends password reset email
POST /api/auth/reset-password – Resets password using token
Product Routes (API)
POST /save – Create or update a product
GET /all – Get all products
GET /seed – Seed dummy products
PUT /products/:id – Update price and quantity
# Seed Sample Products
Visit:
bash
Copy
Edit
http://localhost:5000/seed
# Admin Dashboard UI
Built with React
Displays all products with:
Image
Name
Editable Price & Quantity
Admin can update values directly from UI
# Security & Improvements
In production, replace the in-memory user store with a database
Store hashed passwords (e.g., bcrypt)
Use HTTPS and input validation
Modularize API further using middleware and services