Skip to content

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

Notifications You must be signed in to change notification settings

coslynx/fit-track-social-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Fitness Tracker App

Track your fitness goals and share progress with friends.

Developed with the software and tools below.

React Frontend Node.js MongoDB
git-last-commit GitHub commit activity GitHub top language

πŸ“‘ Table of Contents

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

πŸ“ Overview

The repository contains a Minimum Viable Product (MVP) for a Fitness Tracker application. It allows users to set fitness goals, track progress, and share achievements with friends, leveraging React for the frontend and Node.js for the backend with a MongoDB database.

πŸ“¦ Features

Feature Description
πŸ”‘ Authentication Secure user registration and login using JWT for session management.
🎯 Goal Setting Users can define fitness goals, including name, description, target date, and target value.
πŸ“ˆ Progress Tracking Users can track the progress of their goals, mark goals as complete or incomplete.
πŸ“Š Dashboard Provides a user dashboard to view fitness statistics and track progress of set goals.
βš™οΈ Architecture The codebase follows a structured architecture with distinct directories for components, pages, hooks, and contexts for better maintainability.
πŸ”— Dependencies Uses essential libraries like React Router, Formik, Yup, and Axios, along with Mongoose for MongoDB interactions and jsonwebtoken and bcrypt for authentication.
🧩 Modularity Modular component design for easy updates and extensions with common components for buttons, inputs, and auth forms.
πŸ§ͺ Testing Includes basic unit tests for core components with React Testing Library.
⚑️ Performance Optimized for initial MVP launch, with consideration for future performance enhancements.
πŸ” Security Secure authentication with JWT tokens and password hashing using bcrypt.
πŸ”Œ Integrations Communicates with a Node.js backend using a RESTful API.
πŸ”€ Version Control Utilizes Git for version control with GitHub.
πŸ“Ά Scalability Designed to be scalable by using reusable components and scalable database.

πŸ“‚ Structure

src
β”œβ”€β”€ components
β”‚   β”œβ”€β”€ common
β”‚   β”‚   β”œβ”€β”€ Button.jsx
β”‚   β”‚   └── Input.jsx
β”‚   β”œβ”€β”€ auth
β”‚   β”‚   └── AuthForms.jsx
β”‚   β”œβ”€β”€ dashboard
β”‚   β”‚   └── DashboardStats.jsx
β”‚   └── goals
β”‚       └── GoalItem.jsx
β”œβ”€β”€ pages
β”‚   β”œβ”€β”€ Home.jsx
β”‚   └── Dashboard.jsx
β”œβ”€β”€ hooks
β”‚   └── useAuth.js
β”œβ”€β”€ contexts
β”‚   └── AuthContext.js
β”œβ”€β”€ services
β”‚   └── api.js
β”œβ”€β”€ utils
β”‚   └── helpers.js
└── styles
    └── global.css
public
β”œβ”€β”€ index.html
└── favicon.ico
api
β”œβ”€β”€ controllers
β”‚   β”œβ”€β”€ authController.js
β”‚   └── goalController.js
β”œβ”€β”€ models
β”‚   β”œβ”€β”€ userModel.js
β”‚   └── goalModel.js
β”œβ”€β”€ routes
β”‚   β”œβ”€β”€ authRoutes.js
β”‚   └── goalRoutes.js
β”œβ”€β”€ middlewares
β”‚   └── authMiddleware.js
└── services
    β”œβ”€β”€ authService.js
    └── goalService.js
config
    └── database.js
tests
  └── components
    └── Button.test.jsx
assets
  └── images
.env
package.json
README.md
startup.sh
commands.json

πŸ’» Installation

Warning

πŸ”§ Prerequisites

  • Node.js v18.17.1 or higher
  • npm v9.6.7 or higher
  • MongoDB v6.0 or higher
  • Git
  • Docker (optional for database)

πŸš€ Setup Instructions

  1. Clone the repository:
    git clone https://github.com/coslynx/fit-track-social-app.git
    cd fit-track-social-app
  2. Install dependencies:
    npm install
  3. Set up the database:
    • Option 1: Using Docker
      docker-compose up -d mongodb
    • Option 2: Manual Setup
      • Make sure you have MongoDB installed and running.
      • Update the VITE_DB_URL in the .env file to your MongoDB connection string.
  4. Configure environment variables:
    cp .env.example .env
    # Fill in the necessary environment variables in the .env file

πŸ—οΈ Usage

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

  1. Start the development server:
    npm run dev
  2. Start the backend server:
     # Using docker
       docker-compose up -d api
    
     # Or manually from api dir
     cd api
     npm install
     node server.js
  3. Access the application:

Tip

βš™οΈ Configuration

  • The application's configurations are managed through the .env file, which includes settings for the API base URL, JWT secret, and database connection.
  • To modify any settings, update the corresponding variables in the .env file and restart the application.
  • Make sure to use the .env.example as a template to create the .env file.

