adityanandanx / adityanandanx/raftaar

6. Trip Start (QR Code Unlock)

Open
#7 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Parent PRD

#1

## What to build

Trip initiation by scanning QR code. When customer scans the QR code printed on a bike, the app sends the QR hash to backend, which verifies it matches the reserved bike and starts the trip. Trip timer begins counting and shows running cost estimate.

Implements QR code validation, trip state machine (reserved → in_progress), and frontend QR scanner with live cost ticker.

## Acceptance criteria

- [ ] `POST /trips/start` accepts qr_code_hash (JWT required)
- [ ] Validates QR code matches active reservation
- [ ] Creates trip record with start_time, start_station_id, user_id, bike_id, status='in_progress'
- [ ] Response includes: trip_id, start_time, bike_id, station_name
- [ ] Fails if: no active reservation, QR doesn't match, bike not available, reservation expired
- [ ] Bike status changes from 'available' → 'in_use'
- [ ] Reservation is marked as 'completed'
- [ ] Frontend: QR scanner component (uses device camera)
- [ ] Frontend: Trip in progress screen showing: elapsed time, current cost estimate, end trip button
- [ ] Frontend: Cost estimate updates every second: Cost = 2 + max(0, (elapsed_min - 20) * 0.20)
- [ ] Database schema: `trips` (id, user_id, bike_id, start_station_id, end_station_id, start_time, end_time, duration_minutes, cost, status)
- [ ] Edge case: customer tries to start trip with wrong QR code

## Blocked by

- Blocked by #5 (Reservation - needs active reservation)
- Blocked by #2 (Authentication - needs user context)

## User stories addressed

- User story 7: Unlock bike by scanning QR code
- User story 8: Trip timer starts automatically
- User story 13: See estimated cost before booking (live estimate during trip)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.