flyt

03 — Categories

A file's name says what its code may do.

A feature is a folder. A file is named for its category.

shop/

carts/a feature: the cart and what changes it

  • + adapters, queries, policies, specs, pages/customer

delivery/the carrier: its effects and their adapters

  • + domain, mutations, policies, specs, …

orders/reads carts' rows; asks carts.mutations to change them

+ more features: accounts/, catalog/, payments/, …

Domain

The types a feature speaks in. Every string, list and number has a bound.

carts/domain.flyt
type CartId = Id<"cart", max: 64>
type Quantity = Int<min: 1, max: 99>
type Lines = List<Line, max: 50>

record Cart {
  customer: CustomerId
  currency: Asset
  lines: Lines
  touched: clock.Moment
}

enum Command {
  AddLine { customer: CustomerId, line: Line, currency: Asset, at: clock.Moment }
}

enum Step {
  Next { cart: Cart }
  Refuse { reason: Rejection }
}