How akashyap2013/mern_login_app_with_resetemail works
Project type and purpose
• This is a full-stack MERN (MongoDB, Express, React, Node.js) application that implements user authentication flows: register, login, profile viewing, password recovery and reset.
• The client (“client/”) is a React single-page app; the server (“server/”) is a Node.js/Express REST API. It uses MongoDB Atlas for persistent storage and Nodemailer (via an Ethereal test account) to send reset emails.
File structure
• client/
• public/: static HTML + manifest
• src/: React components, hooks, middleware, helper functions, and global state store (Redux-like)
• middleware/auth.js: client-side route protection
• hooks/fetch.hook.js: custom fetch wrapper for API calls
• server/
• controllers/: business logic (appController.js, mailer.js)
• model/User.model.js: Mongoose schema for users
• database/conn.js: MongoDB connection setup
• router/route.js: Express routes for auth flows
• middleware/auth.js: JWT validation for protected routes
• server.js: express app bootstrap
• Config files: .env on client, config.js on server
README for additional insights
• Describes environment variables and usage.
• Emphasizes use of JWT_SECRET, MongoDB Atlas, and Ethereal email credentials.
Detailed breakdown
• Middleware chains on both sides (client auth middleware, server JWT middleware)
• API endpoints (e.g., POST /register, POST /login, GET /profile, POST /reset)
• Data flows (credentials, JWT tokens, password reset tokens)
• Error flows (e.g., 401 → redirect to login)