Skip to content

Track fitness goals share progress with friends simple... Created at https://coslynx.com

Notifications You must be signed in to change notification settings

coslynx/fitlog-progress-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

43 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

fitness-tracker-app

Track fitness goals, monitor progress, and share with friends.

Developed with the software and tools below.

React Framework Frontend Technologies Node.js Backend SQLite Database
git-last-commit GitHub commit activity GitHub top language

πŸ“‘ Table of Contents

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

πŸ“ Overview

The fitness-tracker-app is a web application built as a Minimum Viable Product (MVP) that enables users to track their fitness goals, monitor their progress, and share their achievements with friends. It's designed for fitness enthusiasts who seek an easy-to-use platform for managing their fitness journey. The application uses React for the frontend and Node.js for the backend, with data stored in SQLite.

πŸ“¦ Features

Feature Description
πŸ”‘ User Authentication Secure user registration and login functionality using email and password, with JWT for authentication.
🎯 Goal Setting Allows users to set personalized fitness goals, including name, target, unit, and optional start and end dates.
πŸ“ˆ Progress Tracking Enables users to log their fitness progress, track values over time, and view progress through charts.
πŸ“Š Data Visualization Provides visual representations of user progress using charts, which enhances user understanding of their fitness journey.
πŸ—‚οΈ Data Storage Uses SQLite for data storage, offering a simple and lightweight solution for the MVP.
βš™οΈ RESTful API Provides a RESTful API for the frontend to communicate with the backend server for all data operations.
βš›οΈ React Frontend The UI is built using React, offering a responsive and dynamic user interface.
πŸ›‘οΈ Security Implements token-based authentication and secure password handling to protect user data and privacy.
πŸ“± Responsive Design The UI is designed to be responsive, ensuring accessibility across devices.
🧩 Modular Structure Organized codebase for easy maintenance and future scalability.

πŸ“‚ Structure

 β”œβ”€β”€ README.md
 β”œβ”€β”€ package.json
 β”œβ”€β”€ components
 β”‚   β”œβ”€β”€ Button.jsx
 β”‚   β”œβ”€β”€ Input.jsx
 β”‚   β”œβ”€β”€ Modal.jsx
 β”‚   β”œβ”€β”€ LoginForm.jsx
 β”‚   β”œβ”€β”€ SignupForm.jsx
 β”‚   β”œβ”€β”€ GoalCard.jsx
 β”‚   β”œβ”€β”€ GoalForm.jsx
 β”‚   β”œβ”€β”€ GoalList.jsx
 β”‚   β”œβ”€β”€ ProgressChart.jsx
 β”‚   β”œβ”€β”€ ProgressInput.jsx
 β”‚   β”œβ”€β”€ Header.jsx
 β”‚   └── Footer.jsx
 β”œβ”€β”€ pages
 β”‚   β”œβ”€β”€ Home.jsx
 β”‚   β”œβ”€β”€ Dashboard.jsx
 β”‚   β”œβ”€β”€ Goals.jsx
 β”‚   └── Profile.jsx
 β”œβ”€β”€ hooks
 β”‚   β”œβ”€β”€ useAuth.js
 β”‚   └── useFetch.js
 β”œβ”€β”€ context
 β”‚   └── AuthContext.js
 β”œβ”€β”€ services
 β”‚   β”œβ”€β”€ api.js
 β”‚   └── auth.js
 β”œβ”€β”€ utils
 β”‚   β”œβ”€β”€ helpers.js
 β”‚   └── validators.js
 β”œβ”€β”€ styles
 β”‚   └── global.css
 β”œβ”€β”€ public
 β”‚   β”œβ”€β”€ index.html
 β”‚   └── favicon.ico
 β”œβ”€β”€ types
 β”‚   └── index.js
 β”œβ”€β”€ api
 β”‚   └── index.js
 β”œβ”€β”€ models
 β”‚   └── index.js
 β”œβ”€β”€ controllers
 β”‚   └── index.js
 β”œβ”€β”€ middlewares
 β”‚   └── authMiddleware.js
 β”œβ”€β”€ config
 β”‚   └── database.js
 β”œβ”€β”€ tests
 β”‚   β”œβ”€β”€ components
 β”‚   β”‚   β”œβ”€β”€ Button.test.js
 β”‚   β”‚   └── GoalForm.test.js
 β”‚   └── services
 β”‚       β”œβ”€β”€ api.test.js
 β”‚       └── auth.test.js
 β”œβ”€β”€ constants
 β”‚   └── index.js
 β”œβ”€β”€ .env
 β”œβ”€β”€ startup.sh
 └── commands.json

πŸ’» Installation

Warning

πŸ”§ Prerequisites

  • Node.js v18+
  • npm v8+
  • Basic knowledge of JavaScript and React
  • Familiarity with RESTful APIs

πŸš€ Setup Instructions

  1. Clone the repository:
    git clone https://github.com/coslynx/fitness-tracker-app.git
    cd fitness-tracker-app
  2. Install dependencies:
    npm install
  3. Create and configure the .env file:
     cp .env.example .env
    • Update environment variables in .env to match your setup.
    • REACT_APP_API_BASE_URL defaults to http://localhost:8080.
    • JWT_SECRET needs a secure key.
    • DB_* variables for database connection.

πŸ—οΈ Usage

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

  1. Start the development server:
    npm start
  2. Access the application:
    • Web interface: http://localhost:3000
    • API endpoint: http://localhost:8080/api

Tip

βš™οΈ Configuration

  • Customize API base URL in the .env file.
  • Set JWT secret for secure authentication in the .env file.
  • Modify SQLite database settings in config/database.js.
  • Run npm start to launch the development server.

πŸ“š Examples

Provide specific examples relevant to the MVP's core features:

  • πŸ“ User Registration:
    curl -X POST http://localhost:8080/api/signup \
      -H "Content-Type: application/json" \
      -d '{"email": "user@example.com", "password": "securepass123"}'
  • πŸ“ User Login:
    curl -X POST http://localhost:8080/api/login \
      -H "Content-Type: application/json" \
      -d '{"email": "user@example.com", "password": "securepass123"}'
  • πŸ“ Setting a Fitness Goal:
     curl -X POST http://localhost:8080/api/goals \
        -H "Content-Type: application/json" \
        -H "Authorization: Bearer YOUR_JWT_TOKEN" \
         -d '{"name": "Run a Marathon", "target": 42, "unit": "km", "startDate": "2024-01-01", "endDate": "2024-12-31"}'
  • πŸ“ Logging Progress:
    curl -X POST http://localhost:8080/api/progress \
        -H "Content-Type: application/json" \
        -H "Authorization: Bearer YOUR_JWT_TOKEN" \
        -d '{"goalId": 1, "value": 5, "date": "2024-01-15"}'

🌐 Hosting

πŸš€ Deployment Instructions

Provide detailed, step-by-step instructions for deploying to a suitable platform.

Deploying to a Cloud Provider (e.g., AWS, Google Cloud, or Azure)

  1. Set up a virtual server:
  • Provision a virtual machine with Node.js and npm installed.
  1. Clone the repository:
  • Use git clone to download the project to the server.
  1. Install dependencies:
  • Run npm install to set up the required packages.
  1. Configure Environment Variables:
    • Configure the .env variables in the hosting environment.
    • Ensure all variables are securely set including database credentials, and JWT secret.
  2. Build the React App:
     npm run build
  3. Start the Application:
    • Use a process manager like pm2 or systemd to run the Node.js application:
        npm run start

πŸ”‘ 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 API, e.g., http://localhost:8080 or https://api.example.com
  • JWT_SECRET: Secret key for JWT token generation, e.g., thisIsARandomSecretKeyForJWTWhichIsLongEnough
  • DB_NAME: Database name. e.g., fitness_tracker_db
  • DB_HOST: Host address for the database, e.g., localhost
  • DB_USER: Database username e.g., user
  • DB_PASSWORD: Database password, e.g., password
  • DB_PORT: Port number for the database connection, e.g., 5432

