Skip to content

Architecture

lpachecob edited this page Mar 24, 2026 · 4 revisions

🏛️ Architecture: Separation of Concerns

In BOUNDLY, the framework is an implementation detail. The architecture follows Clean Architecture principles, where your business domain is the core and the infrastructure is an adapter layer.


🌳 Directory Structure

🧠 Application/ (Use Cases)

Where your Actions live. These orchestrate the flow:

  • Actions/: Classes decorated with #[Action].
  • DTOs/: Inputs for your Actions.
  • Tests/: Integration tests for specific application features.

❤️ Domain/ (The Business)

The logic that would survive even if you change the framework:

  • Entities/: Classes decorated with #[Entity].
  • Events/: Domain events for side effects.
  • ValueObjects/: Immutable data objects.
  • Tests/: Pure unit tests for your business rules. (e.g., UserApiTest.php in Domain/Users/Tests/).

💎 Boilerplate Examples

The repository includes a ready-to-use User boilerplate to demonstrate the full architectural flow:

  • Domain: A clean User entity with Auditable and SoftDelete traits.
  • Application: A CreateUser Action demonstrates delegating to the DynamicRepository using a UserDTO.
  • Infrastructure: Automations for DB synchronization are already active for these examples.

🏚️ Infrastructure/ (Adapters)

Where the technical heavy lifting - and the "basement" - live:

  • FrameworkCore/: The BOUNDLY Engine (Registries, CLI, Dynamic Repos).
    • Attributes/: All framework attributes, organized by category:
      • Schema/: Entity, Column, Id, PrimaryKey, ForeignKey, Index, UniqueConstraint
      • Relations/: BelongsTo, HasMany, HasOne, ManyToMany, MorphMany, MorphOne, MorphTo
      • Behavior/: Auditable, SoftDelete, TenantAware, Authorize, Policy, Timestampable, Blameable, Sluggable
      • UseCase/: Action
      • Security/: Hidden, Encrypted, Hashed
      • Validation/: 40+ data validation attributes
  • LaravelEngine/: The Basement. Contains Laravel internally (config, storage, database, etc.) to keep your root clean.
  • Providers/: Framework wiring.

🛠️ Entry Points

File Purpose
artisan CLI tool. Redirigido al sótano por defecto.
bootstrap/app.php The Ignitor. Connects BOUNDLY's clean root with Laravel's basement.
public/index.php Web entry point. Handles requests by booting the basement.

🧬 Why this structure?

  1. Screaming Architecture: When you open the project, it screams "Users", "Orders", "Products" (Domain), not "Models", "Views", "Controllers" (Framework).
  2. Encapsulation: The framework is hidden. If you ever need to replace Laravel, you only touch the basement.
  3. Purity: Zero framework dependencies in your Domain layer.

Next Step: CLI-Commands 🚀

Clone this wiki locally