MusCo - Auth is a MERN (MongoDB, Express, React, Node.js) stack authentication system that provides a secure and responsive user authentication experience. This project serves as a practical example of how to build a full-stack web application with a focus on user authentication.
- User Registration and Login
- Password Hashing with bcrypt
- Persistent User Sessions using localStorage
- Responsive UI with Bootstrap
- RESTful API Design
- Frontend: React, Bootstrap, Axios, React Router DOM
- Backend: Node.js, Express.js, Mongoose
- Database: MongoDB
- Tools: Nodemon, CORS, Vite
- npm init vite
- npm install bootstrap axios react-router-dom
- import 'bootstrap/dist/css/bootstrap.min.css';
- npm init -y
- npm install express mongoose cors nodemon
- "start": "nodemon index.js"
- npm start
- npm run dev
Use the following curl command to test the registration endpoint:
curl -X POST http://localhost:8002/api/users/register -H "Content-Type: application/json" -d '{"username":"John Doe","email":"[email protected]","password":"password123"}'
- dbConnection.js: Manages the connection to MongoDB.
- userModel.js: Defines the schema and validation for user data.
- userController.js: Handles the business logic for user registration and login.
- userRoutes.js: Defines the API routes related to user operations.
- App.jsx: Main application component that manages routes and session state.
- Navbar.jsx: Responsive navigation bar that changes based on the user's authentication status.
- Login.jsx: Form for user login, including error handling.
- Register.jsx: Form for user registration, including client-side validation.
- Dashboard.jsx: Protected dashboard page, accessible only to logged-in users.
- Home.jsx: Landing page with links to login and registration.
For more detailed information on the technologies used in this project, check out the following resources:
1. MongoDB Documentation
2. Express.js Documentation
3. React.js Documentation
4. Node.js Documentation
5. Bootstrap Documentation
6. Axios Documentation
This project is licensed under the MIT License. See the LICENSE file for details.
Developed by MusCo (Mustafa Coskuncelebi). The complete codebase is available on GitHub.