This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
FlightBoard is a dual-interface flight information display system with:
- Web Interface: Next.js 15 app with real-time flight displays and multiple themes
- CLI Tools: Three command-line utilities (TUI, web server, flight lookup)
- Multi-Provider Support: Aggregates data from 8+ flight APIs with intelligent fallback
IMPORTANT: Run these commands after EVERY code change to ensure nothing breaks:
# 1. Linting (warnings are OK, errors are not)
npm run lint
# 2. TypeScript Type Checking (must pass)
npm run typecheck
# 3. Unit & Integration Tests (must pass)
npm test
# 4. Build Next.js & CLI (must complete successfully)
npm run build
# 5. Docker Build (must complete successfully)
docker build -t flightboard:test .
# 6. E2E Tests (run if UI changes were made)
npm run test:e2eQuick validation command (run all checks):
npm run lint && npm run typecheck && npm test && npm run build && docker build -t flightboard:test .If any of these fail, fix the issues before committing or proceeding.
# Run web app in development mode (port 3000)
npm run dev
# Run CLI tools directly
npm run flightboard-tui # Terminal UI
npm run flightboard-lookup # Flight/route lookup tool
npm run flightboard-web # Alias for web dev server
# Build everything (web + CLI)
npm run build
npm run build:cli # Build CLI tools only# Run all unit/integration tests
npm test
# Run specific test suites
npm run test:unit # Unit tests only
npm run test:integration # Integration tests only
npm run test:e2e # Playwright E2E tests
npm run test:coverage # With coverage report
npm run test:watch # Watch mode for TDD
# Run a single test file
npx jest path/to/test.spec.ts
npx playwright test tests/e2e/flightboard.spec.tsnpm run lint # ESLint check (warnings allowed)
npm run lint:fix # Auto-fix linting issues
npm run typecheck # TypeScript type checkingnpm run docker:build # Build Docker image
npm run docker:compose # Run with docker-compose
docker pull ghcr.io/airframesio/flightboard:latest # From registrysrc/app/: Next.js 15 app router pages and API routessrc/components/: React components (UI primitives inui/, features at root)src/lib/: Core business logic and utilitiessrc/cli/: Command-line tools (tui.ts, lookup.ts, web.ts)src/contexts/: React contexts (theme management)src/types/: TypeScript type definitions
The system uses a provider aggregation pattern with automatic fallback:
-
AggregatedFlightProvider(src/lib/flight-providers.ts):- Orchestrates multiple API providers in priority order
- Automatically falls back to next provider on failure
- Configurable via
FLIGHT_PROVIDER_PRIORITYenv var
-
Individual Providers:
- Each implements
FlightProviderinterface - Located in
src/lib/flight-providers.ts - Examples:
AirframesProvider,FlightAwareProvider,AdsbLolProvider - FlightAware: Uses AeroAPI v4 with
/airports/{code}/flights/departuresendpoints - FlightRadar24: Supports commercial API with flexible endpoint structure
- Each implements
-
Route Enrichment:
enrichFlightWithRoute()automatically fetches missing airport details- Uses separate route providers (adsb.im, adsb.lol)
/api/flights - Main flight data endpoint
- Query params:
airport,type(departure/arrival),count,mock - Attempts real API data first, falls back to mock if unavailable
- Returns enriched flight data with airport details
Located in src/lib/themes/:
- Multiple themes (Airport, Modern, Matrix, Forest, etc.)
- Each theme exports a
FlightBoardThemeobject - Theme persistence via localStorage
- Context provider in
src/contexts/theme-context.tsx
TUI (src/cli/tui.ts):
- Uses
blessedlibrary for terminal UI - Real-time updates via setInterval
- Configurable refresh rate and airport
Lookup Tool (src/cli/lookup.ts):
- Commander.js based CLI
- Supports flight number and route lookups
- Can query specific providers or all
- Unit Tests:
src/**/__tests__/- Component and utility tests - Integration Tests:
tests/integration/- API endpoint testing - E2E Tests:
tests/e2e/- Playwright browser automation - Mocks: API providers are mocked in integration tests
- Coverage: Configured in
jest.config.jswith thresholds
Create .env.local from env.example:
FLIGHT_PROVIDER_PRIORITY: Comma-separated provider order- Individual API keys for each provider (optional)
- Providers work without keys but may have limitations
GitHub Actions workflows (.github/workflows/):
- ci.yml: Runs on PRs - lint, typecheck, tests, build
- docker-publish.yml: Builds multi-arch Docker images on release
- Tests run on Node 18.x and 20.x
- Playwright E2E tests included in CI
-
Mock Data Fallback: When no API providers return data, the system automatically uses mock data from
src/lib/mock-data.ts -
Airport Coordinates: Cached in
src/lib/airport-coords.tswith fallback to Airframes.io API -
Status Mapping: Each provider's status codes are normalized to standard values (scheduled, boarding, departed, etc.)
-
Error Handling: Providers fail gracefully - errors are logged but don't crash the app
-
Real-time Updates: Web UI polls
/api/flightsevery 30 seconds, TUI configurable via--refreshflag -
TypeScript Strict Mode: Enabled - use proper types, avoid
anywhere possible -
ESLint Configuration: Uses ESLint v9 flat config (
eslint.config.mjs), warnings don't fail CI -
Playwright Configuration: E2E tests run against dev server, multiple browser targets configured
- Always validate: Run the validation checklist after every significant change
- Never skip tests: All tests must pass before considering work complete
- Build verification: Both npm and Docker builds must succeed
- Lint warnings: While warnings are acceptable, aim to minimize them
- Type safety: TypeScript compilation must pass without errors
- Breaking the build by not testing TypeScript compilation
- Introducing linting errors (warnings are OK, errors are not)
- Forgetting to test Docker build after dependency changes
- Not running tests after modifying business logic
- Skipping E2E tests after UI changes
Quality over speed: It's better to take time validating than to break the build. Always run the full validation checklist before declaring any task complete.