Skip to content

Fitness Assistant is a Node.js and TypeScript-based application utilizing the Gemini API to provide personalized fitness plans and progress tracking and is designed to be used with Daytona.

License

Notifications You must be signed in to change notification settings

Thund3rHawk/fitness-assistant

Repository files navigation

Fitness Assistant

Node.js TypeScript Daytona Gemini API

Sample TypeScript using Express.js

This project demonstrates how to build a fitness assistant application using Node.js, TypeScript, and the Gemini API, and is designed to be used with Daytona. It includes features such as user authentication, get fitness advice, and get nutrition advice.

🚀 Getting Started

Open Using Daytona

  1. Install Daytona: Follow the Daytona installation guide.

  2. Create the Workspace:

    daytona create https://github.com/Thund3rHawk/fitness-assistant.git
  3. Set Up Environment Variables:

    Before running the application, you need to set up the environment variables. Follow these steps:

    1. Create a .env file in the root directory of the project.

    2. Add the following environment variables to the .env file:

      DATABASE_URL = your_mongodb_url
      GEMINI_API_KEY = your_gemini_api_key
      JWT_SECRET = your_jwt_secret_key
      

      Replace your_mongodb_url, your_gemini_api_key, and your_jwt_secret_key with your actual MongoDB URL, Gemini API key, and JWT secret key.

    3. Save the .env file.

    These environment variables are essential for the application to run correctly and securely.

  1. Start the Application:

    npm run dev

🛠️ Tech Stack

The Fitness Assistant project leverages a modern and efficient tech stack to deliver a high-quality application. Below are the key technologies used:

  • Node.js: A powerful JavaScript runtime built on Chrome's V8 engine, used for building the server-side of the application.
  • TypeScript: A statically typed superset of JavaScript that enhances code quality and maintainability.
  • Express.js: A minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.
  • Prisma: An ORM (Object-Relational Mapping) tool that simplifies database interactions and ensures type safety with TypeScript.
  • MongoDB: A NoSQL database that stores data in JSON-like documents, providing flexibility and scalability.
  • Gemini API: An external API used to fetch fitness and nutrition data, enabling personalized advice for users.
  • Daytona: A development environment that simplifies the process of creating, managing, and deploying applications.

This combination of technologies ensures that the Fitness Assistant application is scalable, maintainable, and easy to develop.

📸 Screenshots

Click to view screenshots Screenshot 2024-12-17 at 12 48 47 AM Screenshot 2024-12-17 at 12 50 42 AM Screenshot 2024-12-17 at 12 52 16 AM Screenshot 2024-12-17 at 1 42 20 AM

API Endpoints

Here are some of the key API endpoints provided by the fitness assistant application, along with sample request and response JSON:

User Registration

Endpoint: `POST /api/v1/auth/sign-up`

Request:

{
   "name": "john_doe",
   "email": "john@gmail.com",
   "password": "securepassword123",
   "age": 20,
   "gender": "male",
   "height": 5.7,
   "weight": 60
}

Response:

{
  "message": "SignUp Successfull"
}

User Login

Endpoint: `POST /api/v1/auth/sign-in`

Request:

{
   "email": "abc@example.com",
   "password": "securepassword123"
}

Response:

{
  "message": "Login successful",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Get Fitness Advice

Endpoint: `POST /api/v1/getFitnessAdvice`

Request:

{
   "email": "abc@example.com"
}

Request Headers:

{
  "Authorization": "Bearer YOUR_JWT_TOKEN"
}

Response:

{
  "advice": "Based on your profile, we recommend a mix of cardio and strength training."
}

Get Nutrition Advice

Endpoint: `POST /api/v1/getNutritionAdvice`

Request:

{
   "email": "abc@example.com"
}

Request Headers:

{
  "Authorization": "Bearer YOUR_JWT_TOKEN"
}

Response:

{
  "advice": "We recommend a balanced diet with a focus on protein and healthy fats."
}

These endpoints allow users to register, log in, and receive personalized fitness and nutrition advice.

Using Postman for API Testing

You can use Postman to test the API endpoints provided by the fitness assistant application. Follow these steps to set up Postman for testing:

  1. Install Postman: Download and install Postman from the official website.

  2. Import the API Collection:

    • Open Postman and click on the "Import" button.
    • Import the provided Postman collection file (postman_collection.json) from the project repository.
  3. Set Up Environment Variables:

    • In Postman, go to "Environments" and create a new environment.
    • Add the following variables to the environment:
      • baseUrl: http://localhost:8080/api/v1
      • jwtToken: Your JWT token obtained from the sign-in route.
  4. Testing the Endpoints:

    • Use the imported collection to test the various endpoints.
    • Ensure you have the jwtToken set in the environment for authenticated routes.

By using Postman, you can easily test and debug the API endpoints to ensure they are working as expected.

✨ Features

  • Framework: Built using Node.js and TypeScript, ensuring a robust and scalable architecture.
  • User Authentication: Secure user registration and login functionality.
  • Fitness Advice: Personalized fitness recommendations based on user data.
  • Nutrition Advice: Tailored nutrition guidance to help users meet their health goals.
  • API Integration: Seamless integration with the Gemini API for enhanced functionality.
  • Daytona Compatibility: Easily deployable and manageable within the Daytona environment.

List of sample features (e.g. realtime chat app, standardized development environment with devcontainers)

About

Fitness Assistant is a Node.js and TypeScript-based application utilizing the Gemini API to provide personalized fitness plans and progress tracking and is designed to be used with Daytona.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published