This project is a full-stack MERN (MongoDB, Express, React, Node.js) application designed for educational purposes. It follows industrial-level standards for both the client-side (React) and server-side (Node.js, Express) implementations. The application demonstrates scalable architecture, modular code, state management with Redux, robust user authentication, and deployment practices.
- Project Overview
- Technologies Used
- Features
- Folder Structure
- Setup & Installation
- API Endpoints
- Running the Project
- Contributing
- License
This project is a simple MERN stack application that allows users to interact with a database, perform CRUD operations, and manage state with Redux on the frontend. The backend is built using Express and MongoDB, and the frontend uses React for dynamic rendering. The application is designed to follow modern development practices and is a great resource for anyone learning MERN stack development at an industrial level.
- MongoDB: NoSQL database to store and manage application data.
- Express.js: Web framework for Node.js, used to build the backend API.
- React.js: Frontend JavaScript library for building user interfaces.
- Node.js: JavaScript runtime used for the server-side development.
- Redux: State management library for React.
- JWT (JSON Web Token): For user authentication and session management.
- Bcrypt.js: Library for hashing passwords.
- Axios: Promise-based HTTP client for making API requests.
- Mongoose: MongoDB object modeling for Node.js.
- dotenv: For managing environment variables.
- Authentication: User login and registration with JWT-based authentication.
- CRUD Operations: Create, Read, Update, and Delete data through RESTful APIs.
- State Management: Redux for managing app state across components.
- Responsive UI: Dynamic frontend using React that is mobile-friendly.
- Error Handling: Graceful error handling and validation on both frontend and backend.
- Modular Codebase: Well-structured and scalable architecture for easy maintenance.
- Environment Configuration: Environment variables used for secure configuration.
The project is divided into two main parts: the server-side (backend) and the client-side (frontend).
/mern-stack-industrial-study-project
│
├── /client # React client-side application
│ ├── /src
│ │ ├── /components # React components
│ │ ├── /redux # Redux store and actions
│ │ └── /utils # Helper functions
│ ├── package.json # React dependencies
│ └── .env # Environment variables for the client
│
├── /server # Node.js backend application
│ ├── /controllers # Express route controllers
│ ├── /models # Mongoose models
│ ├── /routes # Express routes
│ ├── /middleware # Middleware for authentication
│ ├── server.js # Main server file
│ ├── .env # Environment variables for the server
│ └── package.json # Backend dependencies
│
└── README.md # This file
Before starting, ensure that you have the following installed:
- Node.js (v14 or higher)
- MongoDB (either locally or a cloud-based service like MongoDB Atlas)
-
Clone the repository:
git clone https://github.com/your-username/mern-stack-industrial-study-project.git cd mern-stack-industrial-study-project
-
Install dependencies for both client and server:
-
For the client-side:
cd client npm install
-
For the server-side:
cd ../server npm install
-
-
Setup environment variables:
- Create
.env
files in both/client
and/server
directories. - Define necessary variables like database URL, JWT secret, etc.
- Example
.env
file for the server:MONGO_URI=mongodb://localhost:27017/mernstack JWT_SECRET=your_jwt_secret
- Example
- Create
-
Start the server and client:
- In the server directory:
npm start
- In the client directory:
npm start
- In the server directory:
The application should now be running on http://localhost:3000
(client) and http://localhost:5000
(server).
- POST /api/auth/register: Register a new user.
- POST /api/auth/login: Login and receive JWT token.
- GET /api/users: Get a list of all users.
- GET /api/users/:id: Get a specific user by ID.
- PUT /api/users/:id: Update user information.
- DELETE /api/users/:id: Delete a user.
-
Start the backend server:
cd server npm start
-
Start the frontend client:
cd client npm start
Visit http://localhost:3000
in your browser to interact with the application.
Contributions are welcome! If you'd like to contribute to this project, please follow these steps:
- Fork this repository.
- Create a new branch (
git checkout -b feature-name
). - Make your changes and commit (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-name
). - Open a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.