- Docs
- Specs
- Analytics
- Reviews
Reviews¶
This page specifies Passenger post-trip reviews, ratings, Dashboard listing, visibility, and moderation boundaries. It draws from Build Spec §5.9 and the POST /trips/{id}/review API contract.
Sources: Build Spec §5.9 and §7, API Conventions, Domain Glossary.
1. Purpose¶
A Passenger may rate a completed trip from 1 to 5 and leave an optional comment. Reviews are stored in trip_reviews and listed in the Fleet Dashboard with filters by rating, trip, driver, and date range. Managers can also view a company-scoped aggregate summary.
2. Review Flow¶
- The Trip completes (
status=completed). - The Passenger submits a rating and optional comment from the Passenger App.
- The API handles
POST /api/trips/{id}/review. - The review is stored with its Trip, Company, Passenger User, Driver (derived from the Trip's assigned Driver Membership), rating, and comment.
- Managers list Company reviews and view an aggregate summary in the Fleet Dashboard.
No automatic prompt, submission deadline, notification, edit, delete, or moderation workflow is defined in Slice 8.
3. Ratings and Comments¶
| Field | Contract |
|---|---|
trip_id |
Path parameter. The completed Trip being reviewed; must belong to the authenticated Passenger's Company. |
user_id |
Derived from the authenticated Passenger; never accepted from the client. |
company_id |
Derived from the Trip; never accepted from the client. |
driver_id |
Derived server-side from the Trip's assigned Driver Membership (trips.driver_id); never accepted from the client. |
rating |
Required integer, 1–5 inclusive. |
comment |
Optional nullable string, max 1000 characters after trimming; empty string is stored as null. |
A Passenger may submit at most one review per Trip. The uniqueness boundary is (trip_id, user_id) and is enforced by a database unique index and application check.
4. Eligibility and invariants¶
- The authenticated User must have an
activePassenger Membership in the same Company as the Trip. - The Trip must exist in the Passenger's Company; cross-tenant Trip IDs return 404.
- The Trip must be
completed; a non-completed Trip returns 422 witherrors.trip. - The Passenger must own an
approvedBooking on the Trip; missing/ineligible booking returns 422 witherrors.booking. - Duplicate review for the same Trip and Passenger returns 422 with
errors.review. - Suspended Company returns 403 with the standard suspended-company message.
- Reviews carry no payment, price, wallet, or moderation state.
5. API Contract¶
All paths are relative to the API base path /api.
| Method | Path | Audience | Purpose |
|---|---|---|---|
POST |
/trips/{id}/review |
Passenger (auth:sanctum + company + active passenger role) |
Submit a post-trip review. |
GET |
/company/reviews |
Manager (auth:sanctum + company + manager) |
List Company reviews with filters. |
GET |
/company/reviews/summary |
Manager (auth:sanctum + company + manager) |
Company-scoped aggregate summary for the same filters. |
5.1 Create review¶
POST /api/trips/{id}/review
Request body:
{
"rating": 5,
"comment": "Smooth trip and on time."
}
201 response (ReviewResource, unwrapped):
{
"id": 1,
"company_id": 1,
"trip_id": 10,
"driver": { "id": 7, "user_id": 22, "name": "Driver Name" },
"passenger": { "id": 33, "name": "Passenger Name" },
"rating": 5,
"comment": "Smooth trip and on time.",
"created_at": "2026-11-27T12:00:00Z",
"updated_at": "2026-11-27T12:00:00Z"
}
5.2 List reviews¶
GET /api/company/reviews
Query filters:
| Filter | Type | Behavior |
|---|---|---|
rating |
integer 1–5 | Exact rating match. |
trip_id |
integer | Exact Trip ID within Company. |
driver_id |
integer | Exact Driver Membership ID (trips.driver_id) within Company. |
date_from |
Y-m-d date |
Inclusive lower bound on review created_at date (UTC day). |
date_to |
Y-m-d date |
Inclusive upper bound on review created_at date (UTC day). |
page |
integer >=1 | Pagination page; default 1. |
per_page |
integer 1–100 | Pagination size; default 15. |
200 response uses the standard collection envelope (data, meta, links). Default sort is newest first (created_at desc, id desc).
5.3 Review summary¶
GET /api/company/reviews/summary
Accepts the same filters as the list endpoint. Returns an aggregate over the filtered Company reviews:
{
"average_rating": 4.5,
"review_count": 12,
"rating_distribution": {
"1": 0,
"2": 1,
"3": 1,
"4": 2,
"5": 8
}
}
average_rating is a number rounded to two decimal places, or null when review_count is 0. rating_distribution always includes keys "1" through "5".
6. Validation and errors¶
Errors follow { "message": string, "errors"?: Record<string, string[]> }.
| Case | Status | Envelope |
|---|---|---|
| Invalid rating/comment/filter format | 422 | message + field errors |
| Trip not completed | 422 | errors.trip |
| Passenger has no approved Booking for Trip | 422 | errors.booking |
| Duplicate review | 422 | errors.review |
| Wrong role / inactive Passenger Membership | 403 | message only |
| Suspended Company | 403 | message only |
| Missing/cross-tenant Trip or review context | 404 | message only |
7. Visibility¶
| Audience | Visibility |
|---|---|
| Passenger | May submit a review for an eligible completed Trip. Passenger review listing is not part of Slice 8. |
| Manager | May list and view summary for reviews belonging to their Company. |
| Driver | No review visibility in Slice 8. |
| Platform Admin | No review visibility in Slice 8. |
| Other Passengers | No review visibility. |
Manager review responses include Passenger identity (id, name) because managers operate Company trips; no phone/email/PII beyond name is exposed.
8. Open Questions¶
- Submission window: Is there a deadline for submitting a review after trip completion?
- Edit/delete: May a Passenger edit or delete a review?
- Passenger visibility: Can Passengers view their own submitted reviews?
- Moderation: Reporting, hiding, editing, deletion, audit history, and appeals are out of scope for Slice 8.
- Notifications: Are Passengers or Managers notified when a review is submitted?