Skip to content

fathallah7/gym-system-api

Repository files navigation

Gym System API

Laravel PHP MySQL License

Overview

Gym System API is an enterprise-grade backend solution designed to manage modern fitness centers with scalability and performance in mind. Built on Laravel 12, it implements a Service-Oriented Architecture (SOA) ensuring clean command separation, maintainability, and robust business logic handling.

This system powers the full lifecycle of gym management: from Member registration to complex Subscription billing cycles, real-time Attendance tracking via RFID cards, and automated revenue reporting.


Architecture & Design Patterns

This project adheres to strict modern software engineering principles to ensure code quality and testability:

  • Service Layer Pattern: Complex business logic is abstracted into dedicated Services (App\Services), keeping Controllers lean and focused on HTTP handling.
  • API Resources: Data transformation layer (App\Http\Resources) ensures consistent JSON responses and decouples the database structure from the API output.
  • Form Requests: Validation logic is centralized in Request classes (App\Http\Requests), ensuring data integrity before it reaches the controller.
  • Enums: Native PHP Enums (App\Enums) are used for status management (e.g., MemberStatus, PaymentMethod), providing type safety and preventing magic string errors.

Key Modules & Features

1. Member Management

  • Complete CRUD operations for member profiles.
  • Status Tracking: Active, Inactive, Pending.
  • Metrics: Individual member payment history and attendance stats.

2. Subscription & Billing Engine

  • Flexible Plans: Create Monthly, Yearly, or Custom duration plans.
  • Automated Expiration: Background jobs (UpdateExpiredSubscriptions) run daily to automatically expire subscriptions and update member statuses.
  • Revenue Analytics: Real-time endpoints for Daily and Monthly revenue reports.

3. Access Control & Attendance

  • RFID Integration: Assign physical cards to members for secure access.
  • Real-time Check-in: POST /api/attendance/check-in handles logic for valid subscriptions and active cards.
  • History Logs: Detailed logs of every entry for security and audit purposes.

4. Security & Authentication

  • Sanctum Authentication: Secure token-based authentication for API consumption.

Technology Stack

Component Technology Description
Framework Laravel 12 Selected for its robust ecosystem and developer experience.
Language PHP 8.2+ Utilizing strict typing and modern features like Enums/Match.
Database MySQL 8.0 Relational data integrity with foreign key constraints.
Auth Laravel Sanctum Lightweight authentication system for SPAs and mobile apps.
Tools Postman Comprehensive API collection included.

Installation & Setup

Prerequisites

  • PHP >= 8.2
  • Composer
  • MySQL

Step-by-Step Guide

  1. Clone the Repository

    git clone https://github.com/yourusername/gym-system-api.git
    cd gym-system-api
  2. Install Dependencies

    composer install
  3. Environment Setup

    cp .env.example .env
    # Configure your DB_DATABASE, DB_USERNAME, etc. in .env
  4. Generate App Key

    php artisan key:generate
  5. Database Migration & Seeding Creates tables and populates default Admin/Plan data.

    php artisan migrate --seed
  6. Run the Scheduler (Local) Required for automated subscription expiration.

  7. Serve

    php artisan serve

API Documentation

A full Postman Collection is included in the codebase for easy import.

File Location: apis/postman_collection.json


About

Gym management REST API built with Laravel 12, featuring subscriptions, attendance, payments, and revenue reporting.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages