Skip to content

coslynx/fitness-tracker-goal-setter-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

62 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

fitness-tracker-goal-setter-app

A web application to track your fitness journey and set achievable goals.

Developed with the software and tools below.

Framework: Next.js Frontend: TypeScript, React, HTML, CSS Backend: Node.js Database: PostgreSQL
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) called "fitness-tracker-goal-setter-app" that empowers fitness enthusiasts to track their progress, set achievable goals, and connect with a supportive community. Built with Next.js, React, TypeScript, and a robust backend powered by Node.js and PostgreSQL, this MVP offers a user-friendly and engaging experience.

πŸ“¦ Features

Feature Description
βš™οΈ Architecture The codebase follows a modular architectural pattern with separate directories for different functionalities, 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 React, uuid, esbuild, and eslint, which are essential for building and styling the UI components, and handling external services.
🧩 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 Implement unit tests using frameworks like Jest or React Testing Library to ensure the reliability and robustness of the codebase.
⚑️ Performance The performance of the system can be optimized based on factors such as the browser and hardware being used. Consider implementing performance optimizations for better efficiency.
πŸ” Security Enhance security by implementing measures such as input validation, data encryption, and secure communication protocols.
πŸ”€ Version Control Utilizes Git for version control with GitHub Actions workflow files for automated build and release processes.
πŸ”Œ Integrations Interacts with browser APIs, external services through HTTP requests, and includes integrations with speech recognition and synthesis APIs.
πŸ“Ά Scalability Design the system to handle increased user load and data volume, utilizing caching strategies and cloud-based solutions for better scalability.

πŸ“‚ Structure

fitness-tracker-goal-setter-app/
β”œβ”€β”€ .env
β”œβ”€β”€ .env.example
β”œβ”€β”€ next.config.js
β”œβ”€β”€ tailwind.config.js
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ prisma
β”‚   β”œβ”€β”€ schema.prisma
β”‚   └── migrations
β”œβ”€β”€ public
β”‚   └── images
β”œβ”€β”€ pages
β”‚   β”œβ”€β”€ api
β”‚   β”‚   β”œβ”€β”€ auth
β”‚   β”‚   β”‚   └── [...nextauth].ts
β”‚   β”‚   β”œβ”€β”€ goals
β”‚   β”‚   β”‚   β”œβ”€β”€ [id].ts
β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”œβ”€β”€ progress
β”‚   β”‚   β”‚   β”œβ”€β”€ [id].ts
β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”œβ”€β”€ users
β”‚   β”‚   β”‚   β”œβ”€β”€ [id].ts
β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   └── webhooks
β”‚   β”‚       └── stripe.ts
β”‚   β”œβ”€β”€ _app.tsx
β”‚   β”œβ”€β”€ _document.tsx
β”‚   β”œβ”€β”€ index.tsx
β”‚   β”œβ”€β”€ dashboard.tsx
β”‚   β”œβ”€β”€ goals.tsx
β”‚   β”œβ”€β”€ progress.tsx
β”‚   β”œβ”€β”€ community.tsx
β”‚   └── settings.tsx
β”œβ”€β”€ components
β”‚   β”œβ”€β”€ layout
β”‚   β”‚   β”œβ”€β”€ Header.tsx
β”‚   β”‚   β”œβ”€β”€ Footer.tsx
β”‚   β”‚   β”œβ”€β”€ Sidebar.tsx
β”‚   β”‚   └── Layout.tsx
β”‚   β”œβ”€β”€ ui
β”‚   β”‚   β”œβ”€β”€ Button.tsx
β”‚   β”‚   β”œβ”€β”€ Card.tsx
β”‚   β”‚   β”œβ”€β”€ Modal.tsx
β”‚   β”‚   β”œβ”€β”€ Input.tsx
β”‚   β”‚   β”œβ”€β”€ Select.tsx
β”‚   β”‚   └── Spinner.tsx
β”‚   └── features
β”‚       β”œβ”€β”€ auth
β”‚       β”‚   β”œβ”€β”€ LoginForm.tsx
β”‚       β”‚   └── SignupForm.tsx
β”‚       β”œβ”€β”€ goals
β”‚       β”‚   β”œβ”€β”€ GoalCard.tsx
β”‚       β”‚   β”œβ”€β”€ GoalForm.tsx
β”‚       β”‚   └── GoalList.tsx
β”‚       β”œβ”€β”€ progress
β”‚       β”‚   β”œβ”€β”€ ProgressChart.tsx
β”‚       β”‚   └── ProgressLog.tsx
β”‚       β”œβ”€β”€ dashboard
β”‚       β”‚   β”œβ”€β”€ DashboardStats.tsx
β”‚       β”‚   └── RecentActivity.tsx
β”‚       └── community
β”‚           β”œβ”€β”€ CommunityFeed.tsx
β”‚           └── UserProfile.tsx
β”œβ”€β”€ lib
β”‚   β”œβ”€β”€ api
β”‚   β”‚   └── client.ts
β”‚   β”œβ”€β”€ hooks
β”‚   β”‚   β”œβ”€β”€ useUser.ts
β”‚   β”‚   └── useGoals.ts
β”‚   └── utils
β”‚       β”œβ”€β”€ formatters.ts
β”‚       β”œβ”€β”€ validators.ts
β”‚       └── calculations.ts
β”œβ”€β”€ styles
β”‚   β”œβ”€β”€ globals.css
β”‚   └── theme.ts
β”œβ”€β”€ types
β”‚   β”œβ”€β”€ goal.ts
β”‚   β”œβ”€β”€ progress.ts
β”‚   └── user.ts
β”œβ”€β”€ context
β”‚   β”œβ”€β”€ AuthContext.tsx
β”‚   └── ThemeContext.tsx
β”œβ”€β”€ services
β”‚   β”œβ”€β”€ goalService.ts
β”‚   β”œβ”€β”€ progressService.ts
β”‚   └── userService.ts
└── package.json

