Skip to content

yuhuan130/health_tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Health Tracker Application

A comprehensive full-stack health tracking application built with React and Node.js that helps users monitor and manage their health metrics, set goals, and visualize their progress.

Features

πŸ₯ Health Data Tracking

  • Weight Monitoring: Track your weight over time with historical records
  • Nutrition Logging: Record meals with detailed macronutrient information (calories, protein, carbs, fat)
  • Exercise Tracking: Log workouts with duration, calories burned, and distance
  • Sleep Monitoring: Track sleep duration and quality
  • Vital Signs: Record blood pressure, heart rate, and body temperature

πŸ“Š Analytics & Visualization

  • Interactive charts showing weight trends, nutrition patterns, and exercise activity
  • Dashboard with real-time health metrics overview
  • BMI calculation and categorization
  • Progress tracking with visual indicators

🎯 Goal Management

  • Create custom health goals (weight loss, exercise targets, etc.)
  • Track progress towards goals with visual progress bars
  • Mark goals as completed or manage multiple active goals

πŸ‘€ User Management

  • Secure user registration and authentication
  • Personal profile management
  • Customizable user settings (age, height, gender)

Technology Stack

Frontend

  • React 18: Modern component-based UI framework
  • React Router: Client-side routing
  • Chart.js: Data visualization
  • Axios: HTTP client for API calls
  • CSS3: Responsive styling

Backend

  • Node.js: JavaScript runtime
  • Express.js: Web application framework
  • SQLite3: Lightweight database
  • JWT: Secure authentication
  • bcryptjs: Password hashing
  • express-validator: Input validation

Installation

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn

Setup Instructions

  1. Clone the repository

    git clone <repository-url>
    cd health_tracker
  2. Install backend dependencies

    npm install
  3. Install frontend dependencies

    cd src/frontend
    npm install
    cd ../..
  4. Set up environment variables

    cp .env.example .env

    Edit .env and set your configuration:

    PORT=3001
    NODE_ENV=development
    JWT_SECRET=your-secret-key-here
    
  5. Start the application

    Development mode (runs both frontend and backend):

    npm run dev

    Or run separately:

    Backend:

    npm run server

    Frontend (in a new terminal):

    npm run client
  6. Access the application

Project Structure

health_tracker/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ backend/
β”‚   β”‚   β”œβ”€β”€ api/              # API route handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.js       # Authentication endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ users.js      # User management
β”‚   β”‚   β”‚   β”œβ”€β”€ health.js     # Health data endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ goals.js      # Goal management
β”‚   β”‚   β”‚   └── analytics.js  # Analytics endpoints
β”‚   β”‚   β”œβ”€β”€ database/
β”‚   β”‚   β”‚   └── db.js         # Database initialization and queries
β”‚   β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”‚   └── auth.js       # JWT authentication middleware
β”‚   β”‚   └── server.js         # Express server setup
β”‚   └── frontend/
β”‚       β”œβ”€β”€ public/
β”‚       β”‚   └── index.html    # HTML template
β”‚       └── src/
β”‚           β”œβ”€β”€ components/   # Reusable React components
β”‚           β”‚   β”œβ”€β”€ Navbar.js
β”‚           β”‚   └── Navbar.css
β”‚           β”œβ”€β”€ pages/        # Page components
β”‚           β”‚   β”œβ”€β”€ Login.js
β”‚           β”‚   β”œβ”€β”€ Register.js
β”‚           β”‚   β”œβ”€β”€ Dashboard.js
β”‚           β”‚   β”œβ”€β”€ Profile.js
β”‚           β”‚   β”œβ”€β”€ HealthData.js
β”‚           β”‚   β”œβ”€β”€ Goals.js
β”‚           β”‚   └── Analytics.js
β”‚           β”œβ”€β”€ services/
β”‚           β”‚   └── api.js    # API service layer
β”‚           β”œβ”€β”€ App.js        # Main application component
β”‚           β”œβ”€β”€ index.js      # Application entry point
β”‚           └── index.css     # Global styles
β”œβ”€β”€ package.json              # Backend dependencies
β”œβ”€β”€ .env.example              # Environment variables template
β”œβ”€β”€ .gitignore
└── README.md

API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - User login

User Management

  • GET /api/users/profile - Get user profile
  • PUT /api/users/profile - Update user profile

Health Data

  • GET /api/health/weight - Get weight records
  • POST /api/health/weight - Add weight record
  • GET /api/health/nutrition - Get nutrition records
  • POST /api/health/nutrition - Add nutrition record
  • GET /api/health/exercise - Get exercise records
  • POST /api/health/exercise - Add exercise record
  • GET /api/health/sleep - Get sleep records
  • POST /api/health/sleep - Add sleep record
  • GET /api/health/vitals - Get vital records
  • POST /api/health/vitals - Add vital record

Goals

  • GET /api/goals - Get all goals
  • POST /api/goals - Create new goal
  • PUT /api/goals/:id - Update goal
  • DELETE /api/goals/:id - Delete goal

Analytics

  • GET /api/analytics/dashboard - Get dashboard summary
  • GET /api/analytics/weight-trend - Get weight trend data
  • GET /api/analytics/nutrition-trend - Get nutrition trend data
  • GET /api/analytics/exercise-summary - Get exercise summary

Database Schema

Users Table

  • id, email, password, name, age, gender, height, created_at, updated_at

Weight Records

  • id, user_id, weight, date, notes, created_at

Nutrition Records

  • id, user_id, meal_type, description, calories, protein, carbs, fat, date, created_at

Exercise Records

  • id, user_id, exercise_type, duration, calories_burned, distance, notes, date, created_at

Sleep Records

  • id, user_id, sleep_duration, quality, date, created_at

Vital Records

  • id, user_id, blood_pressure_systolic, blood_pressure_diastolic, heart_rate, temperature, date, created_at

Goals

  • id, user_id, goal_type, target_value, current_value, start_date, target_date, status, created_at, updated_at

Security Features

  • Password hashing with bcrypt
  • JWT-based authentication
  • Input validation on both frontend and backend
  • Protected API routes
  • SQL injection prevention through parameterized queries

Usage Guide

  1. Register/Login: Create an account or login with existing credentials
  2. Set up Profile: Add your personal information (height, age, gender) for accurate BMI calculations
  3. Track Health Data: Use the Health Data page to log weight, meals, exercise, sleep, and vitals
  4. Set Goals: Create health goals and track your progress
  5. View Analytics: Check the Analytics page to see your progress with interactive charts
  6. Monitor Dashboard: Get a quick overview of your health metrics on the dashboard

Development

Running Tests

npm test

Building for Production

npm run build

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the ISC License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •