Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” SecureAuthentication

A modern, secure, and full-stack authentication system built using the MERN-inspired stack with React, Node.js, Express.js, Prisma ORM, PostgreSQL, JWT Authentication, and Resend Email API.

This project demonstrates a production-ready authentication workflow including User Registration, Login, Email Verification, Forgot Password, Password Reset, Protected Routes, User Profile Management, and JWT-based Authentication.


πŸ“· Screenshots

πŸ”‘ Login Page

Login

πŸ“ Register Page

Register

πŸ“§ Forgot Password

Forgot Password

πŸ”’ Reset Password

Reset Password

βœ… Verify Email

Verify Email


πŸ“Š Dashboard

Dashboard

πŸš€ Features

πŸ”‘ Authentication

  • User Registration
  • User Login
  • Secure Logout
  • JWT Authentication
  • Protected Routes
  • Public Routes
  • Persistent Login using Context API
  • Authentication Middleware

πŸ“§ Email Verification

  • Email Verification using Resend API
  • Secure Verification Token
  • 24-hour Token Expiry
  • Verification Link Validation
  • Prevent Login Until Email Verification
  • Automatic Token Removal After Verification

πŸ”’ Password Recovery

  • Forgot Password
  • Secure Password Reset Link
  • 1-hour Expiry Token
  • Password Reset Page
  • Confirm Password Validation
  • Secure Password Hashing using bcrypt

πŸ‘€ User Profile

  • Get Current User
  • Update User Profile
  • Duplicate Email Validation
  • JWT Protected APIs

🎨 Frontend

  • Modern Responsive UI
  • Professional Authentication Pages
  • React Context API
  • React Router DOM
  • Axios API Integration
  • Responsive Dashboard
  • Clean Form Validation
  • Loading States

πŸ›‘ Security

  • Password Hashing (bcryptjs)
  • JWT Authentication
  • Protected Backend Routes
  • Authentication Middleware
  • Email Verification
  • Reset Token Expiry
  • Token Cleanup After Use
  • Secure API Validation

πŸ›  Tech Stack

Frontend

  • React.js
  • Vite
  • React Router DOM
  • Context API
  • Axios
  • CSS3

Backend

  • Node.js
  • Express.js
  • Prisma ORM
  • PostgreSQL
  • JWT
  • bcryptjs
  • Crypto

Email Service

  • Resend API

πŸ“‚ Project Structure

SecureAuthentication
β”‚
β”œβ”€β”€ client
β”‚   β”œβ”€β”€ src
β”‚   β”‚   β”œβ”€β”€ assets
β”‚   β”‚   β”œβ”€β”€ components
β”‚   β”‚   β”œβ”€β”€ context
β”‚   β”‚   β”œβ”€β”€ hooks
β”‚   β”‚   β”œβ”€β”€ layouts
β”‚   β”‚   β”œβ”€β”€ pages
β”‚   β”‚   β”œβ”€β”€ routes
β”‚   β”‚   β”œβ”€β”€ services
β”‚   β”‚   β”œβ”€β”€ styles
β”‚   β”‚   β”œβ”€β”€ utils
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   └── main.jsx
β”‚   └── package.json
β”‚
β”œβ”€β”€ server
β”‚   β”œβ”€β”€ prisma
β”‚   β”œβ”€β”€ src
β”‚   β”‚   β”œβ”€β”€ config
β”‚   β”‚   β”œβ”€β”€ controllers
β”‚   β”‚   β”œβ”€β”€ middleware
β”‚   β”‚   β”œβ”€β”€ routes
β”‚   β”‚   β”œβ”€β”€ services
β”‚   β”‚   β”œβ”€β”€ utils
β”‚   β”‚   β”œβ”€β”€ lib
β”‚   β”‚   └── server.js
β”‚   └── package.json
β”‚
└── README.md

βš™ Installation

Clone Repository

git clone https://github.com/tarun0001g/SecureAuthentication.git

cd SecureAuthentication

Backend Setup

cd server

npm install

Create .env

PORT=5000

DATABASE_URL=your_postgresql_database_url

JWT_SECRET=your_jwt_secret

RESEND_API_KEY=your_resend_api_key

SENDER_EMAIL=your_verified_sender_email

Run Prisma Migration

npx prisma migrate dev

npx prisma generate

Start Backend

npm run dev

Frontend Setup

cd client

npm install

npm run dev

Frontend

http://localhost:5173

Backend

http://localhost:5000

πŸ”„ Authentication Flow

User Register
       β”‚
       β–Ό
Verification Email Sent
       β”‚
       β–Ό
Verify Email
       β”‚
       β–Ό
Login
       β”‚
       β–Ό
JWT Generated
       β”‚
       β–Ό
Dashboard
       β”‚
       β–Ό
Protected Routes

πŸ”‘ Password Reset Flow

Forgot Password
        β”‚
        β–Ό
Generate Reset Token
        β”‚
        β–Ό
Send Email
        β”‚
        β–Ό
Reset Password Link
        β”‚
        β–Ό
Create New Password
        β”‚
        β–Ό
Login Again

πŸ“Œ API Endpoints

Authentication

Method Endpoint Description
POST /api/auth/register Register User
POST /api/auth/login Login User
GET /api/auth/verify-email/:token Verify Email
POST /api/auth/forgot-password Forgot Password
POST /api/auth/reset-password/:token Reset Password

User

Method Endpoint Description
GET /api/user/profile Get Current User
PATCH /api/user/profile Update Profile

πŸ“– Learning Outcomes

This project helped me gain hands-on experience with:

  • Full Stack Development
  • React Context API
  • JWT Authentication
  • Protected Routes
  • REST APIs
  • Prisma ORM
  • PostgreSQL
  • Password Hashing
  • Email Verification
  • Password Reset Flow
  • Authentication Middleware
  • API Integration using Axios
  • Production-Level Authentication Flow

πŸš€ Future Improvements

  • Profile Picture Upload
  • Change Password
  • Refresh Token Authentication
  • Google OAuth Login
  • GitHub OAuth Login
  • Two-Factor Authentication (2FA)
  • Role-Based Authentication
  • Admin Dashboard
  • Account Settings
  • Session Management

πŸ‘¨β€πŸ’» Author

Tarun Makavana

B.E. Information Technology

Shantilal Shah Engineering College, Bhavnagar

GitHub: https://github.com/tarun0001g

LinkedIn: https://www.linkedin.com/in/tarun-makavana-52601427a/


⭐ Support

If you found this project helpful, consider giving it a ⭐ on GitHub.

It motivates me to build more open-source projects.


πŸ“œ License

This project is created for educational and learning purposes.

About

A secure full-stack authentication system built with React, Node.js, Express, Prisma, PostgreSQL, and JWT, featuring email verification, password reset, protected routes, and profile management.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages