How rupeshbisen/next-js-authentication works
Project Type and Purpose
• This is a full-stack Next.js application.
• It provides user registration, login, and forgot-password flows via both React UI pages (under src/app) and serverless API routes (under src/app/api).
• It uses a database (models and src/database) to persist users and OTPs, plus middleware for authentication.
File Structure
Top-level:
• next.config.js, tsconfig.json, Tailwind config → build/system config
• public/ → static assets
• src/app/ → frontend pages & API routes, using Next.js App Router
• src/components/ → shared React components (Navbar, Input, Loader, Notification)
• src/context/ → React Context for global state (e.g. auth)
• src/database/ → DB connection setup
• src/middleware/ → Next.js edge middleware for AuthUser
• src/models/ → data schemas (user.model, otp.model)
• src/service/ → service-layer logic for register, login, forgot-password
• src/types/ → TypeScript interfaces for request/response payloads
• src/utils/ → helper functions
README for Additional Insights
• Bootstrapped with create-next-app.
• Uses next/font, Tailwind CSS.
• Standard dev and deployment instructions (npm run dev, vercel).
Detail and Thoroughness
• Every distinct part of the stack (pages, layout, components, services, models, middleware, utils).
• How context providers (src/context) feed into the UI for auth state.
• Configuration files (next.config.js, tailwind.config.ts) only if the deployment/configuration layer is in scope.