A full stack MERN application that tracks exercises completed by a user. Uses React for the frontend UI and a REST API using Node and Express for the backend web service. MongoDB is used for persistence with CRUD operations performed via Mongoose. Written as a portfolio project for CS290 (Web Development) at Oregon State University.
- Node.js: Installation instructions linked here.
- npm (Node Package Manager - included in Node.js)
- Git (optional, for cloning the repository)
git clone https://github.com/sonnenco/exercise-app.git
cd exercise-appData for this application persists in MongoDB with the following attributes:
Database Name : exercise_app_db
Database Collection : exercisesYou will need to create a database and collection in MongoDB which matches these attributes. This can be hosted locally (such as the VS Code MongoDB extension) or in the cloud (such as MongoDB Atlas free tier).
Copy your MongoDB connection string for use in setup step #2.
REST API uses a .env file with 2 variables.
MONGODB_CONNECT_STRING='insert your connection string here'
PORT=3000Paste in your connection string into /exercise-rest/.env and save the file to ensure consistent use of the attributes across the application.
Navigate to /exercise-rest directory and run these commands sequentially:
npm install
npm startThis will start the API using the attributes in the .env file.
API runs independently of the React application. See /exercise-rest/test-requests.http for test requests. These can be executed using a local REST extension for your IDE to verify CRUD operations are working as intended.
Navigate to /exercise-ui directory and run these commands sequentially:
npm install
npm run devThis will start the React application on localhost:5173 in your web browser. This application will then leverage the REST API running on local port 3000.
| Property | Data Type | Comments |
|---|---|---|
| name | string | Name of the exercise |
| reps | integer | Greater than 0 |
| weight | integer | Greater than 0 |
| unit | string | kgs or lbs |
| date | string | MM-DD-YY |
| _id | object | Automatically generated when document created in MongoDB |
Model and controller are separated (model.mjs vs controller.mjs) per MVC design. Mongoose is used to interact with MongoDB to perform the CRUD operations.
- Create using POST /exercises
Request : JSON object, no path parameters, must contain all 5 properties and meet minimum property requirements.
Response : Success code 201, Failure code 400.- Read using GET / exercises
Request : No path parameter, no request body.
Response : Success code 200 + JSON body containing the entire collection.- GET using GET /exercises/:_id
Request : Path parameter contains ID of the document, no request body.
Response : Success code 200 + JSON body containing document with that ID, Failure code 404. - Update using PUT /exercises/:_id
Request : JSON object and path parameter contains ID of the document.
Response : Success code 200 + JSON body with all properties of the updated document.- DELETE using DELETE /exercises/:_id
Request : Path parameter contains ID of the document, no request body.
Response : Success code 204, Failure code 404.Contains three pages inside the Single Page Application (SPA):
- Home page
- Edit Exercise page
- Create Exercise page
