How sreevanib05/trackify420-public works
1. Overall shape
Trackify420 is a multi-client bus tracking system with one shared backend and three frontends: a React admin dashboard, a Flutter student app, and a Flutter driver app. The backend is the central authority for identity/session validation, trip state, route metadata, alerts, and live tracking.
2. Backend as the system core
The Node.js/Express backend owns the public API surface under /api/*, Socket.IO on /socket.io, and a separate raw WebSocket bridge under /ws. It is also responsible for Firebase Admin integration, JWT/session handling, and in-memory/managed state for live operational data.
3. Identity and session boundary
Firebase Auth is the primary identity provider for both Flutter apps and the dashboard. Backend middleware and auth routes convert that identity into application sessions/tokens, with a shared client key used by the mobile apps and backend to validate requests. This creates a clear boundary between Firebase-issued identity and Trackify-specific authorization/session state.
4. Operational state inside the backend
The backend has a dedicated state/ layer for live bus and trip logic: live locations, route reach timing, bus locks, trip start alerts, stopped-alert detection, attendance, announcements, ended trips, and the route catalog. These modules are the main data model for realtime operations and are what make the system more than a simple CRUD API.
5. Realtime tracking data flow
Driver-side location updates are published to the backend, which then updates live location/trip state and broadcasts changes to subscribed clients via Socket.IO. The admin dashboard and student app consume those updates for live maps, status cards, and arrival/boarding alerts. The raw /ws bridge exists as a secondary realtime channel for admin-oriented integration or compatibility scenarios.
6. Driver app responsibilities
The Flutter driver app is focused on authenticated session management, permissions, and foreground/background location publishing. Its services show the key flow: login/signup, session storage, route option selection, background location service, and socket publishing. The driver app is the upstream source of bus telemetry.
7. Student app responsibilities
The Flutter student app is a consumer-facing app for login/signup, profile completion, route selection, live map tracking, announcements, and push/boarding alerts. It uses backend APIs for session validation, student profile and trips data, and Socket.IO for live trip updates. It also bundles route JSON assets, so route visualization can work with local route geometry instead of relying only on the server.
8. Admin dashboard responsibilities
The React/Vite dashboard is the operational console for fleet monitoring, dashboards, attendance, drivers, students, announcements, and tracking views. It combines REST for persistent data, Socket.IO for realtime status, and a map component for live bus visualization. Its UI layer is split into pages, shared components, and small service modules that keep API/realtime access isolated.
9. Persistent vs transient data
Persistent data lives behind backend APIs and Firebase-backed services; transient data lives in backend state modules and websocket broadcasts. This split is important: user accounts, profiles, trips, routes, and announcements are API-backed, while live locations, lock decisions, alert windows, and reach-time calculations are realtime stateful concerns.
10. Route and map data
Route definitions are represented in two places: server-side route catalog/state and client-side assets. The student app includes many bundled route JSON files, while the dashboard includes route-specific data for map views. This suggests route geometry and route-option presentation are shared concepts but are not fully centralized in one datastore.
11. Notifications and alerts
The backend’s alert/announcement modules drive operational messaging, and the student app includes push notification services plus announcement read state. The system therefore separates broadcast/operational events from normal trip tracking, but both are part of the same backend-driven event model.
12. Tooling, tests, and deployment boundaries
The repo is structured as multiple independently runnable apps, each with its own package/configuration and platform build artifacts. The backend has tests for rate limiting, bus locks, reach times, and alert engines, indicating those are critical business rules. Deployment hints show a Render-style backend and a Vercel-style dashboard, while the Flutter apps target Android/iOS and use Firebase mobile config files.
Main entry points: index.js Server entry · buses.js Core APIs · socket.js Socket.IO · App.jsx Dashboard app
Components 26
Backend
Shared Node.js/Express API, auth, realtime, and operational state.
- Server entry · Starts the API server and wires routes, middleware, and realtime channels.
backend/src/index.js - Config · Central backend configuration and environment wiring.
backend/src/config.js - Firebase admin · Backend Firebase integration used for token and session validation.
backend/src/firebase.js - Auth middleware · Validates Firebase identity and access tokens before API handlers run.
backend/src/middleware/firebaseAuth.js - Auth API · Converts external identity into Trackify-specific auth and session state.
backend/src/routes/auth.js - Core APIs · Primary REST surface for buses, drivers, students, routes, trips, alerts, and announcements.
backend/src/routes/buses.js - Route catalog · Shared catalog of route definitions used by operational logic and clients.
backend/src/state/routesCatalog.js - Live state · Operational state for live locations, reach times, locks, alerts, attendance, and ended trips.
backend/src/state/liveLocations.js - Trip alerts · Trip start and stop-alert logic that drives operational notifications.
backend/src/state/tripStartAlerts.js - Announcements · Announcement lifecycle and read/visibility state for operational messaging.
backend/src/state/announcements.js - Socket.IO · Primary realtime channel for live tracking updates and status broadcasts.
backend/src/ws/socket.js - Raw WS bridge · Secondary WebSocket endpoint for admin compatibility or integration scenarios.
backend/src/ws/rawSocket.js
Admin Dashboard
React/Vite operational console for monitoring and management.
- Dashboard app · Vite-based admin UI shell for fleet operations and tracking.
admin-dashboard/src/App.jsx - API client · Dashboard service layer for REST-backed data access.
admin-dashboard/src/services/api.js - Realtime client · Dashboard realtime integration for live bus and trip updates.
admin-dashboard/src/services/realtime.js - Tracking map · Live bus visualization and map-centric tracking UI.
admin-dashboard/src/components/map/TrackingMap.jsx - UI store · Shared dashboard state for buses, students, drivers, and tracking views.
admin-dashboard/src/store/useTrackifyStore.js
Driver App
Flutter client that authenticates and publishes bus telemetry.
- Driver app · Driver-facing Flutter app for auth, permissions, and telemetry publishing.
flutter/driver_app/lib/main.dart - Driver auth · Login, signup, session storage, and session guarding for drivers.
flutter/driver_app/lib/services/auth_session_service.dart - Location service · Foreground/background location collection and publish flow from the driver device.
flutter/driver_app/lib/services/background_location_service.dart - Driver socket · Publishes telemetry and session updates to the backend realtime channel.
flutter/driver_app/lib/services/socket_service.dart
Student App
Flutter client that consumes live tracking, announcements, and profile data.
- Student app · Student-facing Flutter app for tracking, route selection, and alerts.
flutter/student_app/lib/main.dart - Student auth · Login, signup, profile completion, and session handling for students.
flutter/student_app/lib/services/auth_session_service.dart - Route assets · Bundled route JSON and route asset loading for offline-capable map presentation.
flutter/student_app/lib/services/route_asset_service.dart - Live tracking · Consumes live trip updates and alert events from the backend.
flutter/student_app/lib/services/socket_service.dart - Alerts & notices · Push notifications, announcement state, and boarding alert presentation.
flutter/student_app/lib/services/push_notification_service.dart
Connections 35
- Server entry → Config: loads · Bootstrapping depends on runtime configuration.
- Server entry → Auth middleware: uses · API requests pass through authentication middleware.
- Server entry → Auth API: mounts · Exposes auth/session endpoints.
- Server entry → Core APIs: mounts · Exposes the main REST API surface.
- Server entry → Socket.IO: opens · Serves the primary Socket.IO realtime channel.
- Server entry → Raw WS bridge: opens · Serves the secondary raw WebSocket bridge.
- Auth API → Firebase admin: verifies · Translates Firebase identity into application auth state.
- Auth middleware → Firebase admin: checks · Validates Firebase-issued tokens and session claims.
- Core APIs → Route catalog: reads · Route-related endpoints depend on route metadata.
- Core APIs → Live state: reads/writes · Operational endpoints update and read live trip state.
- Core APIs → Trip alerts: uses · Trip endpoints trigger alert and reach-time logic.
- Core APIs → Announcements: uses · Announcement endpoints manage broadcast state.
- Socket.IO → Live state: broadcasts · Realtime updates are emitted from live operational state.
- Socket.IO → Trip alerts: emits · Alert engine events are pushed to connected clients.
- Raw WS bridge → Live state: bridges · Secondary realtime channel reflects live state updates.
- Dashboard app → API client: calls · Dashboard pages load persistent data through REST.
- Dashboard app → Realtime client: subscribes · Dashboard listens for live bus and trip changes.
- Dashboard app → UI store: uses · UI state coordinates operational views and filters.
- Dashboard app → Tracking map: renders · Tracking pages visualize live movement on a map.
- API client → Core APIs: requests · Dashboard REST calls target the backend API.
- Realtime client → Socket.IO: connects · Dashboard realtime client connects to Socket.IO.
- Driver app → Driver auth: uses · Driver UI depends on session and auth state.
- Driver app → Location service: publishes · Driver app collects and streams location telemetry.
- Driver app → Driver socket: connects · Driver app sends realtime updates through sockets.
- Driver auth → Auth API: authenticates · Driver sessions are established through backend auth endpoints.
- Driver socket → Socket.IO: streams · Driver telemetry feeds the realtime backend.
- Location service → Live state: updates · Location updates drive live bus and trip state.
- Student app → Student auth: uses · Student UI depends on account and session state.
- Student app → Route assets: loads · Student maps use bundled route geometry assets.
- Student app → Live tracking: subscribes · Student app consumes live trip updates.
- Student app → Alerts & notices: shows · Student app surfaces announcements and boarding alerts.
- Student auth → Auth API: authenticates · Student identity is converted into Trackify sessions.
- Live tracking → Socket.IO: listens · Student app receives live tracking events from Socket.IO.
- Alerts & notices → Announcements: syncs · Announcement and alert state is backed by the server.
- Route assets → Route catalog: matches · Bundled client routes mirror server route metadata.