How hyraxhomie/fly-over-ts works
1. Two runtime pieces
- The repo is split into a browser client (src/) and an optional Node host server (server/index.mjs).
- The client is a Vite + React + TypeScript single-page app.
- The server serves the built app and acts as an OpenSky proxy/cache layer for production/home hosting.
2. Primary product shape
- This is a flight-visualization dashboard, not a general CRUD app.
- The user enters an address, the app geocodes it, then shows aircraft near that point on a map.
- The UI can run in Live mode from OpenSky or Demo mode from an internal simulation.
3. Client-side architecture
- src/main.tsx bootstraps the app and src/App.tsx wires the top-level layout and state flow.
- Most visible behavior is split into small presentational components:
- MapView.tsx for the map and aircraft rendering
- FlightList.tsx and FlightDetail.tsx for sidebar/list inspection
- SearchBar.tsx for location entry
- StatusBar.tsx for mode/feed status and controls
4. Core orchestration hook
- src/hooks/useFlights.ts is the main client-side state engine.
- It owns both data sources:
- Live: periodically polls OpenSky for the current region
- Demo: seeds and updates a self-contained mock fleet
- It also drives smooth animation by advancing aircraft positions between polls with requestAnimationFrame.
5. Data flow from address to aircraft
- User enters or selects an address in SearchBar.
- The app geocodes the address via src/lib/geocode.ts using Nominatim / OpenStreetMap.
- The resulting lat/lng becomes the home location, which is persisted locally and can be deep-linked via query parameters.
- src/lib/geo.ts computes the bounding box around that home position for the aircraft query.
6. Live aircraft pipeline
- src/lib/opensky.ts fetches OpenSky /states/all for the current bounding box.
- Raw state vectors are normalized into app-specific Flight objects defined in src/types.ts.
- src/lib/mockFlights.ts contains deadReckonFlights, which keeps motion fluid by extrapolating velocity between network updates.
7. Map rendering boundary
- src/components/MapView.tsx is the visual boundary between app state and Leaflet.
- It renders:
- the selected home marker
- a range/bounding ring
- aircraft icons rotated by heading
- The map uses react-leaflet / Leaflet with a dark CARTO basemap, so map rendering is a distinct subsystem from the flight logic.
8. State persistence and user-facing continuity
- The app remembers the user’s address/location in localStorage so it reopens ready for use.
- It also supports sharing/bookmarking via URL parameters (lat, lng, label), which makes location state part of the app boundary rather than ephemeral UI state.
9. Live-vs-demo mode boundary
- StatusBar.tsx exposes the Live/Demo switch and feed status.
- Demo mode is not just a UI mock; it uses the same display pipeline as live flights, which keeps the map and sidebar behavior consistent.
- This makes the data source swappable while preserving the rest of the app architecture.
10. Server responsibilities
- server/index.mjs is the production/home-serving boundary.
- It has three jobs:
- serve static built assets
- proxy OpenSky requests
- enforce bbox validation and short shared caching
- In production, this is important because the browser cannot directly call OpenSky reliably due to CORS and rate limits.
11. OpenSky credentials and rate control
- Anonymous OpenSky usage is constrained, so the server can authenticate with OPENSKY_CLIENT_ID and OPENSKY_CLIENT_SECRET.
- The cache TTL and the client’s visibility-aware polling reduce upstream calls.
- This means the architecture intentionally places sensitive credentials and upstream access server-side only.
12. Development vs production path
- In development, Vite proxies /opensky/* directly to OpenSky.
- In production/home hosting, the bundled Node server becomes the proxy and static host.
- The client can also be pointed at a different proxy through VITE_OPENSKY_BASE, so the app is designed around a configurable API edge.
13. Performance-sensitive behavior
- Aircraft marker positions are updated cheaply; the app avoids rebuilding map icons on every frame.
- Motion is throttled with a configurable frame rate and pauses when the tab is hidden.
- These choices matter because the main interaction is continuous animation, not static data display.
14. Diagram-friendly subsystem summary
- Input layer: address/search, URL params, localStorage
- Geocoding layer: Nominatim
- Flight data layer: OpenSky live feed or mock simulation
- Motion layer: dead-reckoning / frame interpolation
- Presentation layer: React UI + Leaflet map + flight sidebar
- Edge/server layer: static hosting + authenticated cached OpenSky proxy
Main entry points: App.tsx App shell · useFlights.ts Flight engine · index.mjs Host server · SearchBar.tsx Search
Components 18
Browser client
Vite + React SPA that geocodes a home location and visualizes nearby aircraft.
- Entry · Bootstraps the browser app.
src/main.tsx - App shell · Wires top-level layout, location state, and flight flow.
src/App.tsx - Flight engine · Main client-side state engine for live/demo data and animation.
src/hooks/useFlights.ts - Local storage · Persists the last chosen location in the browser.
- URL params · Carries lat, lng, and label for bookmarking and deep links.
Node host
Optional production/home server that serves the app and proxies OpenSky.
- Host server · Serves static assets and proxies cached OpenSky requests.
server/index.mjs
Flight data
External and internal flight sources plus normalization and motion helpers.
- Geocode · Resolves addresses to latitude and longitude via OpenStreetMap.
src/lib/geocode.ts - Bounds · Computes the query bounding box around the home location.
src/lib/geo.ts - OpenSky · Fetches and normalizes OpenSky state vectors for the current area.
src/lib/opensky.ts - Mock motion · Seeds demo flights and dead-reckons motion between updates.
src/lib/mockFlights.ts - Flight types · Shared flight and app domain types.
src/types.ts
UI presentation
Top-level UI shell and visible flight/map components.
- Search · Accepts and selects addresses for the home location.
src/components/SearchBar.tsx - Status · Shows feed status and toggles Live/Demo mode.
src/components/StatusBar.tsx - Map view · Renders the home marker, range ring, and aircraft on the map.
src/components/MapView.tsx - Flight list · Lists nearby aircraft for inspection.
src/components/FlightList.tsx - Flight detail · Shows selected aircraft details.
src/components/FlightDetail.tsx - Leaflet map · Interactive map rendering backend used by the map view.
- Dark basemap · Dark CARTO tile layer used by the map.
Connections 21
- Entry → App shell: mounts · Entry point renders the application shell.
- App shell → Search: location input · Top-level shell passes search interaction into the UI.
- App shell → Status: mode/status · Shell exposes feed state and Live/Demo switching.
- App shell → Map view: visualizes · Shell sends flight and home state to the map.
- App shell → Flight list: lists · Shell feeds nearby flights into the sidebar list.
- App shell → Flight detail: inspects · Shell routes selection into the detail panel.
- App shell → Flight engine: state flow · App delegates flight sourcing and animation to the hook.
- Search → Geocode: resolves · Address entry is turned into coordinates.
- Search → URL params: deep link · Location can be represented in query parameters.
- App shell → Local storage: remembers · Chosen location is persisted for reopening.
- Flight engine → Bounds: queries area · Home location becomes the aircraft search bounds.
- Flight engine → OpenSky: live feed · Live mode polls OpenSky for aircraft in range.
- Flight engine → Mock motion: demo feed · Demo mode seeds and advances a self-contained fleet.
- Flight engine → Flight types: models · Normalized flight state uses shared domain types.
- Mock motion → Flight types: emits · Demo simulation produces app flight objects.
- OpenSky → Flight types: normalizes · Raw OpenSky vectors are mapped into app models.
- Map view → Leaflet map: renders on · Map view is the React boundary around Leaflet.
- Map view → Dark basemap: tiles · Map uses a dark CARTO basemap.
- Host server → OpenSky: proxies · Server forwards and caches OpenSky requests.
- Host server → App shell: serves build · Server hosts the built client assets.
- Host server → Local storage: server edge · Sensitive credentials and upstream access stay server-side.