How aboodmagdy1/sofra works
Project Overview
• This is a backend solution for a multi-restaurant mobile application. It handles orders, client and restaurant management, reviews, meals, offers, commissions, and notifications.
• It exposes comprehensive RESTful APIs (for clients and restaurants), while also providing an admin dashboard for internal management.
• Technologies include Laravel v11 (PHP), MySQL, Eloquent ORM, Sanctum for authentication, Spatie for role/permission management, and external services like FCM for notifications and Paypal for payments.
Main Components
• API Layer:
• Controllers under app/Http/Controllers/Api (for both "Client" and "Restaurant").
• Authentication endpoints, order creation, meal management, offer management, and other CRUD operations.
• Admin Dashboard:
• Controllers within app/Http/Controllers/Admin, handling admin login, dashboard functions, user/role management, etc.
• Business Logic Layer:
• Services such as those in app/Services/(Admin, Client, Restaurant, OrderService, Payments, and more). These encapsulate domain and business logic.
• Use of repositories (app/Repositories and its Interfaces) following the Repository design pattern for data access abstraction.
• Domain & Data Layer:
• Models in app/Models representing entities (User, Client, Restaurant, Order, Meal, etc.).
• Migrations and seeders for the MySQL database structure.
• Auxiliary Components:
• Middleware (e.g., for permission checking – AutoCheckPermissionMiddleware).
• Helpers, Enums, Traits used across the project.
• Notification handling (using Laravel-notification-channels for FCM) and mail services.
• Payment integration service (e.g., PaypalGetwayService, exposing a GetwayInterface).
Architectural Patterns & Design Principles
• MVC Pattern: Controllers are handling HTTP requests and delegating to Services.
• Repository Pattern: Consistent abstraction for data access with Interfaces and Eloquent repositories.
• Service-Oriented: Clear separation of business logic into various service classes.
• Multi-Authentication: Different authentication flows for Admin, Client, and Restaurant users.
Detailed Elements
• Presentation Layer:
• Mobile App / Customer Interface.
• Admin Dashboard UI.
• API Layer:
• Client API Controllers (e.g., AuthController, MainClientController, OrderController).
• Restaurant API Controllers (e.g., AuthController, MealController, OfferController, RestaurantController).
• Separate routes defined in routes/api.php, routes/client-api.php, and routes/restaurant-api.php.
• Admin Layer:
• Admin Controllers (like AuthController, CategoryController, etc.) tied with Web routes (routes/admin.php).
• Business Logic Layer:
• Service classes (Admin services, ClientService, OrderService, etc.)
• Data Layer:
• Repository interfaces and Eloquent implementations.
• Database with migrations and models.
• External Integration:
• Payment Services (Paypal gateway).
• Notification Service (via FCM).
• Mail Service implementation (Mailtrap usage for emails).
• Configuration & Environment: