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.
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.
- Complete CRUD operations for member profiles.
- Status Tracking: Active, Inactive, Pending.
- Metrics: Individual member payment history and attendance stats.
- 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.
- RFID Integration: Assign physical cards to members for secure access.
- Real-time Check-in:
POST /api/attendance/check-inhandles logic for valid subscriptions and active cards. - History Logs: Detailed logs of every entry for security and audit purposes.
- Sanctum Authentication: Secure token-based authentication for API consumption.
| 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. |
- PHP >= 8.2
- Composer
- MySQL
-
Clone the Repository
git clone https://github.com/yourusername/gym-system-api.git cd gym-system-api -
Install Dependencies
composer install
-
Environment Setup
cp .env.example .env # Configure your DB_DATABASE, DB_USERNAME, etc. in .env -
Generate App Key
php artisan key:generate
-
Database Migration & Seeding Creates tables and populates default Admin/Plan data.
php artisan migrate --seed
-
Run the Scheduler (Local) Required for automated subscription expiration.
-
Serve
php artisan serve
A full Postman Collection is included in the codebase for easy import.
File Location: apis/postman_collection.json