Skip to content

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.

  1. 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:DateTime

    The dominio_factura crate in contextos/factura/dominio/: the model, its errors, the repository port with its double, and the Object Mother. This is the moment to write the rules in Factura::new and run cargo test -p dominio_factura: nothing else exists yet that could break.

  2. The application: the aplicacion_factura crate, five use cases, one file each with its params, trait, double, implementation and tests.

    puerto generar aplicacion Factura
  3. The repository: the infra_factura crate, in memory, or Postgres with its row and migration in a --db project.

    puerto generar repositorio Factura
  4. The presentation: the rest_factura crate, with its routes, DTOs, responses and error mapping. It regenerates presentacion/cableado/ and bootstrap.rs, so this is when the entity is wired and served.

    puerto generar presentacion Factura
  5. The screens, in a web project.

    puerto generar web Factura
    make 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.

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 disk
puerto generar bootstrap # rewrite cableado/ and bootstrap.rs (and eventos.rs, registro.rs, the web's generated files)