Skip to content

Latest commit

 

History

History
112 lines (70 loc) · 3.14 KB

File metadata and controls

112 lines (70 loc) · 3.14 KB

Architecture and Structure essentials


Table of Contents

  1. Helpers for reusable functions
  2. Job Queues setup
  3. Use resource routes and API standards


Helpers for reusable functions

Helpers.php for reusable functions

What this topic is:

Centralized helper functions for common tasks and utilities.

Why we are using it:

  • Avoids code duplication across controllers, models, and views.
  • Makes codebase easier to maintain and extend.
  • Provides a single place for reusable logic (e.g., API responses, formatting).

What it does in our project:

  • Defines functions like apiResponse() for consistent API output.
  • Used in controllers and exception handler for standardized responses.
  • Includes other utility functions as needed.

Because of this, files of code:

  • app/helpers.php: Main helper functions file.
  • Referenced in: app/Exceptions/Handler.php, various controllers.



Job Queues setup

Job Queues setup (Redis + Supervisor in production)

What this topic is:

Background job processing using Laravel Queues, Redis, and Supervisor.

Why we are using it:

  • Offloads time-consuming tasks (emails, notifications, backups) from HTTP requests.
  • Improves performance and user experience.
  • Ensures reliable job execution in production.

What it does in our project:

  • Handles queued jobs for emails, notifications, backups, etc.
  • Uses Redis as the queue driver for fast, persistent job storage.
  • Supervisor manages queue workers in production for fault tolerance.

Because of this, files of code:

  • config/queue.php: Queue configuration.
  • app/Jobs/: Custom job classes.
  • .env.example: Sets queue driver and Redis connection.
  • Production setup: Supervisor config (see deployment docs).



Use resource routes and API standards

Use resource() routes & API standards (api.php)

What this topic is:

RESTful routing and standardized API responses using Laravel resource routes.

Why we are using it:

  • Promotes consistency and best practices in API design.
  • Simplifies route definitions and controller logic.
  • Ensures predictable endpoints for frontend and third-party clients.

What it does in our project:

  • Uses Route::resource() for CRUD endpoints.
  • Applies API standards for response format, error handling, and status codes.
  • Integrates with frontend via Inertia.js and React.

Because of this, files of code:

  • routes/api.php: Defines resource routes.
  • app/Http/Controllers/: Resource controllers for models.
  • app/helpers.php: Standardizes API responses.
  • phpunit.xml, tests/Feature/: API tests for endpoints and standards.