Skip to content

Generators, consumer integration, and output ownership

Generators, consumer integration, and output ownership

Section titled “Generators, consumer integration, and output ownership”

backend-core defines framework-neutral generator contracts and dispatch. backend-laravel implements framework output through GeneratorInterface, LaravelGeneratorRegistrar, and LaravelGeneratorEngine. The registrar composes the adapter’s generator set; the engine coordinates rendering/writing. CRUD generators are specialized by artifact responsibility (models, migrations, DTOs, requests, controllers, services, routes, policies, seeders, and API tests).

When adding output:

  1. Put Laravel-specific behavior in the adapter, not backend-core.
  2. Decide which metadata and generation flags select it.
  3. Follow existing generator/stub and filesystem ownership patterns.
  4. Test rendered output and the consumer-visible effect, not just a string fragment.
  5. Verify target selection and incremental cleanup so disabling a generated feature does not remove unrelated application files.

FeatureOutputCleaner is part of the output lifecycle. Treat cleanup rules as a safety boundary: add tests proving both the intended stale output is removed and neighboring consumer-owned files are preserved.

The standalone CLI and Laravel Artisan integration expose distinct stages:

  • mettada:init writes a manifest and empty framework path layout; developers create Laravel/Vite apps separately.
  • mettada:integrate adds the platform packages and bootstrapping to those framework applications.
  • mettada:lint validates consumer specifications and references without generating code.
  • mettada:sync resolves the manifest/spec roots and runs the Laravel generation pipeline.

The implementation is split across ProjectScaffolder, ProjectIntegrator, MettadaIntegrateCommand, and MettadaSyncCommand. Command tests and CLI smoke tests should assert filesystem/manifests in temporary directories; do not use a pilot application’s configured database.

The generated React consumer deliberately keeps platform bootstrap files separate from developer-owned app composition and pages. For example, src/platform/ and the generated composition files are platform-owned, whereas src/App.jsx, app navigation/pages, and theme overrides are developer-owned in the integration template. During initial integration, the stock Vite React App.jsx is replaced by Mettada’s platform-shell starter; other existing application entry points are preserved. Check packages/backend-laravel/README.md before changing this inventory: it is specific to the current scaffold and can change with the template.

Avoid editing generated output in place. If an application needs a durable behavior that cannot be expressed by the spec, add an application-owned service, endpoint, screen, or extension point and test it there.