A full-stack user dashboard built with MongoDB, Express, React (Vite), and Node.js. The application allows you to fetch and display a list of users stored in a MongoDB database.
- Fetch and display users from MongoDB
- RESTful API built with Express
- React frontend with Axios and React Router
- Clean project structure with models, controllers, and routes
- Tailwind CSS-ready for styling (optional)
mern-user-dashboard/
├── backend/
│ ├── controllers/
│ ├── models/
│ ├── routes/
│ └── server.js
├── frontend/
│ ├── src/
│ ├── index.html
│ └── vite.config.js
- Node.js & npm
- MongoDB (local or Atlas)
- Git (optional)
cd backendnpm installPORT=5000
MONGO_URI=mongodb://localhost:27017/userdbIf you're using MongoDB Atlas, replace the URI accordingly.
node server.jsYou should see:
MongoDB Connected
Server running on port 5000
cd ../frontendnpm installnpm run devOpen http://localhost:5173 in your browser.
To avoid CORS issues and clean up Axios calls, add this to vite.config.js in the frontend:
server: {
proxy: {
'/api': {
target: 'http://localhost:5000',
changeOrigin: true,
},
},
},Now you can use:
axios.get('/api/users')Without hardcoding localhost:5000.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users | Get all users |
| POST | /api/users | Create a new user |
Use tools like Postman or curl to test:
GET http://localhost:5000/api/users- Add user registration form
- Hash passwords (bcrypt)
- Add authentication (JWT)
- Style UI with Tailwind CSS
- Deploy to Netlify & Render
This project is open-source and free to use for educational or personal projects.
Feel free to reach out or open an issue for help.