Overview

This is a RESTful API for managing installment plans and customer payments. The API is built with Laravel 12 following SOLID principles and best practices.

All API responses are in Arabic (جميع رسائل الـ API بالعربية).

Base URL: https://installment-back.ammar-system.online/api
🔑 Authentication Requirements:
  • 🌐 Public: No authentication required
  • 🔒 Protected: Requires Authorization: Bearer {token} header
  • 👑 Owner Only: Requires authentication + Owner role
  • ⚠️ Subscription Required: Requires authentication + Active subscription

🎯 Key Features

🔐

Token Authentication

Laravel Sanctum for secure API access

📦

Subscription Plans & Limits

Manage subscription plans with resource limits (customers, installments, notifications). Users can upgrade/downgrade subscriptions.

👥

Customer Management

Full CRUD operations with statistics

💳

Installment Tracking

Payment plans with automatic scheduling

📊

Dashboard Analytics

Comprehensive business insights

🔔

Notifications

In-app and email notifications

Architecture

SOLID Principles Implementation

Single Responsibility

Each class has one clear purpose: Controllers handle HTTP, Services contain business logic, Resources transform data.

Open/Closed

Services are open for extension through interfaces without modifying existing code.

Liskov Substitution

All services implement interfaces and can be substituted without breaking functionality.

Interface Segregation

Separate focused interfaces for Auth, User, Customer, and Installment services.

Dependency Inversion

Controllers depend on interfaces, not concrete implementations via ServiceBindingProvider.

🔐 Authentication (المصادقة)

The API uses Laravel Sanctum for token-based authentication. All messages are in Arabic.

POST /api/auth/register Public

Register a new user (تسجيل مستخدم جديد)

📤 Request
POST /api/auth/register
Content-Type: application/json

{
  "name": "أحمد محمد",
  "email": "ahmed@example.com",
  "password": "password123",
  "password_confirmation": "password123",
  "subscription_id": 1  // optional - if not provided, free plan is assigned
}
📥 Response (201 Created)
{
  "success": true,
  "message": "تم التسجيل بنجاح",
  "data": {
    "user": {
      "id": 1,
      "name": "أحمد محمد",
      "email": "ahmed@example.com",
      "role": "user",
      "user_limit": {
        "subscription_name": "الخطة الأساسية",
        "limits": {
          "customers": {"from": 0, "to": 100},
          "installments": {"from": 0, "to": 200},
          "notifications": {"from": 0, "to": 1000}
        },
        "usage": {
          "customers_used": 0,
          "installments_used": 0,
          "notifications_used": 0
        },
        "remaining": {
          "customers": 100,
          "installments": 200,
          "notifications": 1000
        }
      }
    },
    "token": "1|xxxxxxxxxxxx",
    "token_type": "Bearer"
  }
}
POST /api/auth/login Public

Login and get access token (تسجيل الدخول)

📤 Request
POST /api/auth/login
Content-Type: application/json

{
  "email": "ahmed@example.com",
  "password": "password123"
}
📥 Response (200 OK)
{
  "success": true,
  "message": "تم تسجيل الدخول بنجاح",
  "data": {
    "user": {
      "id": 1,
      "name": "أحمد محمد",
      "email": "ahmed@example.com",
      "role": "user",
      "user_limit": {
        "subscription_name": "الخطة الأساسية",
        "limits": {...},
        "usage": {...},
        "remaining": {...}
      }
    },
    "token": "1|xxxxxxxxxxxx",
    "token_type": "Bearer"
  }
}
GET /api/auth/me Protected

Get authenticated user (الحصول على بيانات المستخدم)

📤 Request
GET /api/auth/me
Authorization: Bearer {token}
📥 Response (200 OK)
{
  "success": true,
  "message": "تم جلب البيانات بنجاح",
  "data": {
    "user": {
      "id": 1,
      "name": "أحمد محمد",
      "email": "ahmed@example.com",
      "role": "user",
      "user_limit": {...}
    }
  }
}