Skip to content

πŸ” A robust full-stack authentication system built with Node.js, Express, MySQL2, and React. It features secure user registration, login, logout, token refresh, and access to protected routes using JSON Web Tokens (JWT).

Notifications You must be signed in to change notification settings

amirmub/jwt-auth-fullstack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

41 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” Full-Stack JWT Authentication System

A secure and minimal JWT-based authentication system using React, Node.js, Express, MySQL2, and bcrypt. This project implements user registration, login, logout, token refresh, providing a robust foundation for secure web applications.


πŸ“Έ Preview

Register Login

βš™οΈ Features

βœ… Register and Login with secure hashing
βœ… JWT Access + Refresh Token flow
βœ… MySQL2 for persistent user storage
βœ… Bcrypt for password encryption
βœ… Protected routes via middleware
βœ… Token storage and invalidation system
βœ… RESTful API with JSON responses


πŸš€ Tech Stack

Layer Technology
Frontend React, Axios, React Router
Backend Node.js, Express
Database MySQL, MySQL2 (Driver)
Security bcrypt, JWT
Config & Env dotenv
Dev Tools Nodemon, Postman

πŸ§‘β€πŸ’» Getting Started

Follow these steps to run the project locally on your machine.

1. Clone the Repository

git clone https://github.com/amirmub/jwt-auth.git
cd jwt-auth/server

2. Install dependencies

npm install

3. Setup MySQL Tables

CREATE DATABASE jwt_auth;

CREATE TABLE users (
  user_id INT AUTO_INCREMENT PRIMARY KEY,
  username VARCHAR(255) NOT NULL,
  firstname VARCHAR(255) NOT NULL,
  lastname VARCHAR(255) NOT NULL,
  email VARCHAR(255) NOT NULL UNIQUE,
  password VARCHAR(255) NOT NULL
);

CREATE TABLE tokens (
  id INT AUTO_INCREMENT PRIMARY KEY,
  user_id INT NOT NULL,
  token TEXT NOT NULL,
  FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);

4. Start the backend server:

npm start

5. Setup Frontend

cd ../client
npm install

6. Start the frontend development server:

npm run dev

πŸ™Œ Contributing

Fork the repository

Create a new branch:

git checkout -b feature-new-feature

Commit your changes:

git commit -m "Add new feature"

Push to GitHub:

git push origin feature-new-feature

Open a Pull Request

πŸ“¬ Contact

πŸ“§ Email: amirmubarek01@gmail.com
πŸ’» GitHub: @amirmub

About

πŸ” A robust full-stack authentication system built with Node.js, Express, MySQL2, and React. It features secure user registration, login, logout, token refresh, and access to protected routes using JSON Web Tokens (JWT).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published