Layer by layer
puerto generar scaffold is four generators run in order, one crate each. Run them yourself when
you want to stop between layers: to get the domain right before anything depends on it, or to
give an agent one layer to work on at a time.
-
The domain, with its fields. They are written to
puerto.toml, so the next commands pick them up.puerto generar dominio Factura -- numero:String! total:i64 vence_en:DateTimeThe
dominio_facturacrate incontextos/factura/dominio/: the model, its errors, the repository port with its double, and the Object Mother. This is the moment to write the rules inFactura::newand runcargo test -p dominio_factura: nothing else exists yet that could break. -
The application: the
aplicacion_facturacrate, five use cases, one file each with its params, trait, double, implementation and tests.puerto generar aplicacion Factura -
The repository: the
infra_facturacrate, in memory, or Postgres with its row and migration in a--dbproject.puerto generar repositorio Factura -
The presentation: the
rest_facturacrate, with its routes, DTOs, responses and error mapping. It regeneratespresentacion/cableado/andbootstrap.rs, so this is when the entity is wired and served.puerto generar presentacion Factura -
The screens, in a web project.
puerto generar web Facturamake web/sync
aplicacion, repositorio, presentacion and web refuse an entity that is not in
puerto.toml yet, presentacion also refuses one without its application crate, and each one
prints the next command.
When the wiring is out of date
Section titled “When the wiring is out of date”presentacion/cableado/ and bootstrap.rs wire what puerto.toml declares. If the manifest
lists an entity whose files are not on disk yet, puerto generar bootstrap refuses rather than
write Rust that does not compile; --permitir-faltantes writes it anyway, for the middle of a
layer-by-layer session.
puerto validar # what puerto.toml says against what is on diskpuerto generar bootstrap # rewrite cableado/ and bootstrap.rs (and eventos.rs, registro.rs, the web's generated files)