Skip to content

Latest commit

 

History

History
214 lines (147 loc) · 6.39 KB

README.md

File metadata and controls

214 lines (147 loc) · 6.39 KB

💪 Trainify API

A REST API for the Trainify app to manage workouts, exercises, sessions, metrics and user progress.

last-commit repo-top-language repo-language-count

📃 About  •   🛠️ Tech Stack  •   ✨ Features  •   🚀 Getting Started  •   📖 API Documentation  •   🧪 Tests


📃 About

Trainify API is the backend of the Trainify app, responsible for providing a REST layer to register and track workouts. The application allows managing exercises, creating and finishing workout sessions, logging weight, tracking metrics, and consuming progress data through a well-organized modular structure.

The project was built with Fastify, TypeScript, Prisma ORM and PostgreSQL, with a focus on performance, strong typing, hardened security and interactive documentation via Scalar.


🛠️ Tech Stack


✨ Features

  • 🏋️ Exercise management (catalog and custom exercises)
  • 🗓️ Workout creation, plans and weekly scheduling
  • ⏱️ Starting, pausing and finishing workout sessions
  • 📝 Exercise log tracking and session history
  • 📊 Performance comparisons (weekly, monthly and per exercise)
  • ⚖️ Weight logging, weight goals and analytics
  • 📈 Overall user metrics and progress
  • 🏆 Gamification module: streaks, badges and achievements
  • 🔐 JWT authentication and Google sign-in
  • 🛡️ Security hardening with Helmet and rate limiting
  • 🧩 Data validation with Zod
  • 📖 Interactive API documentation with Scalar
  • 🧪 Automated testing with Vitest

🚀 Getting Started

📋 Prerequisites

🔧 Installation

  1. Clone the repository:

    git clone https://github.com/joschonarth/trainify-api.git
  2. Navigate into the project:

    cd trainify-api
  3. Install dependencies:

    npm install

🔑 Environment Variables

Copy the example env file and fill in your values:

cp .env.example .env

Example content:

NODE_ENV=dev
PORT=3333
JWT_SECRET=your_jwt_secret
GOOGLE_CLIENT_ID=your-google-oauth-client-id.apps.googleusercontent.com
DATABASE_URL="postgresql://docker:docker@localhost:5432/trainify?schema=public"

🐳 Database

Start the PostgreSQL container:

docker compose up -d

Run the Prisma migrations:

npm run migrate

Optionally, seed the database with sample data:

npm run seed

▶️ Running

Start the server in development mode:

npm run dev

API running at http://localhost:3333


📖 API Documentation

With the server running, access the interactive documentation at:

There is also a health check endpoint available at:


🧪 Tests

Tests are run with Vitest and cover the main application flows.

# Run all tests
npm run test

# Run tests in watch mode
npm run test:watch

# Generate coverage report
npm run test:coverage

📁 Project Structure

src/
  modules/
    exercise/
    gamification/
    metric/
    session/
    user/
    weight/
    workout/
  lib/
  env/

⭐ Contributing

Contributions are welcome. If you'd like to help, open an issue or submit a pull request with your proposed improvements.

If you liked this project, consider leaving a ⭐ on GitHub — it really helps!


Made with ♥ by João Otávio Schonarth

GitHub LinkedIn Gmail