Skip to content

A React Native Transport Tracker app built with Expo SDK 52 and Supabase. Track routes, stops, travel times, and more to analyze your public transport commutes. Inspired by personal travel experiences.

Notifications You must be signed in to change notification settings

Simplegram/react-transport-tracker

Repository files navigation

Transport Tracker App

Based on my personal experience as a former public transport commuter. I used to travel to and from Gading Serpong, Tangerang (a Jakarta satellite city) and Kemang, South Jakarta.

Table of Contents

Get started

This app uses Expo SDK 52.

  1. Install dependencies

    npm install
  2. Start the app

     npx expo start

You can start developing by editing the files inside the app directory. This project uses file-based routing.

Packages Used

  • @expo/vector-icons
  • @maplibre/maplibre-react-native
  • @react-native-async-storage/async-storage
  • @react-native-community/datetimepicker
  • @react-native-picker/picker
  • @react-navigation/bottom-tabs
  • @react-navigation/native
  • @rneui/themed
  • @supabase/supabase-js
  • expo
  • expo-blur
  • expo-build-properties
  • expo-constants
  • expo-dev-client
  • expo-font
  • expo-haptics
  • expo-linking
  • expo-router
  • expo-splash-screen
  • expo-status-bar
  • expo-symbols
  • expo-system-ui
  • expo-updates
  • expo-web-browser
  • moment
  • moment-timezone
  • react
  • react-dom
  • react-native
  • react-native-calendars
  • react-native-gesture-handler
  • react-native-keyboard-aware-scroll-view
  • react-native-loading-spinner-overlay
  • react-native-mmkv-storage
  • react-native-pager-view
  • react-native-safe-area-context
  • react-native-screens
  • react-native-vector-icons
  • react-native-web
  • react-native-webview
  • expo-location

Create Supabase Tables

Create Schema

CREATE SCHEMA public_transport_tracker;
GRANT ALL ON ALL TABLES IN SCHEMA public_transport_tracker TO authenticated;

Directions Table

create table
  public_transport_tracker.directions (
    id bigint generated by default as identity not null,
    name text not null,
    constraint directions_pkey primary key (id)
  ) tablespace pg_default;

Icons Table

create table
  public_transport_tracker.icons (
    id bigint generated by default as identity not null,
    name text not null,
    constraint icons_pkey primary key (id)
  ) tablespace pg_default;

Vehicle Types Table

create table
  public_transport_tracker.types (
    id bigint generated by default as identity not null,
    name text not null,
    icon_id bigint null,
    constraint type_pkey primary key (id),
    constraint types_icon_id_fkey foreign key (icon_id) references public_transport_tracker.icons (id) on update cascade on delete set null
  ) tablespace pg_default;

Stops Table

create table
  public_transport_tracker.stops (
    id bigint generated by default as identity not null,
    name text not null default ''::text,
    lat double precision null,
    lon double precision null,
    name_alt text null,
    vehicle_type bigint null,
    constraint stops_pkey primary key (id),
    constraint stops_vehicle_type_fkey foreign key (vehicle_type) references public_transport_tracker.types (id)
  ) tablespace pg_default;

create index if not exists stops_vehicle_type_idx on public_transport_tracker.stops using btree (vehicle_type) tablespace pg_default;

Routes Table

create table
  public_transport_tracker.routes (
    id bigint generated by default as identity not null,
    first_stop_id bigint not null,
    last_stop_id bigint not null,
    code text null,
    name text null,
    vehicle_type_id bigint null,
    constraint routes_pkey primary key (id),
    constraint routes_first_stop_id_fkey foreign key (first_stop_id) references public_transport_tracker.stops (id),
    constraint routes_last_stop_id_fkey foreign key (last_stop_id) references public_transport_tracker.stops (id),
    constraint routes_vehicle_type_id_fkey foreign key (vehicle_type_id) references public_transport_tracker.types (id)
  ) tablespace pg_default;

create index if not exists routes_first_stop_id_idx on public_transport_tracker.routes using btree (first_stop_id) tablespace pg_default;

create index if not exists routes_last_stop_id_idx on public_transport_tracker.routes using btree (last_stop_id) tablespace pg_default;

create index if not exists routes_vehicle_type_id_idx on public_transport_tracker.routes using btree (vehicle_type_id) tablespace pg_default;

Travels Table

create table
  public_transport_tracker.travels (
    id bigint generated by default as identity not null,
    created_at timestamp with time zone not null default now(),
    bus_initial_arrival timestamp without time zone null,
    bus_initial_departure timestamp without time zone null,
    bus_final_arrival timestamp without time zone null,
    route_id bigint not null,
    first_stop_id bigint not null,
    last_stop_id bigint not null,
    notes text null,
    vehicle_code text null,
    direction_id bigint not null,
    type_id bigint not null,
    constraint travels_pkey primary key (id),
    constraint travels_route_id_fkey foreign key (route_id) references public_transport_tracker.routes (id),
    constraint travels_first_stop_id_fkey foreign key (first_stop_id) references public_transport_tracker.stops (id),
    constraint travels_last_stop_id_fkey foreign key (last_stop_id) references public_transport_tracker.stops (id),
    constraint travels_direction_id_fkey foreign key (direction_id) references public_transport_tracker.directions (id),
    constraint travels_type_id_fkey foreign key (type_id) references public_transport_tracker.types (id)
  ) tablespace pg_default;

create index if not exists travels_id_idx on public_transport_tracker.travels using btree (id) tablespace pg_default;

create index if not exists travels_type_id_idx on public_transport_tracker.travels using btree (type_id) tablespace pg_default;

create index if not exists travels_last_stop_id_idx on public_transport_tracker.travels using btree (last_stop_id) tablespace pg_default;

create index if not exists travels_first_stop_id_idx on public_transport_tracker.travels using btree (first_stop_id) tablespace pg_default;

create index if not exists travels_direction_id_idx on public_transport_tracker.travels using btree (direction_id) tablespace pg_default;

create index if not exists travels_route_id_idx on public_transport_tracker.travels using btree (route_id) tablespace pg_default;

Laps Table

create table
  public_transport_tracker.laps (
    id bigint generated by default as identity not null,
    travel_id bigint not null,
    time timestamp without time zone not null,
    note text null,
    stop_id bigint null,
    constraint laps_pkey primary key (id),
    constraint laps_travel_id_fkey foreign key (travel_id) references public_transport_tracker.travels (id),
    constraint laps_stop_id_fkey foreign key (stop_id) references public_transport_tracker.stops (id)
  ) tablespace pg_default;

create index if not exists laps_travel_id_idx on public_transport_tracker.laps using btree (travel_id) tablespace pg_default;

Build Preview APK

With EAS

You need to specify extra.eas.projectId and updates.url on your app.config.js file

  1. Pull latest environment variables from EAS server

    npx eas env:pull --environment preview
  2. Update EAS server with latest commit

    npx eas update --environment preview
  3. Start build queue

    npx eas build --profile preview --platform android

With Android Studio

When you're ready to build the APK, run:

npx expo prebuild --clean

This command will create the android folder necessary to build with Android Studio. Close any npx expo start instance to avoid Android Studio gradle import error.

About

A React Native Transport Tracker app built with Expo SDK 52 and Supabase. Track routes, stops, travel times, and more to analyze your public transport commutes. Inspired by personal travel experiences.

Resources

Stars

Watchers

Forks