Giter Club home page Giter Club logo

mern-stack-authentication-boilerplate's Introduction

Logo with shadow

Ultimate MERN Stack Authentication Boilerplate for production use

๐Ÿš€ Demo

This application is deployed on DigitalOcean. Please check it out ๐Ÿ˜„ here.

mern-stack-authentication-boilerplate

๐Ÿ–ฅ๏ธ Tech Stack

Frontend:

HTML5ย  CSS3ย  JavaScriptย  Bootstrapย  Reactย  React Routerย 

Backend:

Node JSย  HTML5ย  JWTย 

Database:

MongoDBย 

Deployed On:

DigitalOcean

โšก๏ธ Features

  • Protected routes with Higher Order Components
  • Login with forgot password feature.
  • JWT protected APIs
  • Passwords are encrypted.
  • Image upload with Cloudinary
  • Toast notifications for user actions.

๐Ÿ“ Project structure

โ”œโ”€โ”€ client/
โ”‚   โ”œโ”€โ”€ public/
โ”‚   โ”‚   โ”œโ”€โ”€ favicon.ico
โ”‚   โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ”‚   โ”œโ”€โ”€ logo192.png
โ”‚   โ”‚   โ”œโ”€โ”€ logo512.png
โ”‚   โ”‚   โ”œโ”€โ”€ manifest.json
โ”‚   โ”‚   โ””โ”€โ”€ robots.txt
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ assets/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ email.svg
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ green_check.svg.json
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ index.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ logo.png
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ user.svg
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ NavigationBar/
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ NavigationBar.jsx
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ NavigationBar.css
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ProfileModal/
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ProfileModal.jsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ index.js
โ”‚   โ”‚   โ”œโ”€โ”€ context/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ AuthProvider.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ Pages/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ForgotPasswordPage/
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ForgotPasswordPage.css
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ForgotPasswordPage.jsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ HomePage/
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ HomePage.css
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ HomePage.jsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ LoginPage/
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ LoginPage.css
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ LoginPage.jsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ PasswordResetPage/
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ PasswordResetPage.css
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ PasswordResetPage.jsx
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ RegisterPage/
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ RegisterPage.css
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ RegisterPage.jsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ index.js
โ”‚   โ”‚   โ”œโ”€โ”€ Utils/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ index.js
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ notify.js
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ PrivateRoutes.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ App.css
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx
โ”‚   โ”‚   โ””โ”€โ”€ index.js
โ”‚   โ”œโ”€โ”€ .env.example
โ”‚   โ”œโ”€โ”€ package-lock.json
โ”‚   โ””โ”€โ”€ package.json
โ”œโ”€โ”€ config/
โ”‚   โ””โ”€โ”€ db.js
โ”œโ”€โ”€ controllers/
โ”‚   โ”œโ”€โ”€ auth.js
โ”‚   โ””โ”€โ”€ private.js
โ”œโ”€โ”€ middleware/
โ”‚   โ”œโ”€โ”€ auth.js
โ”‚   โ””โ”€โ”€ error.js
โ”œโ”€โ”€ models/
โ”‚   โ””โ”€โ”€ User.js
โ”œโ”€โ”€ routes/
โ”‚   โ”œโ”€โ”€ auth.js
โ”‚   โ””โ”€โ”€ private.js
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ errorResponse.js
โ”‚   โ””โ”€โ”€ sendEmail.js
โ”œโ”€โ”€ .env.example
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ package-lock.json
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ server.js

๐Ÿ“– Prerequisites

In order to run the project you need node>=16 and npm>=8 installed on your machine.

๐Ÿšฉ Getting Started

1. Clone the mern-stack-authentication-boilerplate repository:

git clone https://github.com/rtewari056/mern-stack-authentication-boilerplate.git

2. Navigate into repo:

cd mern-stack-authentication-boilerplate

3. Rename .env.example into .env and put all creadentials:

# In the root directory put your creadentials
APP_BASE_URL=http://localhost:3000
NODE_ENV=development
PORT=5000
MONGO_URI="YOUR_MONGO_CONNECTION_URL"
JWT_SECRET="YOUR_JWT_SECRET"
JWT_EXPIRE=24 # In hours
SMTP_HOST=<YOUR_SMTP_SERVER_HOST_NAME>
SMTP_PORT=587
SMTP_USER=<YOUR_SMTP_SERVER_USER_NAME>
SMTP_PASSWORD=<YOUR_SMTP_SERVER_PASSWORD>
EMAIL_FROM=<EMAIL_ADDRESS_OF_SENDER>

# Now go to client folder and put your cloudinary creadentials 
REACT_APP_CLOUDINARY_CLOUD_NAME=<YOUR_CLOUDINARY_CLOUD_NAME>
REACT_APP_CLOUDINARY_UPLOAD_PRESET=<YOUR_CLOUDINARY_UPLOAD_PRESET>

4. Install package dependencies:

npm install # Server dependencies
cd client
npm install # Client dependencies

4. Run project:

In the root directory, open two terminal sessions and run both commands separately:

npm run client
npm run server

5. Open your browser and go to http://localhost:3000

๐Ÿ‘ค Developer

Rohit Tewari

๐Ÿ“ฌ Contact

If you want to contact me, you can reach me through below handles.

LinkedIn Gmail Twitter

๐Ÿ“ƒ License

MERN Stack Authentication Boilerplate is licensed under the MIT License.

Show your support by ๐ŸŒŸ the project

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.