Mobile app for looking up Sri Lanka traffic fines, paying pending fines, and viewing an e-receipt.
This project is built with Expo + React Native and uses a simple backend API for fine lookup and payment processing.
- Fine lookup by reference number and category code
- Fine detail view with status, offence, driver, and vehicle data
- Payment form for pending fines
- Receipt screen after successful payment
- Cross-platform support: Android, iOS, and Web
- Custom font loading with splash screen handling
- Expo SDK 51
- React Native 0.74
- React 18
- React Navigation (native stack)
- Expo Google Fonts (DM Sans)
mobile-trafficpay/
App.js
app.json
package.json
assets/
src/
api.js
screens/
HomeScreen.js
FineDetailScreen.js
PaymentScreen.js
ReceiptScreen.js
- Node.js 18+
- npm 9+
- Expo CLI (optional, npx is enough)
- For Android emulator testing: Android Studio + emulator
- For iOS testing: macOS + Xcode
- Install dependencies:
npm install- Start the Expo development server:
npm run start- Run on a target platform:
npm run android
npm run ios
npm run webThe app reads backend URL from EXPO_PUBLIC_API_URL.
- If set, this value is used.
- If not set, defaults are:
- Android emulator:
http://10.0.2.2:5000/api - iOS/Web:
http://localhost:5000/api
- Android emulator:
$env:EXPO_PUBLIC_API_URL="http://192.168.1.20:5000/api"
npm run startset EXPO_PUBLIC_API_URL=http://192.168.1.20:5000/api
npm run startThe mobile app expects these backend endpoints:
GET /fines/lookup?ref=<reference>&category=<categoryCode>POST /payments/payGET /fines/categories
All endpoints are prefixed by the configured API base URL.
lookupFineexpects a JSON response with:success: booleanfineobject when successfulmessagewhen unsuccessful
processPaymentexpects:success: booleanreceiptobject when successfulmessagewhen unsuccessful
The payment screen includes a mock testing hint:
- Type
FAILin the card number to simulate payment failure (behavior depends on backend implementation).
npm run start- Start Expo dev servernpm run android- Open Android targetnpm run ios- Open iOS targetnpm run web- Open web build on port 8082
- App cannot reach API on Android emulator:
- Use
10.0.2.2instead oflocalhost.
- Use
- Physical device cannot reach local backend:
- Set
EXPO_PUBLIC_API_URLto your machine LAN IP.
- Set
- Font or splash issues:
- Clear Metro cache:
npx expo start -c
- Clear Metro cache:
- App display name and package are configured in
app.json. - Current Android package:
lk.police.trafficpay.
This project is currently unlicensed. Add a LICENSE file if you want to define usage terms.
