Skip to content

coslynx/fit-track-goals-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Fitness Tracker App

Track your fitness goals with ease, set, achieve and share 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 Fitness Tracker App is a web application designed to help fitness enthusiasts easily track their goals. This MVP is built using React for the frontend and Node.js for the backend, utilizing MongoDB for data storage, it enables users to set fitness goals, monitor their progress, and share achievements with their friends.

πŸ“¦ Features

Feature Description
πŸ”’ User Authentication Secure user authentication using JWT (JSON Web Tokens) for protected routes and user data management.
🎯 Goal Setting Users can create and manage their fitness goals, including setting titles, descriptions, and target dates.
πŸ“ˆ Progress Tracking Users can log and track their progress towards their fitness goals, with features to view progress over time.
πŸ“± Social Sharing Users can share their achievements and progress with friends via social media.
βš™οΈ Architecture The app is built with a modular architecture, separating frontend and backend functionalities for easier maintenance and scalability.
πŸ”— Dependencies Utilizes libraries like axios for API requests, react-router-dom for routing, mongoose for MongoDB interactions, and bcrypt for password hashing.
πŸ›‘οΈ Security Implements robust security practices, including password hashing and JWT-based authentication.
πŸ—„οΈ Database Leverages MongoDB Atlas for cloud-based database management, ensuring scalable and reliable data storage.
⚑️ Performance Optimizes data fetching and API calls using caching and efficient database queries.
🧩 Modularity The codebase is structured in a modular way to maintain clean and reusable code and enhance maintainability.

πŸ“‚ Structure

    β”œβ”€β”€ README.md
    β”œβ”€β”€ .gitignore
    β”œβ”€β”€ package.json
    β”œβ”€β”€ public
    β”‚   β”œβ”€β”€ index.html
    β”‚   └── favicon.ico
    β”œβ”€β”€ src
    β”‚   β”œβ”€β”€ components
    β”‚   β”‚   β”œβ”€β”€ Button.jsx
    β”‚   β”‚   β”œβ”€β”€ Input.jsx
    β”‚   β”‚   β”œβ”€β”€ Modal.jsx
    β”‚   β”‚   β”œβ”€β”€ AuthForm.jsx
    β”‚   β”‚   β”œβ”€β”€ GoalCard.jsx
    β”‚   β”‚   β”œβ”€β”€ Header.jsx
    β”‚   β”‚   └── Footer.jsx
    β”‚   β”œβ”€β”€ pages
    β”‚   β”‚   β”œβ”€β”€ Home.jsx
    β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx
    β”‚   β”‚   └── Goals.jsx
    β”‚   β”œβ”€β”€ hooks
    β”‚   β”‚   β”œβ”€β”€ useAuth.js
    β”‚   β”‚   └── useFetch.js
    β”‚   β”œβ”€β”€ context
    β”‚   β”‚   └── AuthContext.js
    β”‚   β”œβ”€β”€ services
    β”‚   β”‚   β”œβ”€β”€ api.js
    β”‚   β”‚   └── auth.js
    β”‚   β”œβ”€β”€ utils
    β”‚   β”‚   └── helpers.js
    β”‚   └── styles
    β”‚       └── global.css
    └── api
        β”œβ”€β”€ controllers
        β”‚   β”œβ”€β”€ authController.js
        β”‚   └── goalController.js
        β”œβ”€β”€ models
        β”‚   β”œβ”€β”€ User.js
        β”‚   └── Goal.js
        β”œβ”€β”€ services
        β”‚   β”œβ”€β”€ authService.js
        β”‚   └── goalService.js
        β”œβ”€β”€ middlewares
        β”‚   └── authMiddleware.js
        β”œβ”€β”€ config
        β”‚   └── db.js
        └── routes
            β”œβ”€β”€ authRoutes.js
            └── goalRoutes.js
    β”œβ”€β”€ .env
    └── startup.sh

πŸ’» Installation

Warning

πŸ”§ Prerequisites

  • Node.js v18.16.0 or higher
  • npm v9.5.1 or higher
  • MongoDB Atlas account

πŸš€ 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. Configure environment variables:
    cp .env.example .env
    • Fill in the .env file with your MongoDB connection URI, JWT secret, and other necessary configurations.
        # Port for the server to listen on
        PORT=3001
      
        # MongoDB connection URI
        MONGODB_URI=mongodb+srv://<username>:<password>@<cluster>/<database>?retryWrites=true&w=majority
      
        # Secret key for JWT token generation
        JWT_SECRET=thisisasecretkeyforjwt
      
        # JWT token expiration time
        JWT_EXPIRES_IN=1d

πŸ—οΈ Usage

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

  1. Start the development server:
    npm run dev
  2. Access the application:

Tip

