Skip to content

Track fitness goals, set progress, share achievements with friends... Created at https://coslynx.com

Notifications You must be signed in to change notification settings

coslynx/Fitness-Tracker-Social-Goals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

55 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Fitness Tracker

A web application that empowers users to easily track their fitness goals, monitor progress, and share achievements with friends.

Developed with the software and tools below.

git-last-commit GitHub commit activity GitHub top language

πŸ“‘ Table of Contents

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

πŸ“ Overview

This repository houses the Minimum Viable Product (MVP) for a Fitness Tracker web application, designed to help users set and track their fitness goals, monitor progress, and connect with friends. The application leverages a robust tech stack, including Next.js, React, TypeScript, and Node.js, for a fast, engaging, and user-friendly experience.

πŸ“¦ Features

Feature Description
πŸ” User Authentication Users can securely register and log in using their email and password or through social logins (e.g., Google, Facebook).
🎯 Goal Setting Users can create personalized fitness goals with specific titles, targets, and deadlines.
πŸ“ˆ Progress Tracking Users can log their workouts, including type, duration, and date, to track their progress towards their goals.
πŸ“Š Progress Visualization The application provides visual representations of progress with charts and graphs, offering insightful data.
🀝 Social Sharing Users can connect with friends, share their achievements, and provide support and motivation.
βš™οΈ Architecture The codebase follows a modular architectural pattern, ensuring easier maintenance and scalability.
πŸ“„ Documentation The repository includes a README file that provides a detailed overview of the MVP, its dependencies, and usage instructions.
πŸ”— Dependencies The codebase relies on various external libraries and packages such as Next.js, React, Zustand, Prisma ORM, and others, which are essential for building and styling the UI components, managing state, and handling database interactions.
🧩 Modularity The modular structure allows for easier maintenance and reusability of the code, with separate directories and files for different functionalities such as background, components, and content.
πŸ§ͺ Testing Unit tests are implemented using frameworks like Jest or React Testing Library to ensure the reliability and robustness of the codebase.
⚑️ Performance Performance optimization is implemented to improve loading times and user experience. The system can be further optimized based on factors such as the browser and hardware being used.
πŸ” Security Security is a top priority, with measures like input validation, data encryption, and secure communication protocols implemented.
πŸ”€ Version Control Utilizes Git for version control with GitHub Actions workflow files for automated build and release processes.
πŸ”Œ Integrations The application integrates with external services through HTTP requests. It also interacts with browser APIs.
πŸ“Ά Scalability The system is designed to handle increased user load and data volume, utilizing caching strategies and cloud-based solutions for better scalability.
    ## πŸ“‚ Structure
    ```text
    fitness-tracker/
    β”œβ”€β”€ public
    β”‚   β”œβ”€β”€ images
    β”‚   β”‚   └── logo.png
    β”‚   β”œβ”€β”€ favicon.ico
    β”‚   └── robots.txt
    β”œβ”€β”€ pages
    β”‚   β”œβ”€β”€ api
    β”‚   β”‚   β”œβ”€β”€ auth
    β”‚   β”‚   β”‚   └── [...nextauth].js
    β”‚   β”‚   β”œβ”€β”€ goals
    β”‚   β”‚   β”‚   └── route.ts
    β”‚   β”‚   └── progress
    β”‚   β”‚       └── route.ts
    β”‚   β”œβ”€β”€ index.js
    β”‚   β”œβ”€β”€ dashboard
    β”‚   β”‚   └── page.tsx
    β”‚   β”œβ”€β”€ goals
    β”‚   β”‚   └── page.tsx
    β”‚   └── profile
    β”‚       └── page.tsx
    β”œβ”€β”€ components
    β”‚   β”œβ”€β”€ common
    β”‚   β”‚   β”œβ”€β”€ Button.tsx
    β”‚   β”‚   β”œβ”€β”€ Input.tsx
    β”‚   β”‚   └── Modal.tsx
    β”‚   └── layout
    β”‚       β”œβ”€β”€ Header.tsx
    β”‚       └── Footer.tsx
    β”œβ”€β”€ lib
    β”‚   β”œβ”€β”€ api
    β”‚   β”‚   └── client.ts
    β”‚   └── utils
    β”‚       └── formatters.ts
    β”œβ”€β”€ .eslintrc.js
    β”œβ”€β”€ next.config.js
    β”œβ”€β”€ prisma
    β”‚   β”œβ”€β”€ schema.prisma
    β”‚   β”œβ”€β”€ migrations
    β”‚   β”‚   └── _Rollbacks
    β”‚   β”‚       └── 20231026123456_init.sql
    β”‚   └── migrations
    β”‚       └── 20231026123456_init
    β”‚           └── migration.sql
    β”œβ”€β”€ .env
    └── tests
        β”œβ”€β”€ components
        β”‚   β”œβ”€β”€ common
        β”‚   β”‚   β”œβ”€β”€ Button.test.tsx
        β”‚   β”‚   β”œβ”€β”€ Input.test.tsx
        β”‚   β”‚   └── Modal.test.tsx
        β”‚   └── layout
        β”‚       β”œβ”€β”€ Header.test.tsx
        β”‚       └── Footer.test.tsx
        β”œβ”€β”€ pages
        β”‚   β”œβ”€β”€ index.test.js
        β”‚   β”œβ”€β”€ dashboard
        β”‚   β”‚   └── page.test.tsx
        β”‚   β”œβ”€β”€ goals
        β”‚   β”‚   └── page.test.tsx
        β”‚   └── profile
        β”‚       └── page.test.tsx
        β”œβ”€β”€ lib
        β”‚   β”œβ”€β”€ api
        β”‚   β”‚   └── client.test.ts
        β”‚   └── utils
        β”‚       └── formatters.test.ts
        β”œβ”€β”€ services
        β”‚   β”œβ”€β”€ api.test.ts
        β”‚   └── auth.test.ts
        └── hooks
            └── useAuth.test.ts
    ```
  
    ## πŸ’» Installation
      ### πŸ”§ Prerequisites
      - Node.js v18+
      - npm 6+ or yarn
      - PostgreSQL 13+
      
      ### πŸš€ Setup Instructions
      1. Clone the repository:
         ```bash
         git clone https://github.com/coslynx/Fitness-Tracker.git
         cd Fitness-Tracker
         ```
      2. Install dependencies:
         ```bash
         npm install
         ```
      3. Set up the database:
         ```bash
         npx prisma generate
         npx prisma db push 
         ```
      4. Configure environment variables:
         ```bash
         cp .env.example .env
         [Instruct to fill in necessary environment variables, including DATABASE_URL, NEXTAUTH_URL, NEXTAUTH_SECRET, and any other required variables. For example:]
         # NextAuth.js Configuration
         NEXTAUTH_URL=http://localhost:3000
         NEXTAUTH_SECRET=your_strong_secret_key

         # Database Connection
         DATABASE_URL=postgres://username:password@host:port/database
         ```
      
      ## πŸ—οΈ Usage
      ### πŸƒβ€β™‚οΈ Running the MVP
      1. Start the development server:
         ```bash
         npm run dev
         ```
      
      3. Access the application:
         - Web interface: [http://localhost:3000](http://localhost:3000)
         - API endpoint: [http://localhost:3000/api](http://localhost:3000/api)
      
      ### βš™οΈ Configuration
      - The primary configuration file is `next.config.js` which contains settings for Next.js, including:
          - Environment variables
          - Image handling
          - Experimental features 
      - Other configuration files such as `tailwind.config.js` for styling and `prisma/schema.prisma` for database schema are also crucial for the project. 
      
      ### πŸ“š Examples
      Provide specific examples relevant to the MVP's core features. For instance:
      
      - πŸ“ **User Registration**: 
        ```bash
        curl -X POST http://localhost:3000/api/auth/signup               -H "Content-Type: application/json"               -d '{"email": "user@example.com", "password": "securepass123"}'
        ```
      
      - πŸ“ **Setting a Fitness Goal**: 
        ```bash
        curl -X POST http://localhost:3000/api/goals               -H "Content-Type: application/json"               -H "Authorization: Bearer YOUR_JWT_TOKEN"               -d '{"title": "Lose 10 lbs", "target": 150, "userId": 1}'
        ```
      
      - πŸ“ **Logging Progress**: 
        ```bash
        curl -X POST http://localhost:3000/api/progress               -H "Content-Type: application/json"               -H "Authorization: Bearer YOUR_JWT_TOKEN"               -d '{"type": "Running", "date": "2023-06-15", "duration": 30, "goalId": 1, "userId": 1}'
        ```
      
      ## 🌐 Hosting
      ### πŸš€ Deployment Instructions
      Provide detailed, step-by-step instructions for deploying to the most suitable platform for this MVP. For example:
      
      #### Deploying to Vercel
      1. Install the Vercel CLI:
         ```bash
         npm install -g vercel
         ```
      2. Login to Vercel:
         ```bash
         vercel login
         ```
      3. Deploy the code:
         ```bash
         vercel
         ```
      4. Set up environment variables:
         ```bash
         vercel env [environment-name] [variable-name]=[value] 
         ```
      5. Run database migrations (if applicable):
         ```bash
         vercel run [environment-name] npm run migrate
         ```
      
      ### πŸ”‘ Environment Variables
      Provide a comprehensive list of all required environment variables, their purposes, and example values:
      
      - `DATABASE_URL`: Connection string for the PostgreSQL database
        Example: `postgresql://user:password@host:port/database`
      - `NEXTAUTH_URL`: The URL of your Next.js application
        Example: `http://localhost:3000`
      - `NEXTAUTH_SECRET`: Secret key for NextAuth.js authentication 
        Example: `your-256-bit-secret`
      - `SENTRY_DSN`: DSN for Sentry error tracking 
        Example: `https://YOUR_DSN@sentry.io/PROJECT_ID`
      - `HOTJAR_ID`: ID for Hotjar user behavior analysis
        Example: `your_hotjar_id`
      
      ## πŸ“œ API Documentation
      ### πŸ” Endpoints
      Provide a comprehensive list of all API endpoints, their methods, required parameters, and expected responses. For example:
      
      - **POST /api/auth/signup**
        - Description: Register a new user
        - Body: `{ "email": string, "password": string }`
        - Response: `{ "id": string, "email": string, "token": string }`
      
      - **POST /api/goals**
        - Description: Create a new fitness goal
        - Headers: `Authorization: Bearer TOKEN`
        - Body: `{ "title": string, "target": number, "userId": number }`
        - Response: `{ "id": string, "title": string, "target": number, "userId": number }`
      
      - **GET /api/goals**
        - Description: Get a list of all goals for the current user
        - Headers: `Authorization: Bearer TOKEN`
        - Response: `[{ "id": string, "title": string, "target": number, "userId": number }]`
      
      - **GET /api/progress**
        - Description: Get a list of user's activities
        - Headers: `Authorization: Bearer TOKEN`
        - Query Parameters:
            - `userId`: User ID
            - `goalId`: (Optional) Goal ID to filter by
            - `startDate`: (Optional) Start date to filter activities (YYYY-MM-DD)
            - `endDate`: (Optional) End date to filter activities (YYYY-MM-DD)
        - Response: `[{ "id": string, "type": string, "date": date, "duration": number, "goalId": number, "userId": number }]`
      
      - **POST /api/progress**
        - Description: Add a new activity log
        - Headers: `Authorization: Bearer TOKEN`
        - Body: `{ "type": string, "date": date, "duration": number, "goalId": number, "userId": number }`
        - Response: `{ "id": string, "type": string, "date": date, "duration": number, "goalId": number, "userId": number }`
      
      ### πŸ”’ 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:
      
      ```bash
      # Register a new user
      curl -X POST http://localhost:3000/api/auth/signup             -H "Content-Type: application/json"             -d '{"email": "fitnessuser@example.com", "password": "securepass123"}'
      
      # Response
      {
        "id": "user123",
        "email": "fitnessuser@example.com",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
      }
      
      # Create a new goal
      curl -X POST http://localhost:3000/api/goals             -H "Content-Type: application/json"             -H "Authorization: Bearer YOUR_JWT_TOKEN"             -d '{"title": "Lose 10 lbs", "target": 150, "userId": 1}'
      
      # Response
      {
        "id": "goal123",
        "title": "Lose 10 lbs",
        "target": 150,
        "userId": 1
      }
      
      # Get a list of goals for the current user
      curl -X GET http://localhost:3000/api/goals             -H "Authorization: Bearer YOUR_JWT_TOKEN"
      
      # Response
      [
        {
          "id": "goal123",
          "title": "Lose 10 lbs",
          "target": 150,
          "userId": 1
        },
        {
          "id": "goal456",
          "title": "Run 5km daily",
          "target": 30,
          "userId": 1
        }
      ]
      
      # Log a new activity
      curl -X POST http://localhost:3000/api/progress             -H "Content-Type: application/json"             -H "Authorization: Bearer YOUR_JWT_TOKEN"             -d '{"type": "Running", "date": "2023-06-15", "duration": 30, "goalId": 1, "userId": 1}'
      
      # Response
      {
        "id": "activity789",
        "type": "Running",
        "date": "2023-06-15",
        "duration": 30,
        "goalId": 1,
        "userId": 1
      }
      ```
      
      ## πŸ“œ License & Attribution

      ### πŸ“„ License
      This Minimum Viable Product (MVP) is licensed under the [GNU AGPLv3](https://choosealicense.com/licenses/agpl-3.0/) license.
      
      ### πŸ€– AI-Generated MVP
      This MVP was entirely generated using artificial intelligence through [CosLynx.com](https://coslynx.com).
      
      No human was directly involved in the coding process of the repository: Fitness-Tracker
    
      ### πŸ“ž Contact
      For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:
      - Website: [CosLynx.com](https://coslynx.com)
      - Twitter: [@CosLynxAI](https://x.com/CosLynxAI)

      <p align="center">
        <h1 align="center">🌐 CosLynx.com</h1>
      </p>
      <p align="center">
        <em>Create Your Custom MVP in Minutes With CosLynxAI!</em>
      </p>
      <div class="badges" align="center">
      <img src="https://img.shields.io/badge/Developers-Drix10,_Kais_Radwan-red" alt="">
      <img src="https://img.shields.io/badge/Website-CosLynx.com-blue" alt="">
      <img src="https://img.shields.io/badge/Backed_by-Google,_Microsoft_&_Amazon_for_Startups-red" alt="">
      <img src="https://img.shields.io/badge/Finalist-Backdrop_Build_v4,_v6-black" alt="">
      </div>