Skip to content

DalaScript/fullstack-auth-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Fullstack Auth App - User Authentication System

🚀 Overview

A simple fullstack authentication system with JWT-based login, MongoDB user storage, and a protected dashboard route.
Built for learning, testing, and extending real-world auth flows in fullstack applications. 🔐

This project includes a React frontend, Node.js backend, and MongoDB database connection.


📌 Features

  • 🔐 User Registration & Login
  • 🔑 Password hashing with bcrypt
  • 📦 Token-based authentication with JWT
  • 🔐 Protected routes (Dashboard)
  • 🚪 Logout functionality
  • 📁 Organized code structure for scalability
  • 🧪 Tested via Postman

📦 Setup & Installation

1️⃣ Clone the Repository

git clone https://github.com/DalaScript/fullstack-auth-app.git
cd fullstack-auth-app

2️⃣ Install Dependencies

Backend:

cd server
npm install

Frontend:

cd ../client
npm install

3️⃣ Configure Environment Variables

In the server/ folder, create a .env file and add:

PORT=5000
MONGO_URI=your_mongodb_connection_string
DB_NAME=your_database_name
JWT_SECRET=your_secret_key

🔥 You can change the port or JWT secret as needed.

4️⃣ Start the Server

Backend:

npm start

Frontend (React App):

cd ../client
npm start

📡 API Endpoints

🔹 POST /api/register

Registers a new user.

Request Body:

{
  "email": "[email protected]",
  "password": "yourpassword"
}

🔹 POST /api/login

Logs in a user and returns a token.

Request Body:

{
  "email": "[email protected]",
  "password": "yourpassword"
}

Response:

{
  "token": "jwt-token"
}

Token is stored in localStorage on the client side.


⚙️ Additional Features

  • Frontend redirect logic based on auth status
  • Token stored securely in localStorage
  • Clean and minimalistic UI

🛠️ Technologies Used

Frontend:

  • React
  • React Router DOM

Backend:

  • Node.js
  • MongoDB
  • bcryptjs
  • jsonwebtoken

🎯 Next Steps

  • ✅ Add user-specific content after login (e.g., profile, settings)
  • 📄 Implement server-side token validation middleware
  • 🌐 Form validations & error handling improvements
  • 📬 Add forgot password and reset functionality

🤝 Contributing

Feel free to fork and submit issues!

Created by DalaScript 💻


Author

Connect with Me

Coding Profiles

Releases

No releases published

Packages

No packages published