πŸ’» Installation

πŸ”§ Prerequisites

  • Node.js v18+
  • npm 8+
  • PostgreSQL 14+
  • Docker 20.10+

πŸš€ Setup Instructions

  1. Clone the repository:
    git clone https://github.com/coslynx/fitness-tracker-goal-setter-app.git
    cd fitness-tracker-goal-setter-app
  2. Install dependencies:
    npm install
  3. Create a .env file for environment variables:
    cp .env.example .env
    Fill in the required environment variables in the .env file.
  4. Set up the PostgreSQL database:
  • Install PostgreSQL on your machine if you haven't already.
  • Create a new database.
  • Set the DATABASE_URL environment variable in your .env file to connect to your database.
  1. Run database migrations:
    npm run migrate
  2. Start the development server:
    npm run dev
    Access the application in your browser at http://localhost:3000.

πŸ—οΈ Usage

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

  • Start the development server:
    npm run dev
  • Access the application in your browser at http://localhost:3000.

βš™οΈ Configuration

  • next.config.js: Configures Next.js for optimal performance and development settings.
  • tailwind.config.js: Customizes Tailwind CSS for the application's visual style.
  • tsconfig.json: Configures the TypeScript compiler for type checking and code generation.
  • .env: Stores environment variables specific to your development and production environments.

πŸ“š Examples

  • User Registration
    curl -X POST http://localhost:3000/api/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:3000/api/goals \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer YOUR_JWT_TOKEN" \
      -d '{"type": "weight_loss", "target": 10, "deadline": "2023-12-31"}' 
  • Logging Progress
    curl -X POST http://localhost:3000/api/progress \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer YOUR_JWT_TOKEN" \
      -d '{"goalId": "goal_id_here", "value": 2, "date": "2023-06-15"}'

🌐 Hosting

πŸš€ Deployment Instructions

Deploying to Vercel

  1. Create a Vercel account and install the Vercel CLI:
    npm install -g vercel
  2. Login to Vercel:
    vercel login
  3. Initialize a Vercel project:
    vercel init fitness-tracker-goal-setter-app
    Follow the prompts to configure your project.
  4. Deploy to Vercel:
    vercel deploy

