Skip to main content

BearBnB

BearBnB is an AirBnB clone for bears to demonstrate building a Dream/Psychic application complicated enough to leverage several of the powerful features of Dream and Psychic (including STI, polymorphism, has-many-through, serializers in addition to the default and summary serializers, soft-delete, and sortable).

A good way to follow along with building a Psychic app is:

  1. Have PostgreSQL and Redis running (e.g. by brew install postgres brew install redis & following post-install instructions for each)
  2. Create a new Psychic app with npx @rvoh/create-psychic bearbnb.
  3. Start with the third commit in the BearBnB commits (Generate User model).
  4. Then follow along with the changes, commit by commit, making the changes in your project. The commits are broken down into generated code and hand coded features, and the commit message includes generator commands that were run.

Entity Relationship Diagram (ERD) of the BearBnB model domain

Generator commands used to create BearBnB

pnpm psy g:model --no-serializer User email:citext
pnpm psy g:model Guest User:belongs_to
pnpm psy g:model Host User:belongs_to
pnpm psy g:resource --owning-model=Host v1/host/places Place name:citext style:enum:place_styles:cottage,cabin,lean_to,
pnpm psy g:model --no-serializer HostPlace Host:belongs_to Place:belongs_to deleted_at:datetime:optional

pnpm psy g:resource --sti-base-serializer --owning-model=Place v1/host/places/\{\}/rooms Room type:enum:room_types:Bathroom,
pnpm psy g:sti-child Room/Bathroom extends Room bath_or_shower_style:enum:bath_or_shower_styles:bath,shower,bath_and_shower,
pnpm psy g:sti-child --help
pnpm psy g:sti-child Room/Bedroom extends Room bed_types:enum[]:bed_types:twin,bunk,queen,king,cot,sofabed
pnpm psy g:sti-child Room/Kitchen extends Room appliances:enum[]:appliance_types:stove,oven,microwave,dishwasher
pnpm psy g:sti-child Room/Den extends Room
pnpm psy g:sti-child Room/LivingRoom extends Room

pnpm psy g:resource --only=update,destroy v1/host/localized-texts LocalizedText localizable_type:enum:localized_types:Host,
pnpm psy g:controller V1/Guest/Places index show
pnpm psy g:migration add-deferrable-unique-constraint-to-rooms