Skip to content

Fitness-plus offers gym memberships with various billing structures. This backend system manages memberships, including annual and monthly billing, as well as optional add-on services.

Notifications You must be signed in to change notification settings

NuelUzoma/fitness-plus

Repository files navigation

Fitness-plus Membership Backend API

Overview

Fitness-plus offers gym memberships with various billing structures. This backend system manages memberships, including annual and monthly billing, as well as optional add-on services such as personal training sessions and towel rentals. The API also handles invoicing for new members, sends email reminders for upcoming payments, and includes a cron job to check for upcoming membership fees.

Features

  • Manage memberships with annual and monthly billing.
  • Handle optional add-on services with separate monthly charges.
  • Combine the annual membership fee with the first month's add-on service charges for new members.
  • Send email reminders for upcoming payments.
  • Cron job to check for upcoming membership fees and send reminders.

Technologies Used

Prerequisites

  • Node.js and npm installed
  • PostgreSQL database setup
  • Gmail account for sending emails

Installation

  1. Clone the repository:

    git clone https://github.com/NuelUzoma/fitness-plus.git
    cd fitness-plus
  2. Install dependencies:

    npm install
  3. Set up environment variables:

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

    DB_HOST=localhost
    DB_PORT=5432
    DB_USERNAME=your_db_username
    DB_PASSWORD=your_db_password
    DB_DATABASE=fitness_plus
    MAIL_HOST=smtp.gmail.com
    MAIL_PORT=587
    MAIL_USER=your_gmail_username
    MAIL_PASS=your_gmail_password
  4. Run the database migration to set up the database schema:

    npm run typeorm migration:run

Running the Application

  1. Start the Nest.js server:

    npm run start

Usage

Endpoints

Memberships

  • Create a new membership

    POST /api/memberships

    Request Body:

    {
      "firstName": "Kelechi",
      "lastName": "Ogu",
      "membershipType": "Annual Basic",
      "email": "[email protected]",
      "isFirstMonth": true
    }

    Response:

    {
      "firstName": "Kelechi",
      "lastName": "Ogu",
      "membershipType": "Annual Basic",
      "email": "[email protected]",
      "isFirstMonth": true,
      "startDate": "2024-06-11T20:16:26.217Z",
      "dueDate": "2025-06-10T23:00:00.000Z",
      "totalAmount": 500,
      "id": 22
    }
  • Get all memberships

    GET /api/memberships
  • Update membership details

    PUT /api/memberships

Add-On Services

  • Create a new add-on service

    POST /api/addons

    Request Body:

    {
      "serviceName": "Personal Training"
    }

    Response:

    {
      "serviceName": "Personal Training",
      "dueDate": "2024-07-10T23:00:00.000Z",
      "monthlyAmount": 100,
      "id": 21
    }
  • Get all add-on services

    GET /api/addons

Email Notifications

Emails are sent using NodeMailer configured with a Gmail SMTP server. Ensure that your Gmail account allows less secure apps or generate an app-specific password for better security.

Cron Job

A cron job runs daily at midnight to check for upcoming membership fees and send reminders.

About

Fitness-plus offers gym memberships with various billing structures. This backend system manages memberships, including annual and monthly billing, as well as optional add-on services.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published