Finite ride state machine
- Why
- Avoid fragile ad-hoc status flags and make invalid transitions explicit.
- Trade-off
- Adds upfront modelling, but makes testing and future policy rules easier.
Dissertation system
Low-acuity transport requests need clear ownership, controlled state, and an audit trail.
RIDE REQUEST #014
Second accept attempt → rejected
One ride through the system
One request enters. One volunteer owns it. Every state change is bounded. Every important event leaves evidence.
POST /api/ride
Pickup, destination, reason, mobility note.
Guarded accept.
One volunteer becomes the owner.
Finite transitions.
Terminal states block outgoing moves.
Notifications are sent and stored.
Payloads stay minimal.
History, timestamps, role-aware reads, and tests make the workflow reviewable.
System layers
Supporting structure behind the lifecycle.
Request layer
Assignment layer
State layer
Communication layer
Navigation layer
Governance layer
Technical decisions
Finite ride state machine
Atomic accept endpoint
Open in Maps handoff
Expo notifications instead of chat
SQLite for MVP
Constrained leaderboard
Implementation
A patient creates a ride request with pickup, destination, reason, and optional mobility note. The server stores it as pending. Volunteers fetch pending rides and one volunteer can accept. Acceptance is guarded so a second accept attempt fails deterministically. The ride then moves through a finite state machine, while notifications and audit records make key changes visible.
API flow
State machine
Requested → Accepted → EnRoute → PickedUp → Completed. Cancelled can be reached from active states. Completed and Cancelled are terminal.
Invariants
Evidence from the build
Measured claims from tests, checks, and governance framing.
State machine
27 Jest tests, 100% coverage.
Transitions, invalid moves, self-transitions, and unknown states are handled.
API
22 Supertest cases.
Register/login, ride lifecycle, double accept, repeat completion, role-scoped reads, notifications, and leaderboard.
Accessibility
Contrast CLI, target-size checks, focus visibility, accessibility screen.
The MVP considered WCAG 2.2 requirements from the start.
Performance
Cold-start p50/p95 measurement.
The app was measured against a defined p95 target rather than guessed.
Security / governance
Privacy minimisation, role-aware endpoints, STRIDE-style threat model, DPIA framing.
The system boundary and pilot risks were considered explicitly.
Pilot boundary
VAS is not a production transport service. It does not include identity proofing, DBS checks, insurance verification, geofencing, continuous GPS tracking, complex eligibility gating, or live operator tooling. Roles are controlled for the MVP, and usability evaluation was limited to lab-style testing and role-play because real patient evaluation would require ethics and governance approval.
Identity & safeguarding
No DBS, insurance, licence, or volunteer verification in the MVP.
Location & eligibility
No geofencing, continuous GPS, or complex eligibility gating.
Governance
No real patient evaluation without ethics, DPIA, privacy notice, and partner approval.
Infrastructure
SQLite is suitable for dissertation testing; a pilot would need managed storage, migrations, retention policy, and audit-grade logs.
Next iteration
Volunteer onboarding and verification
Identity checks, DBS where applicable, insurance/licence checks, safeguarding training.
Operator oversight view
Admin queue, manual intervention, no-show handling, anomaly review.
Managed data layer
Move from SQLite to managed relational storage with migrations, retention policy, and audit-grade logs.
Security hardening
Rate limits, structured errors, stronger auth, role administration, abuse monitoring.
Accessibility audit
External WCAG review, automated checks for labels/focus, wider device testing.
Pilot governance
DPIA completion, privacy notice, university/partner ethics, retention schedule, monitored pilot metrics.
What this project proves
I can take an operationally sensitive workflow and reduce it into actors, state, ownership, boundaries, tests, and evidence. This was not about building a mobile UI first. It was about making a coordination process legible enough to test, audit, and improve.