Skip to main content

Bikun Tracker Frontend V2

Client-facing web app for the Bikun shuttle system. It consumes live state from the backend, renders the map and bus status, and keeps the user experience fast enough for real-time tracking.

At a Glance

AreaDetails
RoleLive map, schedules, reporting, and auth entrypoint
RuntimeReact 19 + TypeScript + Vite
RoutingTanStack React Router
StateZustand
StylingTailwind CSS v4
Map layerLeaflet
Main consumersStudents, staff, and Bikun administrators

What It Does

  • Shows live bus positions on an interactive map.
  • Keeps a persistent connection to backend real-time updates.
  • Handles authentication through UI CAS.
  • Presents schedules and bus operational information.
  • Uses local interpolation so bus movement feels smooth between updates.

User Flow

  1. The user opens the dashboard and authenticates through UI SSO.
  2. The app fetches the static route and account data it needs.
  3. The browser subscribes to live updates from the backend WebSocket.
  4. Map markers and status cards update as new coordinates arrive.
  5. Reporting and schedule screens reuse the same authenticated session.

Backend Dependencies

DependencyUsed For
Backend V2 REST APIBuses, auth, and schedule data
Backend V2 WebSocketLive location updates
UI CASSign-in and session bootstrap

Project Structure

PathResponsibility
src/routesRoute entrypoints and page composition
src/common/componentsShared map, modal, drawer, and navbar pieces
src/common/constantsStatic route and map configuration
src/common/dataBus stop and route definitions
src/common/hooksWebSocket, animation, and UI logic hooks
src/common/schemaZod validation for auth and socket payloads
src/lib/storeZustand stores for auth and global app state
src/servicesAPI and utility wrappers

Key Components

  • main.tsx: app bootstrap.
  • __root.tsx: top-level route shell.
  • index.tsx: dashboard entry page.
  • bus-schedule.tsx: schedule browsing.
  • report.tsx and create-report.tsx: reporting flows.
  • sso-login.tsx: login entry and redirect handling.

Operational Notes

Environment Variables

KeyPurposeNotes
DAMRI_APIDamri GPS API base URLShared backend dependency in docs
DAMRI_LOGIN_USERNAMEDamri usernameSecret value, not committed
DAMRI_LOGIN_PASSWORDDamri passwordSecret value, not committed
WS_URLExternal GPS WebSocket URLUsed for live connection testing
RM_APILane detection service URLShared backend dependency
PRINT_CSV_LOGSEnable CSV loggingDebug only
PORTLocal dev portDefault app port
DB_HOSTDatabase hostDev environment only
DB_NAMEDatabase nameDev environment only
DB_USERDatabase usernameDev environment only
DB_PASSWORDDatabase passwordSecret value, not committed

Notes

  • The frontend is a consumer of the backend, so it does not own the authoritative bus state.
  • Live behavior should always be validated against the backend and WebSocket contract.
  • The map experience should stay minimal and readable, because this page is used in motion-heavy contexts.