πŸ“š Examples

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

  • πŸ“ User Registration:

    curl -X POST http://localhost:3001/api/auth/register \
         -H "Content-Type: application/json" \
         -d '{"email": "user@example.com", "password": "securepass123", "name": "newuser"}'
  • πŸ“ User Login:

    curl -X POST http://localhost:3001/api/auth/login \
        -H "Content-Type: application/json" \
        -d '{"email": "user@example.com", "password": "securepass123"}'
  • πŸ“ Creating a 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": "Complete a full marathon", "targetDate": "2024-12-31", "targetValue": 26.2}'
  • πŸ“ Updating a Goal: bash curl -X PUT http://localhost:3001/api/goals/YOUR_GOAL_ID \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -d '{"completed": true}'

🌐 Hosting

πŸš€ Deployment Instructions

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

Deploying to a VPS/Cloud Server

  1. Ensure you have a VPS or cloud server running Node.js and MongoDB.
  2. Clone the repository onto the server:
    git clone https://github.com/coslynx/fit-track-social-app.git
    cd fit-track-social-app
  3. Install dependencies for both frontend and backend
     npm install
     cd api
     npm install
     cd ..
  4. Build the React frontend for production.
    npm run build
  5. Copy the dist folder from the client directory and place it in the public directory of the api folder.
  6. Set up the required environment variables in the .env file on the server.
  7. Start the server.
     cd api
     node server.js

πŸ”‘ Environment Variables

Provide a comprehensive list of all required environment variables, their purposes, and example values:

  • VITE_API_BASE_URL: Base URL for the API server. Example: http://localhost:3001/api
  • VITE_JWT_SECRET: Secret key for JWT token generation. Example: abcdefghijklmnopqrstuvwxyz123456
  • VITE_DB_URL: MongoDB connection string. Example: mongodb://localhost:27017/fitness_tracker
  • VITE_PORT: Port for the api server Example: 3001

πŸ“œ API Documentation

πŸ” Endpoints

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

  • POST /api/auth/register
    • Description: Register a new user
    • Body: { "email": string, "password": string, "name": string }
    • Response: { "success": boolean, "message": string, "user": { "id": string, "name": string, "email": string }, "token": string }
  • POST /api/auth/login
    • Description: Logs in an existing user
    • Body: { "email": string, "password": string }
    • Response: { "success": boolean, "message": string, "user": { "id": string, "name": string, "email": string }, "token": string }
  • POST /api/auth/logout
    • Description: Logs out a user
    • Response: { "success": boolean, "message": string }
  • POST /api/goals
    • Description: Creates a new goal
    • Headers: Authorization: Bearer TOKEN
    • Body: { "name": string, "description": string, "targetDate": string, "targetValue": number }
    • Response: { "success": boolean, "message": string, "data": object }
  • GET /api/goals
    • Description: Get all goals for the user
    • Headers: Authorization: Bearer TOKEN
    • Response: Array of goals
  • PUT /api/goals/:id
    • Description: Updates a specific goal
    • Headers: Authorization: Bearer TOKEN
    • Body: { "name": string, "description": string, "targetDate": string, "targetValue": number, "completed": boolean}
    • Response: { "success": boolean, "message": string, "data": object }
  • DELETE /api/goals/:id
    • Description: Deletes a specific goal
    • Headers: Authorization: Bearer TOKEN
    • Response: { "success": boolean, "message": 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
    
  3. Tokens expire after 2 hours.

πŸ“ Examples

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

# Register a new user
curl -X POST http://localhost:3001/api/auth/register \
     -H "Content-Type: application/json" \
     -d '{"email": "user@example.com", "password": "securepass123", "name": "newuser"}'

# Response
{
  "success": true,
  "message": "User registered successfully",
  "user": {
    "id": "6663e92105739a2e9127e556",
    "name": "newuser",
    "email": "user@example.com"
  },
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY2NjNlOTIxMDU3MzlhMmU5MTI3ZTU1NiIsImlhdCI6MTcxNzA0MTkwNCwiZXhwIjoxNzE3MDQ4OTA0fQ.qM_yWqg_0d_7r0y8_2T9Ue9c_2h_6j_8i_0Q_3v_1_c"
}

# Login an existing user
curl -X POST http://localhost:3001/api/auth/login \
     -H "Content-Type: application/json" \
     -d '{"email": "user@example.com", "password": "securepass123"}'

# Response
{
    "success": true,
    "message": "Login successful",
    "user": {
        "id": "6663e92105739a2e9127e556",
        "name": "newuser",
        "email": "user@example.com"
    },
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY2NjNlOTIxMDU3MzlhMmU5MTI3ZTU1NiIsImlhdCI6MTcxNzA0MTk1MSwiZXhwIjoxNzE3MDQ4OTUxfQ.WdZ7uI1W017_3_Yp0g7_6_lU8R_3yT_6_2Z_zU_9_5_k"
}

# 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": "Complete a full marathon", "targetDate": "2024-12-31", "targetValue": 26.2}'

# Response
{
    "success": true,
    "message": "Goal created successfully",
    "data": {
        "userId": "6663e92105739a2e9127e556",
        "name": "Run a Marathon",
        "description": "Complete a full marathon",
        "targetDate": "2024-12-31T00:00:00.000Z",
        "targetValue": 26.2,
        "completed": false,
        "createdAt": "2024-06-08T15:20:13.618Z",
        "updatedAt": "2024-06-08T15:20:13.618Z",
        "id": "6663e93d05739a2e9127e557"
    }
}

[Add more examples covering all major API functionalities]

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-track-social-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!