- Docs
- Domain
- Bounded contexts
Bounded Contexts¶
TyteRide is split into bounded contexts to keep ownership clear and prevent direct cross-domain coupling. This page summarizes the contexts defined in the domain glossary and system architecture.
1. Context map¶
| Context | Owns | Key entities |
|---|---|---|
| Identity & Enrollment | Phone/OTP auth, users, memberships, company codes, approval queue | User, Company, Membership, CompanyCode |
| Fleet | Vehicles and Drivers owned by a company | Vehicle, Driver membership |
| Trips & Booking | Routes, trips, trip groups, bookings, deadlines, duplication, extra cars | NavRoute, Trip, Booking, CarRequest |
| Live Ops | GPS publishing, realtime channels, boarding, Driver feedback | TripTracking, Boarding event, feedback |
| D2D | Company D2D settings, eligibility, pickup/drop-off points, request approval, detour estimation, route plan | D2DSettings, D2DRequest, RoutePlan legs |
| Billing & Tiers | Tiers, seat limits, subscription status, suspension | SubscriptionTier, Company status |
| Reviews & Analytics | Post-trip ratings and computed trip metrics | Review, TripAnalysis |
2. Context relationships¶
flowchart LR
IE[Identity & Enrollment]
BT[Billing & Tiers]
FL[Fleet]
TB[Trips & Booking]
D2D[D2D]
LO[Live Ops]
RA[Reviews & Analytics]
IE -->|company, membership, approval| BT
IE -->|approved Driver/Passenger identity| FL
IE -->|approved Passenger can book| TB
BT -->|tier/seat/suspension constraints| IE
BT -->|suspension blocks operations| TB
FL -->|vehicles and Drivers| TB
TB -->|trip and booking facts| D2D
D2D -->|eligible D2D points, detour, route plan| TB
TB -->|active trip and manifest| LO
LO -->|boarding and live events| TB
TB -->|completed trip facts| RA
LO -->|tracking/operational signals| RA
D2D -->|D2D detour metrics| RA
3. Communication rules¶
- Use application services and domain events for cross-context communication. A context should expose behavior through application services or publish/consume domain events rather than reaching directly into another context's internal models.
- Do not use direct model reach-through as integration. Reading or mutating another context's tables/models as a shortcut couples invariants and makes boundaries meaningless.
- Respect ownership. For example, Billing & Tiers owns seat-limit decisions, Trips & Booking owns booking lifecycle, and Live Ops owns realtime/boarding signals. Consumers should request decisions or react to events.
- Tenant isolation crosses all contexts. Company scope is a system-wide constraint; context boundaries do not permit cross-company access.
4. Boundary notes¶
- Identity & Enrollment vs Billing & Tiers: Enrollment creates memberships and approval flow, but tier seat limits and suspension decisions are Billing & Tiers constraints.
- Trips & Booking vs D2D: Trips & Booking owns bookings and trip selection; D2D owns company settings, eligibility checks, the D2D request lifecycle, detour estimation, and route-plan leg generation. A D2D Request references an approved Booking but does not mutate it; D2D rules are not duplicated ad hoc.
- Live Ops vs Trips & Booking: Live Ops emits boarding/GPS/feedback events; Trips & Booking remains the source for trip/booking records.
- Reviews & Analytics is downstream: It consumes completed trip and operational facts; it should not control booking or live operations.