Skip to content

denverdelamasa/mern-stack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MERN Stack Authentication Template

A simple MERN (MongoDB, Express, React, Node.js) starter project with authentication. This template provides the essential building blocks for a login/signup system so you can quickly build and expand into a full application!


πŸš€ Features

  • πŸ” User authentication (signup & login)
  • πŸ›‘οΈ Password hashing with bcrypt
  • πŸ“¦ Backend API built with Express & MongoDB
  • βš›οΈ Frontend with React & Vite
  • πŸ“‘ API requests handled via Axios
  • πŸ”„ Ready-to-extend template for dashboards, CRUD apps, and more (Depending on your project)

πŸ“‚ Project Structure

mern-stack/
β”œβ”€β”€ client/ # Frontend (React + Vite)
β”‚ β”œβ”€β”€ node_modules/
β”‚ β”œβ”€β”€ public/
β”‚ β”œβ”€β”€ src/
β”‚ β”‚ β”œβ”€β”€ App.jsx
β”‚ β”‚ β”œβ”€β”€ Home.jsx
β”‚ β”‚ β”œβ”€β”€ Login.jsx
β”‚ β”‚ β”œβ”€β”€ Signup.jsx
β”‚ β”‚ └── main.jsx
β”‚ β”œβ”€β”€ .gitignore
β”‚ β”œβ”€β”€ eslint.config.js
β”‚ β”œβ”€β”€ index.html
β”‚ β”œβ”€β”€ package-lock.json
β”‚ β”œβ”€β”€ package.json
β”‚ └── vite.config.js
β”‚
β”œβ”€β”€ server/ # Backend (Node.js + Express + MongoDB)
β”‚ β”œβ”€β”€ models/
β”‚ β”‚ └── Account.js
β”‚ β”œβ”€β”€ node_modules/
β”‚ β”œβ”€β”€ .env
β”‚ β”œβ”€β”€ .gitignore
β”‚ β”œβ”€β”€ index.js
β”‚ β”œβ”€β”€ package-lock.json
β”‚ └── package.json
β”‚
β”œβ”€β”€ README.md

βš™οΈ Installation & Setup

1. Clone the repository

git clone https://github.com/denverdelamasa/mern-stack.git
cd mern-stack

2. Install dependencies

Backend

cd server
npm install

Frontend

cd ../client
npm install

3. Setup Environment Variables

Create a .env file in the backend directory with the following keys:

PORT=3001
MONGO_URI=mongodb://127.0.0.1:27017/account
JWT_ACCESS_SECRET=supersecret-access-key
JWT_REFRESH_SECRET=supersecret-refresh-key

4. Run the development servers

Start backend

cd server
npm start

Start frontend

cd client
npm run dev

Frontend runs on http://localhost:5173 and backend on http://localhost:3001 (by default).


πŸ–ΌοΈ Usage

  • Go to http://localhost:5173
  • Sign up for a new account
  • Log in with your credentials
  • After login, you’ll be redirected to the Home page (example protected route)

πŸ›  Troubleshooting

MongoDB Permission Issues on Windows
Some users may encounter (because I did) an error when trying to start MongoDB due to permission issues if it’s installed inside C:/Program Files.

Fix:

  1. Uninstall MongoDB.
  2. Reinstall it directly in C:/ (e.g., C:/MongoDB/) instead of C:/Program Files/.
  3. Make sure the mongod service points to the new installation path.

This avoids Windows permission conflicts and ensures MongoDB runs correctly!


🀝 Contributing

This is meant to be a starter template. Feel free to fork and adapt for your own projects. Contributions are welcome via pull requests!

Goodluck on your project!!!


πŸ“„ License

This project is open-source and available under the MIT License.

About

MERN-STACK template to start your projects!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published