Generators, consumer integration, and output ownership
Generators, consumer integration, and output ownership
Section titled “Generators, consumer integration, and output ownership”Backend generator extension points
Section titled “Backend generator extension points”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:
- Put Laravel-specific behavior in the adapter, not backend-core.
- Decide which metadata and generation flags select it.
- Follow existing generator/stub and filesystem ownership patterns.
- Test rendered output and the consumer-visible effect, not just a string fragment.
- 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.
Consumer lifecycle commands
Section titled “Consumer lifecycle commands”The standalone CLI and Laravel Artisan integration expose distinct stages:
mettada:initwrites a manifest and empty framework path layout; developers create Laravel/Vite apps separately.mettada:integrateadds the platform packages and bootstrapping to those framework applications.mettada:lintvalidates consumer specifications and references without generating code.mettada:syncresolves 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.
Generated versus consumer-owned files
Section titled “Generated versus consumer-owned files”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.