Pedalen rents bikes by the hour, and every rental, from the web, the counter or a hotel voucher, passes one reserve() door that writes the row everything else reads.
This page shows how a rental starts and what it touches. Read it top to bottom: each section asks one question, draws the answer, and says what it means for the shop.
Where does a rental start, and what does every way in share? Look at the dashed line: above it, one adapter per way in; below it, the parts every rental passes.
Figure 1 · the rental machine · every way in passes one door
Above the line, one adapter per way a rental starts; the app is missing and drawn dashed in the slot it would fill. Below the line, everything is shared: one reserve() door writes the rental, which holds a bike and a payment.
reserve() like the web shop.Every way in ends at reserve(), so a new channel is one more adapter, not a second booking system. The weak spot is the hotel voucher file, which arrives once a night; the next section shows what a rental writes when it gets through.
What happens between a click on the web shop and an open lock? Read the five actors left to right and the steps top to bottom.
A rental is reserved, then unlocked
Read top to bottom. The pale band is one database transaction: the card is charged before it opens, so the transaction never waits on the payment provider. The lock code is sent after commit.
The card is charged before the transaction and the lock code is sent after it, so neither outside service can hold a rental half-written.
What does the shop store, and how do the tables join? Start at rental, the row everything else reads.
The rental data model, six tables
What exists and how many: a customer has rentals, a rental holds one bike and its payments. Damage reports are planned and not built.
A rental holds one bike and one or more payments, so deposits and refunds are rows, not edits. Damage reports have no table yet; adding one is a single join on rental_id.
What has to happen the week before opening, and what holds it up? The red bars are the critical path.
Season prep, the week before opening
What runs when on a calendar. The red bar is the critical path: the e-bikes cannot go out before the lock firmware is updated.
Nothing else in the week can delay opening; the lock firmware can. If it slips past Wednesday, the e-bikes, a third of last season's rentals, open late.