Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FitTracker

Web app for enthusiasts: goal setting, progress tracking, social sharing.

Developed with the software and tools below.

React 18.2.0 JavaScript, HTML, CSS Node.js MongoDB Atlas
git-last-commit GitHub commit activity GitHub top language

πŸ“‘ Table of Contents

  • πŸ“ Overview
  • πŸ“¦ Features
  • πŸ“‚ Structure
  • πŸ’» Installation
  • πŸ—οΈ Usage
  • 🌐 Hosting
  • πŸ“„ API Documentation
  • πŸ“œ License & Attribution
  • πŸ‘ Authors

πŸ“ Overview

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.

πŸ“¦ Features

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.

πŸ“‚ Structure

β”œβ”€β”€ 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

πŸ’» Installation

Warning

πŸ”§ Prerequisites

  • Node.js v16+
  • npm 6+

πŸš€ Setup Instructions

  1. Clone the repository:
    git clone https://github.com/coslynx/fit-tracker-mvp.git
    cd fit-tracker-mvp
  2. Install dependencies:
    npm install
  3. Configure environment variables:
    cp .env.example .env
    # Fill in necessary environment variables in .env file

πŸ—οΈ Usage

πŸƒβ€β™‚οΈ Running the MVP

  1. Start the development server:
    npm run dev
  2. Access the application:
    • Web interface: http://localhost:3000

Tip

βš™οΈ Configuration

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 URI
  • JWT_SECRET_KEY: Secret key for signing JSON Web Tokens

πŸ“š Examples

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"}'

🌐 Hosting

πŸš€ Deployment Instructions

Provide detailed, step-by-step instructions for deploying to the most suitable platform for this MVP. For example:

Deploying to Heroku

  1. Install the Heroku CLI:
    npm install -g heroku
  2. Login to Heroku:
    heroku login
  3. Create a new Heroku app:
    heroku create fit-tracker-production
  4. 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
  5. Deploy the code:
    git push heroku main

πŸ”‘ Environment Variables

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:3001 or https://your-app-backend.herokuapp.com
  • MONGODB_URI: Connection string for the MongoDB Atlas database Example: mongodb+srv://<user>:<password>@<cluster>.mongodb.net/fitnesstracker
  • JWT_SECRET_KEY: Secret key for JWT token generation Example: your-256-bit-secret

πŸ“„ API Documentation

πŸ” Endpoints

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 } }

πŸ”’ Authentication

Explain the authentication process in detail:

  1. Register a new user or login to receive a JWT token
  2. Include the token in the Authorization header for all protected routes:
    Authorization: Bearer YOUR_JWT_TOKEN
    

πŸ“ Examples

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

πŸ“œ License & Attribution

πŸ“„ License

This Minimum Viable Product (MVP) is licensed under the GNU AGPLv3 license.

πŸ€– AI-Generated MVP

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

πŸ“ž Contact

For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:

🌐 CosLynx.com

Create Your Custom MVP in Minutes With CosLynxAI!