βš™οΈ Configuration

  • The app uses environment variables for configuration, mainly set in .env file.
  • API base URL is configured in /src/services/api.js file.
  • Default port is set to 3001 and UI is served from port 3000, make sure that ports are not conflicting with other services.

πŸ“š 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 '{"username": "newuser", "email": "user@example.com", "password": "securepass123"}'
  • πŸ“ User Login:

    curl -X POST http://localhost:3001/api/auth/login -H "Content-Type: application/json" -d '{"email": "user@example.com", "password": "securepass123"}'
  • πŸ“ Create a Goal:

    curl -X POST http://localhost:3001/api/goals -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_JWT_TOKEN" -d '{"title": "Run a Marathon", "description": "Complete a full marathon in under 4 hours.", "targetDate": "2024-12-31", "progress": 0}'

🌐 Hosting

πŸš€ Deployment Instructions

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

Deploying to Render

  1. Create a new Web Service on Render.
  2. Connect your GitHub repository.
  3. Configure the build command: npm install && npm run build --prefix src
  4. Set the start command: node server.js
  5. Configure environment variables:
    • Add all variables defined in .env file.
  6. Deploy the app.

πŸ”‘ Environment Variables

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

  • PORT: Port for the server to listen on. Example: 3001
  • MONGODB_URI: Connection string for the MongoDB database. Example: mongodb+srv://<username>:<password>@<cluster>/<database>?retryWrites=true&w=majority
  • JWT_SECRET: Secret key for JWT token generation. Example: thisisasecretkeyforjwt
  • JWT_EXPIRES_IN: JWT token expiration time. Example: 1d

πŸ“œ 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: { "username": string, "email": string, "password": string }
    • Response: { "username": string, "email": string, "id": string, "createdAt": string, "updatedAt": string }
  • POST /api/auth/login
    • Description: Logs in a user and returns a JWT token
    • Body: {"email": string, "password": string}
    • Response: { "message": string, "token": string, "user": { "username": string, "email": string, "id": string, "createdAt": string, "updatedAt": string }}
  • POST /api/goals
    • Description: Create a new fitness goal
    • Headers: Authorization: Bearer TOKEN
    • Body: { "title": string, "description": string, "targetDate": date, "progress": number }
    • Response: { "_id": string, "userId": string, "title": string, "description": string, "targetDate": date, "progress": number, "createdAt": string, "updatedAt": string }
  • GET /api/goals/:goalId
    • Description: Get a goal by its ID
    • Headers: Authorization: Bearer TOKEN
    • Response: { "_id": string, "userId": string, "title": string, "description": string, "targetDate": date, "progress": number, "createdAt": string, "updatedAt": string }
  • PUT /api/goals/:goalId
    • Description: Updates a goal by its ID
    • Headers: Authorization: Bearer TOKEN
    • Body: { "title": string, "description": string, "targetDate": date, "progress": number }
    • Response: { "_id": string, "userId": string, "title": string, "description": string, "targetDate": date, "progress": number, "createdAt": string, "updatedAt": string }
  • DELETE /api/goals/:goalId
    • Description: Deletes a goal by its ID
    • Headers: Authorization: Bearer TOKEN
    • Response: { "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. The token expires based on the JWT_EXPIRES_IN setting, which is 1 day by default.

πŸ“ 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 '{"username": "fitnessuser", "email": "user@example.com", "password": "securepass123"}'
# Response
{
  "username": "fitnessuser",
  "email": "user@example.com",
  "id": "666e4a5989977f4298765d3c",
  "createdAt": "2024-06-17T14:07:05.127Z",
  "updatedAt": "2024-06-17T14:07:05.127Z"
}

# Login a user
curl -X POST http://localhost:3001/api/auth/login  -H "Content-Type: application/json"  -d '{"email": "user@example.com", "password": "securepass123"}'
# Response
{
    "message": "Login successful",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NjZlND...",
    "user": {
        "username": "fitnessuser",
        "email": "user@example.com",
        "id": "666e4a5989977f4298765d3c",
        "createdAt": "2024-06-17T14:07:05.127Z",
        "updatedAt": "2024-06-17T14:07:05.127Z"
    }
}

# Create a new goal
curl -X POST http://localhost:3001/api/goals -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_JWT_TOKEN" -d '{"title": "Run a Marathon", "description": "Complete a full marathon in under 4 hours.", "targetDate": "2024-12-31", "progress": 0}'
# Response
{
  "_id": "666e4a7889977f4298765d3d",
  "userId": "666e4a5989977f4298765d3c",
  "title": "Run a Marathon",
  "description": "Complete a full marathon in under 4 hours.",
  "targetDate": "2024-12-31T00:00:00.000Z",
  "progress": 0,
  "createdAt": "2024-06-17T14:07:36.231Z",
  "updatedAt": "2024-06-17T14:07:36.231Z"
}

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!