πŸ”‘ Environment Variables

  • DATABASE_URL: Connection string for your PostgreSQL database (e.g., postgresql://user:password@host:port/database_name)
  • NEXTAUTH_URL: Your application's URL (e.g., https://your-app.vercel.app)
  • NEXTAUTH_SECRET: A random 32-character string for secure authentication (generate a unique secret using openssl rand -base64 32)
  • [Add any other environment variables specific to your MVP]

πŸ“œ API Documentation

πŸ” Endpoints

  • POST /api/auth/register
    • Description: Registers a new user.
    • Body: { "username": string, "email": string, "password": string }
    • Response: { "id": string, "username": string, "email": string, "token": string }
  • POST /api/auth/login
    • Description: Logs in an existing user.
    • Body: { "email": string, "password": string }
    • Response: { "id": string, "username": string, "email": string, "token": string }
  • GET /api/auth/session
    • Description: Fetches the current user session.
    • Response: { "user": { "id": string, "username": string, "email": string }, "expires": string }
  • POST /api/goals
    • Description: Creates a new fitness goal.
    • Headers: Authorization: Bearer TOKEN
    • Body: { "type": string, "target": number, "deadline": date }
    • Response: { "id": string, "type": string, "target": number, "deadline": date, "progress": number }
  • GET /api/goals
    • Description: Fetches all goals for the current user.
    • Headers: Authorization: Bearer TOKEN
    • Response: [{ "id": string, "type": string, "target": number, "deadline": date, "progress": number }]
  • GET /api/goals/:id
    • Description: Fetches a specific goal by its ID.
    • Headers: Authorization: Bearer TOKEN
    • Response: { "id": string, "type": string, "target": number, "deadline": date, "progress": number }
  • PUT /api/goals/:id
    • Description: Updates an existing goal.
    • Headers: Authorization: Bearer TOKEN
    • Body: { "type": string, "target": number, "deadline": date, "progress": number }
    • Response: { "id": string, "type": string, "target": number, "deadline": date, "progress": number }
  • DELETE /api/goals/:id
    • Description: Deletes a goal by its ID.
    • Headers: Authorization: Bearer TOKEN
    • Response: {}
  • POST /api/progress
    • Description: Creates a new progress entry for a goal.
    • Headers: Authorization: Bearer TOKEN
    • Body: { "goalId": string, "value": number, "date": date }
    • Response: { "id": string, "goalId": string, "value": number, "date": date }
  • GET /api/progress
    • Description: Fetches all progress entries for the current user.
    • Headers: Authorization: Bearer TOKEN
    • Response: [{ "id": string, "goalId": string, "value": number, "date": date }]
  • GET /api/progress/:id
    • Description: Fetches a specific progress entry by its ID.
    • Headers: Authorization: Bearer TOKEN
    • Response: { "id": string, "goalId": string, "value": number, "date": date }
  • PUT /api/progress/:id
    • Description: Updates an existing progress entry.
    • Headers: Authorization: Bearer TOKEN
    • Body: { "goalId": string, "value": number, "date": date }
    • Response: { "id": string, "goalId": string, "value": number, "date": date }
  • DELETE /api/progress/:id
    • Description: Deletes a progress entry by its ID.
    • Headers: Authorization: Bearer TOKEN
    • Response: {}

πŸ”’ Authentication

  1. Registration and Login: Use the /api/auth/register and /api/auth/login endpoints to register a new user or log in to an existing account. Upon successful authentication, you'll receive a JWT token.
  2. Authentication Header: Include the JWT token in the Authorization header for all protected API routes:
    Authorization: Bearer YOUR_JWT_TOKEN
    
  3. Session Management: The Authorization header is used to authenticate each request and ensure that only authenticated users can access protected data or resources.

πŸ“ Examples

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

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

# Fetch the current user session (after login)
curl -X GET http://localhost:3000/api/auth/session \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

# Create a new goal
curl -X POST http://localhost:3000/api/goals \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{"type": "weight_loss", "target": 10, "deadline": "2023-12-31"}' 

πŸ“œ 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-goal-setter-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!