What are Layers?

What are Layers?

Understanding the core unit of OSDD architecture.

A layer is the core unit of OSDD architecture. Every layer is a standard Composer package that lives inside either functional/ or technical/ at your project root.

Anatomy of a Layer

functional/orders/
├── composer.json             ← Composer package definition
└── src/
    ├── Models/
    │   └── Order.php
    ├── Http/
    │   └── Controllers/
    │       └── OrderController.php
    ├── Policies/
    │   └── OrderPolicy.php
    └── Providers/
        └── OrdersServiceProvider.php
├── database/
│   ├── migrations/
│   │   └── xxxx_create_orders_table.php
│   ├── factories/
│   │   └── OrderFactory.php
│   └── seeders/
│       └── OrdersSeeder.php
└── tests/
    └── OrderTest.php

What Makes a Directory a Valid Layer

OSDD identifies a directory as a layer when it contains a composer.json with "type": "layer":

composer.json
{
  "name": "functional/orders",
  "type": "layer",
  "autoload": {
    "psr-4": {
      "Functional\\Orders\\": "src/"
    }
  },
  "extra": {
    "laravel": {
      "providers": [
        "Functional\\Orders\\Providers\\OrdersServiceProvider"
      ]
    }
  }
}
The extra.laravel.providers entry enables Laravel's package auto-discovery to boot the layer's service provider automatically after composer update.

Layer Discovery

OSDD discovers layers by scanning the paths defined in config/osdd.php:

config/osdd.php
'layers' => [
    'paths' => [
        'functional' => base_path('functional'),
        'technical'  => base_path('technical'),
    ]
]

The scanner traverses one level deep by default. If a sub-directory does not contain a composer.json with "type": "layer", it recurses one level further — so you can group layers under category folders without those folders needing to be layers themselves.

functional vs technical

BucketPurposeExamples
functional/Business domain concernsusers, orders, billing, notifications
technical/Infrastructure and cross-cutting concernsosdd, auth, queue-config, event-bus

This distinction is entirely organizational — OSDD treats both buckets the same way technically.

Layer Registration

When osdd:layer or osdd:start creates a layer, it automatically:

  1. Adds a Composer path repository entry pointing to the layer directory
  2. Adds "vendor/package": "*" to require in root composer.json
  3. Injects the service provider into the layer's own composer.json under extra.laravel.providers

After composer update vendor/package, Laravel auto-discovers and boots the service provider — no changes to bootstrap/providers.php needed.