System Design Atlas

Rental and sharing system

04 / 10Worked example

Interfaces

What does the interface confirm immediately?

The app sends requests over HTTP, the communication protocol of the web interface. In the technical models, K-17 denotes the order of the app and R-17 the associated reservation. M-17 is the name of the resulting rental. A-17 is the stable key of the payment authorization; P-17 denotes the later provider reference. These identifiers make the same process recognizable across interface, data model and error sequence. The contract distinguishes between the immediately stored hold, later provider results and the secure repetition after a connection is terminated.

Starting point From step 3: The load test distinguishes search, booking and contention for vehicle A; the reservation remains limited to ten minutes.

Assumptions for the example case

Example design: an operator, specifically assigned vehicles, planned periods and a region. Figures are illustrative design assumptions, not company data.

Request, reply and subsequent result

Separate immediate response and later result

POST /reservationsRequest K-17Vehicle A · 9-12 o'clock · Hold 10 minutes
201 CreatedR-17 · heldThe hold is stored. The payment check follows.
GET /reservations/R-17Read state: confirmedGET reads the state; confirmed only arises after checked authorization and valid time.
POST /rentals/M-17/startRequest for approvalCheck the authorization, time period and vehicle condition.
202 acceptedCommand acceptedThe response provides the status URL for the release order.
GET statusUrlRelease confirmed → activeOnly after confirmed vehicle response is M-17 allowed to start.
Response lostThe app sends K-17 again with the same input. The server leads back to R-17 and does not generate a second booking.
API and WebhookA webhook is an HTTP feedback from the provider. After testing and storage, the result is readable via the status.

The process connects contract, HTTP status and business state. Immediate acceptance remains distinguishable from subsequent confirmation.

K-17 identifies the app order, R-17 the reservation. A-17 identifies the authorization with the provider; P-17 is its later reference.

Five Central Operations

Further reading
  1. GET/vehicles?from=…&to=…

    Find vehicles for a time window

    Input
    Place, start and end; limited list of results.
    Result
    200 with candidates and the freshness of the displayed data. The result does not reserve a vehicle.
    Retry behaviour
    Re-readable; data can now change.
  2. POST/reservations

    Creating a temporary hold

    Input
    vehicleId, from, to and app order key K-17. The authenticated session identifies the person.
    Result
    201 with reservationId, status=held and expiresAt; 409 in the case of overlapping occupancy. Payment authorization follows asynchronously.
    Retry behaviour
    Idempotency: The same app key K-17 and the same payload refer to the same job. Other payload under the same key is rejected. The payment provider processes A-17 and provides P-17 as its own reference.
  3. GET/reservations/{id}

    Read the binding booking status

    Input
    Reservation ID; Access for the authorized person.
    Result
    200 with held, confirmed, expired or cancelled and the associated payment status.
    Retry behaviour
    Re-readable. The current state is decisive for the display.
  4. POST/rentals/{id}/start

    Requesting the vehicle release

    Input
    Identifier of the rental and own order key for the start of the rental. The server checks booking, authorization, time and vehicle condition.
    Result
    202 with release order and status URL. Only a verified vehicle response allows active.
    Retry behaviour
    The same order at the start of the rental does not generate a second release. The access provider receives its own stable key for this; an uncertain outcome is reconciled.
  5. POST/rentals/{id}/return

    Arrange for return and completion

    Input
    Identifier of the rental, return data and own order key for the return.
    Result
    202 with status URL. Upon confirmation of the return conclusion, the end of use and billing order arise.
    Retry behaviour
    Repeats are assigned to the same return order.

Treat repetitions and later results

Further reading
Ensure Idempotency in case of connection interruptions
If the response to R-17 is lost, the app sends the same order key K-17 and the same inputs again. The server recognizes the order and assigns the repetition of the existing reservation. This is idempotence: a repetition does not produce a second business effect. Start of rental and return will each receive their own order keys. External providers carry their own stable keys per purpose, such as A-17 for payment authorization; P-17 remains the provider reference.
Track asynchronous completion through status
Upon vehicle release, HTTP 202 first confirms acceptance of the order. The process continues asynchronously: the access system responds later, and the app reads the result via the status URL. It shows pending, succeeded or needs_review together with the next step. In the case of pending, the release remains in processing; only a verified vehicle response confirms success.
Feedback from providers
A webhook is an HTTP feedback sent by the provider. The recipient checks their signature and stores it permanently. Duplicate or delayed events must not uncontrollably reset a state.
Supplementary endpoints
Cancellation, renewal and reading the rental status follow the same rules. Their complete fields will be specified during implementation.

Terms in this step

Idempotency
The same order can be repeated without additional business effect. Here, the server recognizes a re-sent reservation by its stable order key.
Asynchronous
Command acceptance and the domain outcome occur at different times. Here, the vehicle release is first accepted; its result can be retrieved later via the stored status.

Try it yourself

The API stores R-17, but the response 201 does not reach the app. What does the app send again? Can a later GET query confirm R-17?

A hint for your attempt

The order key identifies the same intention. A status query reads the stored result.

Compare with a possible solution
Repeat safely
The app sends K-17 again with the same input. The server assigns it to R-17 and does not generate a second reservation.
Reading status
GET reads the current state of R-17. confirmed is created by the checked processing of the payment response under valid hold period.
Deviating input
K-17 with modified vehicle or period is rejected. An intentionally new order needs a new key.

Apply to your project

Apply the pattern to your own external call and note which status remains visible if the outcome is uncertain.

Step 5 specifies which relationships, states and transactions carry the R-17 contract in the dataset.