Authora is a full-featured e-commerce web application built with the MERN stack (MongoDB, Express, React, Node.js). It includes secure authentication with JWT and 2FA (OTP via Gmail SMTP), user profile management, and integrated payments via Razorpay.
- User registration and login with JWT authentication
- Two-factor authentication (2FA) using OTP sent via email (Gmail SMTP)
- Resend OTP and Forgot Password flows
- User profile management
- Product browsing, cart, and checkout
- Secure payments via Razorpay
- Modern, responsive UI with React and Material-UI
Authora/
├── backend/
│ ├── config/ # Configuration files (e.g., email setup)
│ ├── controllers/ # Express route controllers (business logic)
│ ├── middleware/ # Custom Express middleware (e.g., auth)
│ ├── models/ # Mongoose models (MongoDB schemas)
│ ├── routes/ # Express route definitions
│ ├── server.js # Entry point for backend server
│ ├── package.json # Backend dependencies and scripts
│ └── ...
├── frontend/
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ ├── context/ # React context providers
│ │ ├── features/ # Feature modules (e.g., authentication)
│ │ ├── layouts/ # Layout components
│ │ ├── pages/ # Main application pages (Home, Login, Register, etc.)
│ │ ├── routes/ # Route definitions
│ │ ├── services/ # API service functions
│ │ ├── utils/ # Utility functions
│ │ ├── App.jsx # Main app component
│ │ └── main.jsx # Entry point for React
│ ├── public/ # Static assets
│ ├── package.json # Frontend dependencies and scripts
│ └── ...
├── README.md # Project documentation
└── ...
- Express.js server with RESTful API endpoints
- MongoDB Atlas for cloud database
- Mongoose for schema modeling
- JWT for authentication
- Nodemailer (Gmail SMTP) for sending OTPs
- Joi for input validation
- Razorpay integration for payments
server.js: Main server entry point, connects to MongoDB, sets up middleware and routesroutes/userRoutes.js: User-related API endpoints (register, login, profile, OTP, etc.)controllers/userController.js: Business logic for user actionsmodels/userModel.js: User schema (with password hashing, OTP fields, etc.)middleware/authMiddleware.js: JWT authentication middlewareconfig/email.js: Nodemailer configuration for Gmail SMTP
- React with functional components and hooks
- React Router for navigation
- Material-UI for UI components
- Axios for API requests
- Formik/Yup for form handling and validation
- React Toastify for notifications
- Razorpay for payment integration
src/pages/: Main views (Home, Login, Register, Profile, Cart, Checkout, etc.)src/features/authentication/: All authentication logic (forms, OTP, hooks, services)src/components/: Reusable UI components (ProductCard, CartItem, etc.)src/services/: API service functions
- Node.js (v16+ recommended)
- MongoDB Atlas account
- Gmail account for SMTP (for OTP)
- Razorpay account (for payments)
cd backend- Install dependencies:
npm install - Create a
.envfile with:MONGODB_URI=your_mongodb_connection_stringJWT_SECRET=your_jwt_secretEMAIL_USER=your_gmail_addressEMAIL_PASS=your_gmail_app_passwordRAZORPAY_KEY_ID=your_razorpay_key_idRAZORPAY_KEY_SECRET=your_razorpay_key_secret
- Start server:
npm run dev
cd frontend- Install dependencies:
npm install - Start dev server:
npm run dev
POST /api/users/register— Register user (with OTP)POST /api/users/login— Login (with OTP)POST /api/users/verify-otp— Verify OTPPOST /api/users/resend-otp— Resend OTPPOST /api/users/forgot-password— Forgot password (send OTP)GET /api/users/profile— Get user profile (auth required)
MIT