- π Overview
- π¦ Features
- π Structure
- π» Installation
- ποΈ Usage
- π Hosting
- π API Documentation
- π License & Attribution
- π Authors
The repository contains a Minimum Viable Product (MVP) called "FitTracker" that allows fitness enthusiasts to track their goals and share their progress. It's built using React for the frontend and Node.js with Express for the backend, leveraging MongoDB Atlas for data persistence. The application provides user authentication, goal setting, progress tracking, and social sharing capabilities.
| Feature | Description | |
|---|---|---|
| π | Authentication | Secure user authentication using bcrypt for password hashing and JWT for session management. |
| π― | Goal Setting | Users can define and customize fitness goals, storing parameters in MongoDB for persistence. |
| π | Progress Tracking | Real-time progress updates through API endpoints, allowing users to monitor their achievements. |
| π± | Responsive Design | A fully responsive UI built with React and styled with Tailwind CSS for optimal viewing across devices. |
| π‘οΈ | XSS Protection | Utilizes DOMPurify for input sanitization to prevent Cross-Site Scripting (XSS) attacks. |
| βοΈ | Centralized State | Authentication state management is handled via React Context API for consistent user experience. |
| π | API Services | Abstracted API calls using axios, providing a service layer for easy data fetching and updates. |
| βοΈ | Email Validation | Implements client-side email validation with regular expressions, enhancing data quality. |
| π | Cloud Database | Leverages MongoDB Atlas for scalable and reliable cloud-based NoSQL data storage. |
βββ README.md
βββ package.json
βββ src
β βββ components
β β βββ common
β β β βββ Button.jsx
β β β βββ Input.jsx
β β βββ auth
β β β βββ AuthForm.jsx
β β βββ goals
β β β βββ GoalCard.jsx
β β β βββ GoalForm.jsx
β β βββ profile
β β β βββ ProfileDetails.jsx
β β βββ layout
β β β βββ Header.jsx
β β β βββ Footer.jsx
β βββ pages
β β βββ Home.jsx
β β βββ Dashboard.jsx
β β βββ Profile.jsx
β βββ context
β β βββ AuthContext.jsx
β βββ services
β β βββ api.js
β β βββ authService.js
β β βββ goalService.js
β β βββ userService.js
β βββ utils
β β βββ helpers.js
β βββ styles
β βββ global.css
βββ public
β βββ index.html
β βββ favicon.ico
βββ .env
βββ startup.sh
βββ commands.json
- Clone the repository:
git clone https://github.com/coslynx/fit-tracker-mvp.git cd fit-tracker-mvp - Install dependencies:
npm install
- Configure environment variables:
cp .env.example .env # Fill in necessary environment variables in .env file
- Start the development server:
npm run dev
- Access the application:
- Web interface:
http://localhost:3000
- Web interface:
Tip
The .env file contains the configuration settings for the application. Ensure the following variables are properly set:
REACT_APP_API_BASE_URL: Base URL for the backend API (default:http://localhost:3001)MONGODB_URI: MongoDB Atlas connection URIJWT_SECRET_KEY: Secret key for signing JSON Web Tokens
Provide specific examples relevant to the MVP's core features. For instance:
-
π User Registration:
curl -X POST http://localhost:3001/auth/register \ -H "Content-Type: application/json" \ -d '{"username": "newuser", "email": "user@example.com", "password": "securepass123"}' -
π Setting a Fitness Goal:
curl -X POST http://localhost:3001/api/goals \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -d '{"name": "Run a Marathon", "description": "Train to complete a 26.2 mile marathon.", "target": 26.2, "unit": "miles"}'
Provide detailed, step-by-step instructions for deploying to the most suitable platform for this MVP. For example:
- Install the Heroku CLI:
npm install -g heroku
- Login to Heroku:
heroku login
- Create a new Heroku app:
heroku create fit-tracker-production
- Set up environment variables:
heroku config:set NODE_ENV=production heroku config:set REACT_APP_API_BASE_URL=https://your-app-backend.herokuapp.com heroku config:set MONGODB_URI=your_mongodb_uri_here heroku config:set JWT_SECRET_KEY=your_jwt_secret_key_here
- Deploy the code:
git push heroku main
Provide a comprehensive list of all required environment variables, their purposes, and example values:
REACT_APP_API_BASE_URL: Base URL for the backend API Example:http://localhost:3001orhttps://your-app-backend.herokuapp.comMONGODB_URI: Connection string for the MongoDB Atlas database Example:mongodb+srv://<user>:<password>@<cluster>.mongodb.net/fitnesstrackerJWT_SECRET_KEY: Secret key for JWT token generation Example:your-256-bit-secret
Provide a comprehensive list of all API endpoints, their methods, required parameters, and expected responses. For example:
-
POST /auth/register
- Description: Register a new user
- Body:
{ "username": string, "email": string, "password": string } - Response:
{ "statusCode": number, "data": { "id": string, "username": string, "email": string, "token": string } }
-
POST /auth/login
- Description: Log in an existing user
- Body:
{ "email": string, "password": string } - Response:
{ "statusCode": number, "data": { "id": string, "username": string, "email": string, "token": string } }
-
GET /api/goals
- Description: Retrieve all fitness goals for the authenticated user
- Headers:
Authorization: Bearer TOKEN - Response:
{ "statusCode": number, "data": array<{ "id": string, "name": string, "description": string, "target": number, "current": number, "unit": string }> }
-
POST /api/goals
- Description: Create a new fitness goal
- Headers:
Authorization: Bearer TOKEN - Body:
{ "name": string, "description": string, "target": number, "unit": string } - Response:
{ "statusCode": number, "data": { "id": string, "name": string, "description": string, "target": number, "current": number, "unit": string } }
-
PUT /api/goals/:goalId
- Description: Update an existing fitness goal
- Headers:
Authorization: Bearer TOKEN - Parameters:
goalId(string, required) - Body:
{ "name": string, "description": string, "target": number, "unit": string } - Response:
{ "statusCode": number, "data": { "id": string, "name": string, "description": string, "target": number, "current": number, "unit": string } }
-
DELETE /api/goals/:goalId
- Description: Delete a fitness goal
- Headers:
Authorization: Bearer TOKEN - Parameters:
goalId(string, required) - Response:
{ "statusCode": number, "message": string }
-
GET /api/users/:userId
- Description: Retrieve a user profile by user ID.
- Headers:
Authorization: Bearer TOKEN - Parameters:
userId(string, required) - Response:
{ "statusCode": number, "data": { "id": string, "username": string, "email": string } }
-
PUT /api/users/:userId
- Description: Update a user profile by user ID.
- Headers:
Authorization: Bearer TOKEN - Parameters:
userId(string, required) - Body:
{ "username": string, "email": string } - Response:
{ "statusCode": number, "data": { "id": string, "username": string, "email": string } }
Explain the authentication process in detail:
- Register a new user or login to receive a JWT token
- Include the token in the
Authorizationheader for all protected routes:Authorization: Bearer YOUR_JWT_TOKEN
Provide comprehensive examples of API usage, including request and response bodies:
# Register a new user
curl -X POST http://localhost:3001/auth/register \
-H "Content-Type: application/json" \
-d '{"username": "fitnessuser", "email": "user@example.com", "password": "securepass123"}'
# Response
{
"statusCode": 201,
"data": {
"id": "user123",
"username": "fitnessuser",
"email": "user@example.com",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
}
# Create a new goal
curl -X POST http://localhost:3001/api/goals \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{"name": "Run a Marathon", "description": "Train to complete a 26.2 mile marathon.", "target": 26.2, "unit": "miles"}'
# Response
{
"statusCode": 201,
"data": {
"id": "goal123",
"name": "Run a Marathon",
"description": "Train to complete a 26.2 mile marathon.",
"target": 26.2,
"current": 0,
"unit": "miles"
}
}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: fit-tracker-mvp
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!