Skip to content

mr0erek/MERN-Authentication-sys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tree Structure:

MERN-Authentication-sys
                      ├── LICENSE
                      ├── README.md
                      ├── backend
                      │         ├── Controllers
                      │         │             └── AuthController.js
                      │         ├── Middlewares
                      │         │             ├── Auth.js
                      │         │             └── AuthValidation.js
                      │         ├── Models
                      │         │        ├── User.js
                      │         │        └── db.js
                      │         ├── Routes
                      │         │        ├── AuthRouter.js
                      │         │        └── ProductRouter.js
                      │         ├── index.js
                      │         ├── package-lock.json
                      │         └── package.json
                      ├── frontend
                      ├── README.md
                      ├── package-lock.json
                      ├── package.json
                      ├── public
                      │        ├── favicon.ico
                      │        ├── index.html
                      │        ├── logo192.png
                      │        ├── logo512.png
                      │        ├── manifest.json
                      │        └── robots.txt
                      └── src
                            ├── App.css
                            ├── App.js
                            ├── App.test.js
                            ├── RefreshHandler.js
                            ├── index.css
                            ├── index.js
                            ├── logo.svg
                            ├── pages
                            │       ├── Home.js
                            │       ├── Login.js
                            │       └── Signup.js
                            ├── reportWebVitals.js
                            ├── setupTests.js
                            └── utils.js

                      

WireFrame

MERN WireFrame

Typing SVG

MERN-Authentication-sys

Full-Stack Authentication System with MERN Stack

MERN-STACK.img

High-Level Documentation for MERN Full-Stack Authentication System

1. Introduction

  • Project Name: FULL-STACK AUTHENTICATION SYSTEM
  • Description: Web app with full-stack authentication using the MERN stack.
  • Purpose: Secure user authentication with role-based access control.

2. Architecture Overview

  • Frontend: React.js (Hosted on Vercel)
  • Backend: Node.js with Express.js (Hosted on Render)
  • Database: MongoDB (User data storage)

3. Key Components

  • Frontend:
    • React Components: Login, Register, Dashboard, Admin Panel
    • State Management: Context API/Redux
    • Routing: React Router
  • Backend:
    • Express Routes: Auth routes, protected routes
    • Middleware: JWT verification, Role-based authorization
  • Database:
    • User Schema: User data including roles

4. Data Flow

  1. User Registration:
    • Frontend sends POST request to /auth/signup
    • Backend hashes password, saves user in MongoDB, responds with success/error
  2. User Login:
    • Frontend sends POST request to /auth/login
    • Backend verifies credentials, generates JWT, responds with token and role
    • Frontend stores token and role
    • MindMap to avoid JWT TOKEN Spoofing
      Check Mind Map
  3. Protected Routes:
    • Frontend checks JWT token, sends with requests
    • Backend verifies token, checks user role, allows/denies access

5. Role-Based Authentication Implementation

Typing SVG