How dohuyit/backend-qnhg works
Project type and purpose
• This is a full-stack Laravel web application that supports two user domains:
• An Admin panel (managing categories, dishes, combos, orders, reservations, users, permissions).
• A Client interface (browsing menu, managing cart, placing orders, making reservations).
• It exposes RESTful/HTTP APIs for both domains, real-time event broadcasting for order/reservation notifications, background jobs for email/notification delivery, and integrates with external services (mail, payment gateways, face recognition API).
File structure
• Top-level directories:
• app/Http/Controllers (separated into Admin and Client subfolders) – presentation layer.
• app/Services & app/Repositories – business logic and data access layers following the Service-Repository pattern.
• app/Models – Eloquent ORM models for each domain entity.
• app/Events & app/Listeners – event-driven architecture for side-effects (notifications, counters).
• routes/ – separate route files for admin, client, API, and web.
• resources/js & resources/views – frontend assets (Vue or plain JS & Blade templates).
• config/, bootstrap/, public/, storage/ – Laravel infrastructure and deployment.
• database/ – migrations, factories, seeders for schema and test data.
• artisan, composer.json, phpunit.xml, Vite/Tailwind configs – build, dependency, and tooling.
README for additional insights
• The README is the standard Laravel boilerplate and confirms the use of core features: routing, Eloquent ORM, migrations, queues, broadcasting.
• REALTIME_SETUP.md (not shown) likely describes configuration for Pusher or Socket server.
• Client UI (Browser or Mobile)
• Public Web UI (Blade templates)
• Admin SPAs/Pages (resources/js + Vite)
• HTTP/API Layer (Laravel Controllers: Admin & Client)
• Application Services (app/Services)
• Repositories & Models (app/Repositories + app/Models + Eloquent)
• Relational Database (MySQL/PostgreSQL)
• Cache/Session & Queue backend (Redis)
• Event Broadcasting (Laravel Echo + Pusher or Socket)
• External Services: Email SMTP, Payment Gateway, Face Recognition API
• Background Worker (laravel-queue: Consumers running queued Jobs & Listeners)
b. Relationships and interactions
• Controllers → Services (dependency injection) → Repositories
• Repositories → Database (ORM queries)
• Certain controller or service actions → dispatch Events → Queue → Listeners → Notifications / Mail / Real-time Broadcast
• Controllers → call external SDKs (PaymentService → Payment Gateway; FaceRecognitionService → Face API)
• Broadcasting: Event → Broadcast to WebSocket server → Client UI (real-time notifications)
c. Architectural patterns / design principles
• MVC at the controller-view-model level
• Service-Repository to decouple business logic from persistence
• Event-driven for side effects and real-time updates
• Layered Architecture: Presentation → Application → Domain/Data → Infrastructure
• Dependency Injection via Laravel’s IoC container
• Single codebase servicing multiple domains (admin / client) via route grouping and middleware
d. Key technologies / frameworks / libraries
• PHP 8.x, Laravel Framework
• Eloquent ORM, Migrations, Factories, Seeders
• Redis (cache, session, queues)
• Laravel Queue Workers (e.g., Supervisor)
• Laravel Echo + Pusher or Socket server for broadcasting
• Blade Templates & Vite (with TailwindCSS, JavaScript assets)
• SMTP (Mailgun/SendGrid) and Payment SDK (Stripe/PayPal)
• Face Recognition SDK via HTTP client
Detail
• Sub-components that play a key architectural role (e.g., Queue Worker, Event Service Provider, Broadcast Server).
• Middleware flows (e.g., auth:sanctum, role checks) if space permits.
• Both synchronous (HTTP) and asynchronous (Queue/Broadcast) interactions.