An open API service indexing awesome lists of open source software.

https://github.com/ilkaytech/advanced-mern-auth


https://github.com/ilkaytech/advanced-mern-auth

2fa-security jwt-token mongodb-database nextjs nodejs rate-limiting redis-cache shadcn-ui tailwind-css typescript zod

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

          

# Advanced Authentication System with Node.js, TypeScript, 2FA, JWT, Sessions & Next.js

A full-stack, secure authentication boilerplate built using **Node.js**, **Express**, **TypeScript**, and **Next.js**. It includes modern auth features like **email verification**, **2FA**, **access & refresh tokens**, **cookie-based sessions**, and more — all production-ready.

---

## Key Features

### Backend (Node.js + Express + TypeScript)

- **Modular Architecture** — Clean, scalable folder structure
- **MongoDB (Mongoose)** for schema modeling
- **User Registration & Login**
- **Email Verification with Resend**
- **Password Reset via Email**
- **Access & Refresh Tokens (JWT)**
- **Secure Cookies for Session Management**
- **Two-Factor Authentication (2FA)** using `speakeasy` and `qrcode`
- **Passport.js with JWT strategy**
- **Rate Limiting** middleware for brute-force protection
- **Environment-based Config with dotenv**
- **Validation with Zod**

---

### Frontend (Next.js + TypeScript + Tailwind CSS)

- **Reusable Auth Forms** (Sign up / Login)
- **Email Confirmation Page**
- **Protected Routes with Middleware**
- **User Dashboard with Session Info**
- **2FA Setup & Verification Flow**
- **Active Session Tracking & Management**
- **Logout with Secure Session Termination**
- **Light & Dark Mode UI**

---

## Getting Started

### Backend

```bash
cd backend
npm install
npm run dev
```

> Create a `.env` file and set up Mongo URI, JWT secrets, Resend API key, etc.

### Frontend

```bash
cd frontend
npm install
npm run dev
```

---

## 📌 Tech Stack

- **Backend**: Node.js, Express, MongoDB, TypeScript, Passport, JWT
- **Frontend**: Next.js, React, Tailwind CSS
- **Security**: Bcrypt, JWT, 2FA, Cookie-based auth, Rate limiting
- **Utilities**: Zod, Resend, dotenv, qrcode

---

## API Documentation

**Swagger**

- 🔗 [View Swagger UI](http://api-docs)
- 🔗 [Download Swagger JSON](http://api-docs-json)

You can import the JSON file into tools like **Postman**


Swagger UI Screenshot

---

Application Screenshots

Sign In Sign Up Check Email Confirm Email Account Confirmation 2FA Setup Session List Dashboard Reset Password Logout Dark Mode