TrustRide replaces the payment receipt and trip-update workflow that would otherwise happen over WhatsApp or phone calls with a structured, in-app messaging system. Every booking gets its own chat thread between the rider and driver, and a separate notification centre keeps both parties informed about booking events, payment confirmations, waitlist updates, and more.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Muhammadbugaje/trustride/llms.txt
Use this file to discover all available pages before exploring further.
The chat feature is currently in a “coming soon” state in production. All chat URL patterns currently route to
views.coming_soon, which renders a placeholder page. The full chat implementation — including message sending, receipt upload, and WebSocket connectivity — is complete in the codebase and will be activated when the feature is officially launched.Chat Architecture
TrustRide’s real-time features are built on Django Channels with Redis as the channel layer backend. The ASGI application is configured intrust_ride/asgi.py using ProtocolTypeRouter to handle both HTTP and WebSocket connections.
AuthMiddlewareStack, which attaches the session user to the WebSocket scope. Unauthenticated connections and connections that fail authorization checks are closed immediately.
There are two categories of real-time consumers:
Chat Consumers
Handle per-booking, per-inquiry, and direct user-to-user message threads. Defined in
apps/chat/consumers.py.Notification Consumer
Pushes real-time notification events and unread-count updates to individual users. Defined in
apps/notifications/consumers.py.WebSocket URL Patterns
Chat WebSockets (apps/chat/routing.py)
| Pattern | Consumer | Description |
|---|---|---|
ws/chat/<booking_id>/ | ChatConsumer | Per-booking chat thread between rider and driver |
ws/inquiry/<thread_id>/ | InquiryConsumer | Pre-booking inquiry thread for a specific trip |
ws/direct/<user_id1>/<user_id2>/ | DirectChatConsumer | Direct message channel between any two users |
Notification WebSocket
TheNotificationConsumer uses a per-user group name (notifications_<user_id>) and is instantiated directly. It is not included in the current asgi.py routing but is ready to be wired in when the notifications WebSocket channel is activated.
All consumer classes share a BaseChatConsumer that handles connect/disconnect lifecycle, group membership, typing indicator broadcast, and message dispatch. Authorization is enforced by each subclass through the user_is_authorized() async method.
Booking Chat
Each booking gets a dedicated chat thread — a collection ofChatMessage records tied to the Booking — that lives for the duration of the booking’s lifecycle. The chat serves three primary purposes:
- Payment verification — the rider uploads their transfer receipt; the driver reviews and confirms
- Trip updates — the driver can send messages to the rider about pickup points, timing changes, or instructions
- Dispute resolution — in the event of a refund or complaint, the chat thread provides a full audit trail
Accessing a Booking Chat
chat_<booking_id>. Connect from the client with:
Inquiry Chat
Riders can ask questions about a trip before committing to a booking via an inquiry thread. AnInquiryThread is unique per (trip, rider, driver) combination, so opening the same inquiry twice returns the existing thread rather than creating a new one.
Starting an Inquiry
inquiry_<thread_id>.
Message Sending
All text messages are sent through a single unified POST endpoint that handles booking threads, inquiry threads, and direct messages based on the provided parameters.| Parameter | Required | Description |
|---|---|---|
booking_id | Conditional | UUID of the booking (for booking chat) |
thread_id | Conditional | UUID of the inquiry thread (for inquiry chat) |
recipient_id + is_direct=true | Conditional | Target user ID for direct messages |
message | Yes | The message text (cannot be empty) |
booking_id, thread_id, or recipient_id+is_direct must be provided. The response is an HTMX partial (chat/_message_list.html) containing the full updated message list, which replaces the message container in the UI without a page reload.
After saving the message, the server broadcasts it to the relevant WebSocket group via send_websocket_message:
Receipt Upload
Riders upload their payment receipt (JPEG, PNG, or PDF, max 5 MB) as a separate action:- Creates a
ChatMessagewithreceipt_imagepopulated andis_verified=False - Changes
booking.statustopending_verification - Posts a system message: “Receipt uploaded! Awaiting driver verification.”
- Fires a
receipt_uploadedWebSocket event to the booking’s channel
Payment Verification Action
The driver verifies payment directly from within the chat:payment_verified WebSocket event to all connected clients in the chat group.
Notifications
The notifications app (apps/notifications) handles in-app alerts for all platform events. Notifications are created via Notification.objects.create(...) in views and signals throughout the codebase.
Notification Types
| Type | When It Fires |
|---|---|
verification | Email verification requests |
booking | New booking created on a driver’s trip |
payment | Payment approved or rejected |
ride_available | A matching trip is published for a FutureTripInterest |
waitlist | A seat opens up for a waitlisted rider |
refund | Refund request received, approved, or rejected |
reminder | Pre-trip departure reminder |
system | Platform-wide announcements |
Notification Center
The full notification list is accessible at:NotificationCenterView is a LoginRequiredMixin class-based view that queries the authenticated user’s notifications and passes the unread count to the context.
HTMX Integration
TrustRide uses HTMX to update notification and chat UI components in real time without full page reloads.Live Thread List
chat/_thread_list.html) containing all booking threads, inquiry threads, and direct message threads for the current user, sorted by most recent activity. Used in the chat inbox sidebar to show unread counts and last message previews.
Notification Count Badge
Notification Dropdown
Mark as Read
Mark a Single Notification
notification.is_read = True and records read_at = timezone.now().
Mark All Notifications as Read
is_read=True in a single query.
Both endpoints are also supported over WebSocket via the NotificationConsumer. Clients can send action messages directly through the WebSocket connection:
count_update event containing the latest unread count after each action.