π Disponible tambiΓ©n en EspaΓ±ol
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.
-
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
-
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.
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
-
Node.js (v16 o +)
-
npm
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
- Clone the repository:
git clone https://github.com/nuriadevs/backend-api-fitflow
cd backend-api-fitflow
- Install dependencies:
npm install
-
npm start
: Starts the server in development mode with nodemon. -
npm test
: Runs tests using Jest.
- 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>
- You can customize additional settings in
src/config/env.ts
as needed.
API docs are available in docs/swagger.yaml
. You can preview them using Swagger UI or import into Postman, Bruno,etc... .
Run tests with:
npm test
You can send chat requests using the following examples:
-
Recommend exercises for biceps.
-
Recommend exercises for triceps.
-
Recommend a routine for training glutes.
-
Don't forget to create your own .env file for the variables.
-
This project is under construction...can be improved.