How detrogo/detrogo-react-native works
Purpose and Runtime
DetroGo is an offline-first Delhi-NCR metro route-planning mobile app. It uses React Native, Expo, TypeScript, and Expo Router; native Android development-client builds are required for custom native functionality. Primary app configuration is app.json, with router entry layout at app/_layout.tsx.
Navigation and User Journeys
Expo Router screens define the app flow: onboarding, tabbed home/settings, station/route planning, route detail, and system-map views.
• Root and tab navigation: app/_layout.tsx, app/(tabs)/_layout.tsx
• Primary search/home UI: app/(tabs)/index.tsx, components/homescreenui.tsx
• Planning and presentation screens: app/planner.tsx, app/route.tsx, app/listpage.tsx
• First-run gating: app/onboarding.tsx
Transit Data Boundary
City-specific static datasets are the authoritative offline transit graph and display metadata. Delhi is currently the supported city; the city registry enables expansion without changing routing consumers.
• City registry: cities/index.ts
• Delhi topology and stations: cities/delhi/stationsdata.json, cities/delhi/lines.json, cities/delhi/metrolines.json
• Geometry and line metadata: cities/delhi/shapes.ts, cities/delhi/stationshapes.ts, cities/delhi/lineMeta.ts
Route Computation Pipeline
The planner takes selected origin/destination stations, resolves them against city data, and computes routes through the custom BFS/Dijkstra routing engine. Route domain contracts separate graph/routing results from screen rendering.
• Routing engine: utils/metroRouting.ts
• Route and routing types: types/route.ts, types/routing.ts, types/index.ts
• Geographic nearest-station lookup: utils/nearestStation.ts, store/useNearestStationStore.ts
The important boundary is static city data → routing utility → typed route result → planner/detail UI. GPS is used locally only to improve station selection; no backend is required for core routing.
Persistence and App State
Zustand-style stores own user-local state and persistence: onboarding completion, preferences, saved routes, and recent-trip history. This keeps route calculation/data independent of UI session state.
• Storage adapter: store/storage.ts
• Preferences and onboarding: store/usePrefStore.ts, store/onboarding.ts
• Route history/library: store/recentTrips.ts, store/savedRoutes.ts
Maps, Rendering, and Themes
The app exposes an in-app transit map and route schematic presentation. A bundled web renderer is present under assets/routemap, while MapLibre is the declared map-rendering technology. Material 3, dynamic colors, and AMOLED behavior are centralized outside feature screens.
• Bundled route-map renderer: assets/routemap/index.html, assets/routemap/assets/index-C3YrQ63w.js
• Theme/color system: constants/theme.ts, constants/m3Colors.ts, hooks/useAppTheme.ts
• AMOLED preference/rendering: constants/amoled.ts, hooks/useAmoled.ts
Notifications, Localization, and External Services
A local Expo native module package implements live-update notifications on Android, including Firebase token/service integration; route notification utilities connect app route state to that capability. Crowdin manages translation workflow; locale JSON is bundled with the app.
• Notification integration: utils/detroLiveNotif.ts, utils/routeNotification.ts
• Native live-update module: packages/expo-live-updates/android/src/main/java/expo/modules/liveupdates/ExpoLiveUpdatesModule.kt, packages/expo-live-updates/android/src/main/java/expo/modules/liveupdates/FirebaseService.kt
• Localization resources: i18n/locales/en.json, i18n/locales/hi.json, crowdin.yml
Main entry points: planner.tsx Planner and route views · _layout.tsx Root navigation · index.tsx Station search home · usePrefStore.ts Local state stores
Components 19
Mobile app
Expo Router mobile client.
- Expo app config · Requires Android development-client builds for native functionality.
app.json - Root navigation
app/_layout.tsx - Home and settings tabs
app/(tabs)/_layout.tsx - Station search home
app/(tabs)/index.tsx - Onboarding screen · Gates first-run access.
app/onboarding.tsx - Planner and route views
app/planner.tsx
Offline routing
Static Delhi transit data and local route computation.
- City registry · Selects the supported city dataset.
cities/index.ts - Delhi transit graph · Authoritative stations, topology, and line definitions.
cities/delhi/stationsdata.json - Geometry and line metadata
cities/delhi/shapes.ts - BFS/Dijkstra engine · Computes routes entirely on-device.
utils/metroRouting.ts - Route contracts · Separates routing results from screen rendering.
types/route.ts - Nearest-station lookup · Uses GPS locally to improve station selection.
utils/nearestStation.ts
State and presentation
Local persistence, themes, and map rendering.
- Local state stores · Owns onboarding, preferences, saved routes, and history.
store/usePrefStore.ts - Persistence adapter
store/storage.ts - Theme system · Centralizes Material 3, dynamic color, and AMOLED behavior.
hooks/useAppTheme.ts - Bundled route-map renderer · In-app schematic and transit-map presentation.
assets/routemap/index.html
Native and localization
Android live updates and bundled translations.
- Route notifications · Connects route state to live-update capability.
utils/routeNotification.ts - Android live-update module · Provides Firebase-backed live-update notifications.
packages/expo-live-updates/android/src/main/java/expo/modules/liveupdates/ExpoLiveUpdatesModule.kt - Bundled locales · English and Hindi app translations.
i18n/locales/en.json
Connections 22
- Expo app config → Root navigation: launches
- Root navigation → Home and settings tabs: hosts
- Root navigation → Onboarding screen: routes to
- Home and settings tabs → Station search home: shows
- Station search home → Planner and route views: starts planning
- City registry → Delhi transit graph: selects
- Delhi transit graph → Geometry and line metadata: supports display
- Delhi transit graph → BFS/Dijkstra engine: provides graph
- BFS/Dijkstra engine → Route contracts: returns typed results
- Nearest-station lookup → BFS/Dijkstra engine: selects origin
- Route contracts → Planner and route views: renders
- Nearest-station lookup → Station search home: suggests station
- Local state stores → Persistence adapter: persists through
- Local state stores → Onboarding screen: tracks completion
- Local state stores → Planner and route views: stores saved and recent routes
- Theme system → Station search home: styles
- Geometry and line metadata → Bundled route-map renderer: drives schematic
- Bundled route-map renderer → Planner and route views: presents map
- Planner and route views → Route notifications: configures alerts
- Route notifications → Android live-update module: invokes
- Expo app config → Android live-update module: includes native build
- Bundled locales → Root navigation: localizes screens