- 📍 Overview
- 📦 Features
- 📂 Structure
- 💻 Installation
- 🏗️ Usage
- 🌐 Hosting
- 📄 License
- 👏 Authors
This repository contains a Minimum Viable Product (MVP) for a web application named "fitness-tracker-app". This MVP allows users to track their fitness goals, monitor progress, and share achievements. The application is built using React for the frontend, Node.js for the backend, and MongoDB for data storage. It provides an easy way for fitness enthusiasts to monitor their progress and share achievements with friends.
Feature | Description | |
---|---|---|
🔑 | User Authentication | Secure user authentication system with registration and login functionalities. |
🎯 | Goal Setting | Allows users to set fitness goals with descriptions, target values, and progress tracking. |
📈 | Progress Tracking | Enables users to track their progress towards their fitness goals. |
🔗 | Social Sharing | Provides a basic ability to share fitness achievements. |
⚙️ | Architecture | Uses a modular architecture, separating the frontend (React), backend (Node.js), and database (MongoDB) layers. |
📄 | Documentation | Includes a detailed README file with project overview, installation, and usage instructions. |
🔗 | Dependencies | Utilizes dependencies like axios , bcrypt , cors , express , joi , jsonwebtoken , mongoose , react , react-dom , react-router-dom , dotenv , and tailwindcss . |
🧩 | Modularity | The project is structured into modules like components, pages, hooks, context, services, utils, and api for better maintainability. |
🧪 | Testing | Includes unit tests for components and validation utilities using @testing-library/react and Jest. |
⚡️ | Performance | Uses efficient database queries and optimized rendering practices. |
🔐 | Security | Implements JWT for secure authentication and password hashing using bcrypt. |
🔀 | Version Control | Utilizes Git for version control. |
🔌 | Integrations | Integrates with MongoDB for data persistence and local storage for token management. |
📶 | Scalability | Designed with a scalable architecture, suitable for future feature expansions. |
├── README.md
├── package.json
├── .env
├── config
│ └── database.js
├── api
│ ├── auth.js
│ └── goals.js
├── models
│ ├── User.js
│ └── Goal.js
├── services
│ ├── api.js
│ └── auth.js
├── controllers
│ ├── authController.js
│ └── goalController.js
├── middlewares
│ └── authMiddleware.js
├── utils
│ ├── helpers.js
│ └── validators.js
├── constants
│ └── apiEndpoints.js
├── components
│ ├── Button.jsx
│ ├── Input.jsx
│ ├── Modal.jsx
│ └── GoalCard.jsx
├── pages
│ ├── Home.jsx
│ ├── Dashboard.jsx
│ └── Goals.jsx
├── hooks
│ ├── useAuth.js
│ └── useFetch.js
├── context
│ └── AuthContext.js
├── public
│ ├── index.html
│ └── favicon.ico
├── styles
│ └── global.css
├── assets
│ ├── images
│ │ └── logo.png
│ └── icons
│ └── settings.svg
└── tests
├── components
│ └── Button.test.js
└── utils
└── validators.test.js
- Clone the repository:
git clone https://github.com/coslynx/fitness-tracker-app.git cd fitness-tracker-app
- Install dependencies:
npm install
- Set up the database:
- Make sure MongoDB is running and accessible using
mongodb://localhost:27017/fitness_tracker
.
- Make sure MongoDB is running and accessible using
- Configure environment variables:
cp .env.example .env
- Update the
.env
file with your desired MongoDB connection URI and JWT secret.
- Update the
- Start the development server:
npm run dev
- Access the application:
- Web interface:
http://localhost:3000
- Web interface:
- The backend server will automatically be started using the development server.
Tip
- The application uses environment variables for configuration.
- Modify the
.env
file to set your MongoDB connection URI (MONGO_URI
), JWT secret (JWT_SECRET
), and client URL (CLIENT_URL
). - The client URL is set to
http://localhost:3000
by default.
Provide specific examples relevant to the MVP's core features:
-
📝 User Registration:
curl -X POST http://localhost:5000/api/auth/register \ -H "Content-Type: application/json" \ -d '{"username": "newuser", "email": "user@example.com", "password": "securepass123"}'
-
📝 User Login:
curl -X POST http://localhost:5000/api/auth/login \ -H "Content-Type: application/json" \ -d '{"username": "newuser", "password": "securepass123"}'
-
📝 Adding a Goal:
curl -X POST http://localhost:5000/api/goals \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -d '{"description": "Run 5 miles", "target": 5, "progress": 0}'
Provide detailed, step-by-step instructions for deploying to the most suitable platform for this MVP. For example:
- Build the React frontend:
cd client npm run build cd ..
- Build the backend by running the command
npm run build:backend
- Copy the contents of the frontend build folder to the server.
- Set up environment variables on the server:
- Set
NODE_ENV
toproduction
. - Set
MONGO_URI
to your production MongoDB connection string. - Set
JWT_SECRET
to your production JWT secret. - Set
CLIENT_URL
to your production URL.
- Set
- Start the Node.js backend server using a process manager like pm2 or forever
npm start
Provide a comprehensive list of all required environment variables, their purposes, and example values:
MONGO_URI
: Connection string for the MongoDB database. Example:mongodb://localhost:27017/fitness_tracker
JWT_SECRET
: Secret key for JWT token generation. Example:your_jwt_secret
PORT
: Port for the Node.js server Example:5000
CLIENT_URL
: URL for the client-side React application. Example:http://localhost:3000
Provide a comprehensive list of all API endpoints, their methods, required parameters, and expected responses:
-
POST /api/auth/register
- Description: Register a new user.
- Body:
{ "username": string, "email": string, "password": string }
- Response:
{ "id": string, "username": string, "email": string, "token": string }
-
POST /api/auth/login
- Description: Login an existing user.
- Body:
{ "username": string, "password": string }
- Response:
{ "id": string, "username": string, "email": string, "token": string }
-
GET /api/auth/me
- Description: Get current logged in user info
- Headers:
Authorization: Bearer TOKEN
- Response:
{ "id": string, "username": string }
-
POST /api/goals
- Description: Create a new fitness goal.
- Headers:
Authorization: Bearer TOKEN
- Body:
{ "description": string, "target": number, "progress": number }
- Response:
{"_id": string, "user": string, "description": string, "target": number, "progress": number, "createdAt": string, "updatedAt": string, "__v": number }
-
GET /api/goals
- Description: Get all goals for the logged in user.
- Headers:
Authorization: Bearer TOKEN
- Response:
[{"_id": string, "user": string, "description": string, "target": number, "progress": number, "createdAt": string, "updatedAt": string, "__v": number }]
-
PUT /api/goals/:id
- Description: Update an existing goal.
- Headers:
Authorization: Bearer TOKEN
- Body:
{ "description": string, "target": number, "progress": number }
- Response:
{"_id": string, "user": string, "description": string, "target": number, "progress": number, "createdAt": string, "updatedAt": string, "__v": number }
-
DELETE /api/goals/:id
- Description: Delete an existing goal.
- Headers:
Authorization: Bearer TOKEN
- Response:
{ "message": string }
Explain the authentication process in detail:
- Register a new user or login to receive a JWT token.
- Include the token in the Authorization header for all protected routes:
Authorization: Bearer YOUR_JWT_TOKEN
- Token expiration is set to 1 hour, after which you need to login again.
Provide comprehensive examples of API usage, including request and response bodies:
# Register a new user
curl -X POST http://localhost:5000/api/auth/register \
-H "Content-Type: application/json" \
-d '{"username": "fitnessuser", "email": "user@example.com", "password": "securepass123"}'
# Response
{
"id": "user123",
"username": "fitnessuser",
"email": "user@example.com",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
# Login user
curl -X POST http://localhost:5000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "fitnessuser", "password": "securepass123"}'
# Response
{
"id": "user123",
"username": "fitnessuser",
"email": "user@example.com",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
# Get current user
curl -X GET http://localhost:5000/api/auth/me \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
# Response
{
"id": "user123",
"username": "fitnessuser"
}
# Create a new goal
curl -X POST http://localhost:5000/api/goals \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-d '{"description": "Run 5 miles", "target": 5, "progress": 0}'
# Response
{
"_id": "goal123",
"user": "user123",
"description": "Run 5 miles",
"target": 5,
"progress": 0,
"createdAt": "2023-01-01T00:00:00.000Z",
"updatedAt": "2023-01-01T00:00:00.000Z",
"__v": 0
}
Note
This Minimum Viable Product (MVP) is licensed under the GNU AGPLv3 license.
This MVP was entirely generated using artificial intelligence through CosLynx.com.
No human was directly involved in the coding process of the repository: fitness-tracker-app
For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:
- Website: CosLynx.com
- Twitter: @CosLynxAI
Create Your Custom MVP in Minutes With CosLynxAI!