Skip to content

damattag/API-Gym-Pass

Repository files navigation

GymPass Style API

A Node.js API that simulates a GymPass-like system for managing gym check-ins and user access. This project was built using modern technologies and best practices for backend development.

🚀 Technologies

  • Node.js
  • Fastify - Fast and low overhead web framework
  • TypeScript - For type safety and better development experience
  • PostgreSQL - Relational database
  • Prisma - Modern database ORM
  • Docker - For containerization
  • Vitest - Unit and E2E testing
  • JWT - For authentication
  • Zod - For data validation

📋 Requirements

  • Node.js (v16 or higher)
  • Docker and Docker Compose
  • PostgreSQL
  • Yarn or npm

🛠️ Setup

  1. Clone the repository
git clone <repository-url>
cd API-Gym-Pass
  1. Install dependencies
yarn install
  1. Set up environment variables
# Create a .env file based on .env.example
cp .env.example .env
  1. Start the database using Docker
docker-compose up -d
  1. Run database migrations
yarn migration
  1. Start the development server
yarn dev

📜 Available Scripts

  • yarn dev - Start development server
  • yarn build - Build for production
  • yarn start - Start production server
  • yarn test - Run unit tests
  • yarn test:e2e - Run end-to-end tests
  • yarn test:coverage - Generate test coverage report
  • yarn migration - Run database migrations
  • yarn studio - Open Prisma Studio
  • yarn generate - Generate Prisma client

🎯 Features

Functional Requirements

  • User registration
  • Authentication
  • User profile retrieval
  • Check-in count tracking
  • Check-in history
  • Nearby gym search (within 10km)
  • Gym search by name
  • Check-in functionality
  • Check-in validation
  • Gym registration

Business Rules

  • No duplicate email registrations
  • One check-in per day limit
  • Proximity check for check-ins (within 100m)
  • 20-minute window for check-in validation
  • Admin-only check-in validation
  • Admin-only gym registration

Non-functional Requirements

  • Password encryption
  • PostgreSQL data persistence
  • Paginated data lists (20 items per page)
  • JWT authentication

🏗️ Project Structure

src/
├── http/          # HTTP routes and controllers
├── use-cases/     # Business logic
├── repositories/  # Data access layer
└── utils/         # Helper functions and utilities

🔐 Authentication

The API uses JWT (JSON Web Token) for authentication. Protected routes require a valid JWT token in the Authorization header:

Authorization: Bearer <your-token>

📝 License

This project is licensed under the ISC License.

👨‍💻 Author

This project was developed as a personal study and portfolio piece.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published