A full-stack workout tracking application built while following The Net Ninja's MERN Stack Tutorial. This project demonstrates the implementation of a complete CRUD application using MongoDB, Express.js, React, and Node.js.
This is a learning project created by following The Net Ninja's comprehensive MERN Stack tutorial series. The application allows users to manage their workout routines with full Create, Read, Update, and Delete (CRUD) functionality, featuring a modern React frontend and a RESTful API backend.
Through this project, I gained hands-on experience with:
- Building RESTful APIs with Express.js and Node.js
- Database modeling and operations with MongoDB and Mongoose
- Creating interactive UIs with React and React Hooks
- Managing application state with Context API
- Implementing routing with React Router
- Connecting frontend and backend applications
- Environment variable management and security
- Modern JavaScript (ES6+) features and best practices
- β¨ Create Workouts: Add new workout entries with title, reps, and load
- π View Workouts: Display all workouts in a clean, organized list
- βοΈ Update Workouts: Edit existing workout information
- ποΈ Delete Workouts: Remove workouts from the database
- β‘ Real-time Updates: Instant UI updates using React Context
- π± Responsive Design: Mobile-friendly interface
- π¨ Modern UI: Clean and intuitive user experience
- JavaScript library for building user interfaces
- Declarative routing for React
- date-fns (v4.1.0) - Modern JavaScript date utility library
- Context API - State management solution
- JavaScript runtime environment
- Fast, minimalist web framework
- NoSQL document database
- Elegant MongoDB object modeling
- Nodemon (v3.1.10) - Auto-restart server during development
- dotenv (v17.2.3) - Load environment variables from .env file
MERN-Stack-Project/
βββ backend/
β βββ controller/
β β βββ workoutController.js # Business logic for workout operations
β βββ models/
β β βββ workoutModel.js # Mongoose schema for workouts
β βββ routes/
β β βββ workouts.js # API route definitions
β βββ server.js # Express server configuration
β βββ package.json
β βββ .env # Environment variables (not tracked)
β
βββ frontend/
β βββ public/
β βββ src/
β β βββ components/ # Reusable React components
β β βββ context/ # React Context for state management
β β βββ hook/ # Custom React hooks
β β βββ pages/ # Page components
β β βββ App.js # Main App component
β β βββ index.js # React entry point
β β βββ index.css # Global styles
β βββ package.json
β
βββ .gitignore
Before you begin, ensure you have the following installed:
- Node.js (v14 or higher) - Download here
- MongoDB - Local installation or MongoDB Atlas account
- npm or yarn package manager
git clone https://github.com/Tanathorn-Rin/MERN-Stack-Project.git
cd MERN-Stack-Project- Navigate to the backend directory:
cd backend- Install dependencies:
npm install- Create a
.envfile in the backend directory with the following variables:
PORT=4000
MONGODB_URI=mongodb://localhost:27017/workout-db
# Or use MongoDB Atlas connection string:
# MONGODB_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/workout-db- Start the backend server:
# Development mode (with auto-restart)
npm run dev
# Production mode
npm startβ
Backend server should be running on http://localhost:4000
- Open a new terminal and navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Start the React development server:
npm startβ
Frontend application should automatically open at http://localhost:3000
http://localhost:4000/api
| Method | Endpoint | Description | Request Body |
|---|---|---|---|
GET |
/api/workouts |
Retrieve all workouts | N/A |
GET |
/api/workouts/:id |
Retrieve a specific workout | N/A |
POST |
/api/workouts |
Create a new workout | { title, reps, load } |
PATCH |
/api/workouts/:id |
Update a workout | { title, reps, load } |
DELETE |
/api/workouts/:id |
Delete a workout | N/A |
POST http://localhost:4000/api/workouts
Content-Type: application/json
{
"title": "Bench Press",
"reps": 10,
"load": 60
}{
"_id": "507f1f77bcf86cd799439011",
"title": "Bench Press",
"reps": 10,
"load": 60,
"createdAt": "2025-11-05T18:30:00.000Z",
"updatedAt": "2025-11-05T18:30:00.000Z"
}-
Start MongoDB: Ensure your MongoDB server is running
# If using local MongoDB mongod -
Start Backend Server:
cd backend && npm run dev
-
Start Frontend Server:
cd frontend && npm start
-
Access the Application: Open your browser to
http://localhost:3000 -
Add Workouts: Click the form to add your first workout!
cd frontend
npm testnpm test -- --coveragecd frontend
npm run buildThis creates an optimized production build in the frontend/build folder, ready for deployment.
The application can be deployed to various platforms:
- Frontend: Vercel, Netlify, GitHub Pages
- Backend: Heroku, Railway, Render, DigitalOcean
- Database: MongoDB Atlas (cloud-hosted)
- β Setting up a full-stack MERN application from scratch
- β Creating RESTful API endpoints with Express.js
- β Database modeling with Mongoose schemas
- β React hooks (useState, useEffect, useContext)
- β Custom React hooks for reusable logic
- β Context API for global state management
- β Handling asynchronous operations with async/await
- β CORS configuration for connecting frontend and backend
- β Error handling in both client and server
- β MVC (Model-View-Controller) architecture pattern
- The Net Ninja - For the excellent MERN Stack Tutorial
- YouTube Channel: The Net Ninja
- Tutorial source code: iamshaunjp/MERN-Stack-Tutorial
- React Documentation
- Express.js Documentation
- MongoDB Documentation
- Mongoose Documentation
- The Net Ninja YouTube Channel
Tanathorn Rin
- GitHub: @Tanathorn-Rin
- Learning Project: Built while following The Net Ninja's MERN Stack Tutorial
This project is licensed under the ISC License.
This is a learning project, but suggestions and improvements are welcome! Feel free to:
- Fork the project
- Create your feature branch (
git checkout -b feature/improvement) - Commit your changes (
git commit -m 'Add some improvement') - Push to the branch (
git push origin feature/improvement) - Open a Pull Request
For questions or feedback, please open an issue on this repository.
β If you found this project helpful for your learning journey, please give it a star!
This project was created as part of my journey to learn the MERN stack. Special thanks to The Net Ninja for the amazing tutorial!