Skip to content

subhajitsakar26-eng/SecureFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” MERN Authentication Boilerplate

A production-ready MERN stack authentication system with secure JWT & refresh token handling, role-based access control, and a modern React + TailwindCSS frontend.


✨ Features

  • 🌐 MERN Stack (MongoDB, Express, React, Node.js)
  • πŸ”‘ Authentication & Authorization
    • Login, Logout
    • Access & Refresh Tokens
    • Secure password hashing with bcrypt
  • πŸ›‘οΈ Protected Routes (API + Frontend)
  • 🎨 Modern UI with React + TailwindCSS
  • πŸͺ Cookie-based sessions with HttpOnly cookies
  • πŸ“‚ Clean and maintainable folder structure

πŸ“¦ Tech Stack

Frontend: React, Vite, TailwindCSS
Backend: Node.js, Express.js, MongoDB, Mongoose
Auth: JWT, Refresh Tokens, bcrypt
Dev Tools: Nodemon, dotenv


βš™οΈ Installation & Setup

1️⃣ Clone the Repository

git clone https://github.com/your-company/mern-auth-boilerplate.git
cd mern-auth-boilerplate

2️⃣ Backend Setup

cd backend
npm install

Create a .env file inside /backend:

PORT=3000
MONGODB_URI=your_mongodb_connection_string
DB_NAME=authdb
ACCESS_TOKEN_SECRET=your_access_secret
ACCESS_TOKEN_EXPIRY=1d
REFRESH_TOKEN_SECRET=your_refresh_secret
REFRESH_TOKEN_EXPIRY=15d
CORS_ORIGIN=http://localhost:5173

Run backend server:

npm run dev

3️⃣ Frontend Setup

cd frontend
npm install
npm run dev

The frontend runs on http://localhost:5173
The backend runs on http://localhost:3000


πŸš€ Usage

  • Open frontend in browser (http://localhost:5173)
  • Register / Login with email & password
  • Access protected dashboard with JWT auth

πŸ“‚ Project Structure

mern-auth-boilerplate/
│── backend/
β”‚   β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ middleware/
β”‚   └── server.js
β”‚
│── frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   └── App.jsx
β”‚   └── tailwind.config.js
β”‚
└── README.md

πŸ“œ License

This project is maintained by onescreensolutions.
Feel free to use it for learning or as a starting point for production projects.


🀝 Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you’d like to change.


🏒 About

This repository is maintained by onescreensolutions as a standard authentication boilerplate for production-ready MERN applications.

About

πŸ” MERN Authentication with JWT, Refresh Tokens & Tailwind Frontend

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published