πŸ“œ API Documentation

πŸ” Endpoints

Provide a comprehensive list of all API endpoints, their methods, required parameters, and expected responses:

  • POST /api/login
    • Description: User login and token generation.
    • Body: {"email": string, "password": string}
    • Response: {"user": object, "token": string}
  • POST /api/signup
    • Description: User registration and token generation.
    • Body: {"email": string, "password": string}
    • Response: {"user": object, "token": string}
  • GET /api/goals
    • Description: Fetch all goals for the authenticated user.
    • Headers: Authorization: Bearer YOUR_JWT_TOKEN
    • Response: [{"id": number, "userId": number, "name": string, "description": string, "target": number, "unit": string, "startDate": date, "endDate": date}]
  • POST /api/goals
    • Description: Create a new fitness goal.
    • Headers: Authorization: Bearer YOUR_JWT_TOKEN
    • Body: {"name": string, "description": string, "target": number, "unit": string, "startDate": date, "endDate": date}
    • Response: {"id": number, "userId": number, "name": string, "description": string, "target": number, "unit": string, "startDate": date, "endDate": date}
  • PUT /api/goals/:id
    • Description: Update an existing goal.
    • Headers: Authorization: Bearer YOUR_JWT_TOKEN
    • Body: {"name": string, "description": string, "target": number, "unit": string, "startDate": date, "endDate": date}
    • Response: {"id": number, "userId": number, "name": string, "description": string, "target": number, "unit": string, "startDate": date, "endDate": date}
  • DELETE /api/goals/:id
    • Description: Delete a goal.
    • Headers: Authorization: Bearer YOUR_JWT_TOKEN
    • Response: 204 No Content
  • POST /api/progress
    • Description: Add progress data for a specific goal.
    • Headers: Authorization: Bearer YOUR_JWT_TOKEN
    • Body: {"goalId": number, "value": number, "date": date}
    • Response: {"id": number, "goalId": number, "value": number, "date": date}

πŸ”’ Authentication

All protected routes require a valid JWT token, which can be acquired during the login or signup process. Include the token in the Authorization header:

Authorization: Bearer YOUR_JWT_TOKEN

πŸ“ Examples

Provide examples of API usage, including request and response bodies:

# Signup user
curl -X POST http://localhost:8080/api/signup \
    -H "Content-Type: application/json" \
    -d '{"email": "testuser@example.com", "password": "securepassword123"}'

# Response
{
    "user": {
        "id": 1,
        "email": "testuser@example.com"
    },
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
# Login user
curl -X POST http://localhost:8080/api/login \
    -H "Content-Type: application/json" \
    -d '{"email": "testuser@example.com", "password": "securepassword123"}'

# Response
{
    "user": {
        "id": 1,
        "email": "testuser@example.com"
    },
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
# Create a new goal
curl -X POST http://localhost:8080/api/goals \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_JWT_TOKEN" \
    -d '{"name": "Run 5K", "target": 5, "unit": "km", "startDate": "2024-01-01", "endDate": "2024-03-31"}'

# Response
{
    "id": 1,
    "userId": 1,
    "name": "Run 5K",
    "description": null,
    "target": 5,
    "unit": "km",
    "startDate": "2024-01-01T00:00:00.000Z",
    "endDate": "2024-03-31T00:00:00.000Z"
}
# Add progress to a goal
curl -X POST http://localhost:8080/api/progress \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_JWT_TOKEN" \
    -d '{"goalId": 1, "value": 2, "date": "2024-01-15"}'
# Response
{
    "id": 1,
    "goalId": 1,
    "value": 2,
    "date": "2024-01-15T00:00:00.000Z"
}

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: fitness-tracker-app

πŸ“ž 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!