Skip to content

nuriadevs/backend-api-fitflow

Repository files navigation

Backend - FitFlow App

📘 Disponible también en Español

Overview

FitFlow App is an AI-powered agent that helps users discover and get personalized workout recommendations. It uses a RAG (Retrieval-Augmented Generation) architecture with Upstash to optimize storage and semantic retrieval of workout.

The backend is built with TypeScript and Node.js, and interfaces with a MongoDB database to manage user profiles and workout data. Integrates OpenAI’s API to enable a conversational AI assistant for user interactions.

Technologies

  • Node.js: JavaScript runtime environment.

  • TypeScript: Language that builds on JavaScript

  • MongoDB: NoSQL database for storing users and exercises.

  • Upstash: RAG-based vector DB for fast semantic search.

  • OpenAI API: API KEY para poder utilizar el chat y consultar datos.

  • Jest: Testing framework for backend and route logic

Key Features

  • Authentication: User management with JWT.

  • Exercise Recommendation: Personalized search and suggestions.

  • AI Chat Assistant: Natural language interaction for workout guidance, saved directly to the user profile.

  • RAG Integration: Uses Upstash to optimize speed and accuracy in exercise-related queries.

Project Structure


backend/

  

├── docs/ # API documentation (Swagger)

  

├── src/ # Main source code

  

│ ├── api/ # Controllers, routes, middlewares

  

│ ├── config/ # App configuration

  

│ ├── constants/ # Global constants

  

│ ├── interfaces/ # TypeScript interfaces

  

│ ├── models/ # Data models

  

│ ├── responses/ # Standardized API responses

  

│ ├── schemas/ # Validation schemas

  

│ ├── services/ # Business logic

  

│ ├── tests/ # Unit and integration tests

  

│ ├── utils/ # Utility functions

  

├── package.json # Dependencies and scripts

  

├── tsconfig.json # TypeScript config

  

Prerequisites

  • Node.js (v16 o +)

  • npm

🏋️‍♀️ Gym Exercises Dataset

The megaGymDataset.csv dataset located in the src/services/rag folder. This dataset contains detailed information about exercises targeting different parts of the body.

The analysis was essential for preparing the data for the RAG system (Retrieval-Augmented Generation).

📁 You can view the full data analysis here:
🔗 Data Analysis Repository

Setup

  1. Clone the repository:
git clone https://github.com/nuriadevs/backend-api-fitflow

cd backend-api-fitflow
  1. Install dependencies:
npm install

Scripts

  • npm start: Starts the server in development mode with nodemon.

  • npm test: Runs tests using Jest.

Environment Variables

  1. Create a .env file in the root directory and define the following variables:
  

DATABASE_URL=<DATABASE_URL>

  

JWT_SECRET=<JWT_SECRET>

  

OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>

  

MONGODB_URI=<MONGODB_CONNECTION_URI>

  

PORT=<SERVER_PORT>

  

CORS_ORIGIN=<ALLOWED_ORIGIN>

  

NODE_ENV=<ENVIRONMENT>

  

UPSTASH_VECTOR_REST_URL=<VECTOR_REST_URL>

  

UPSTASH_VECTOR_REST_TOKEN=<UPSTASH_TOKEN>

  
  1. You can customize additional settings in src/config/env.ts as needed.

API Documentation

API docs are available in docs/swagger.yaml. You can preview them using Swagger UI or import into Postman, Bruno,etc... .

Testing

Run tests with:

npm  test

Chat requests

You can send chat requests using the following examples:

  • Recommend exercises for biceps.

  • Recommend exercises for triceps.

  • Recommend a routine for training glutes.

Demo

backend api

Watch video demo backend

Links

Summary

  • Don't forget to create your own .env file for the variables.

  • This project is under construction...can be improved.

About

AI agent that helps users discover and get personalized workout recommendations.

Topics

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors