Skip to content

Repository files navigation

Flight Monitor Agent

A multi-language, AI-powered flight price monitoring dashboard with real-time data, TimesFM forecasting, and global airport coverage.

License: MIT Next.js TypeScript TimesFM


πŸ“‹ Table of Contents


πŸ“– Overview

Flight Monitor Agent is a production-ready web application that monitors flight prices across 432 airports in 182 countries worldwide. It combines real-time web search for live pricing with Google Research's TimesFM 2.5 foundation model for 14-day price forecasting, all wrapped in a 6-language RTL/LTR-aware interface.

The app stores all data in the browser's localStorage β€” zero database setup required. Track any airport pair, get alerts when prices drop, view AI-powered buy/wait/monitor recommendations, and click through to booking sites.

What makes this special?

  • No mock data β€” every price is fetched live via web search or estimated using real airline pricing models
  • No database setup β€” localStorage persists everything (trackers, price history, alerts, logs)
  • TimesFM 2.5 β€” Google Research's 200M-parameter time-series foundation model for forecasting
  • 6 languages β€” English, Russian, Georgian, Hebrew, Arabic, Spanish with automatic RTL switching
  • 432 airports β€” every country with commercial aviation is represented
  • Click-to-buy β€” every deal links directly to Skyscanner/Google Flights/airline websites

✨ Features

πŸ›« Tracker System

  • Track any airport pair worldwide (432 airports, 182 countries)
  • Round-trip and one-way support
  • Cabin classes: Economy, Premium, Business, First
  • 1–9 passengers
  • Target price alerts (get notified when price hits your threshold)
  • Pause/resume individual trackers
  • Persistent storage via localStorage

πŸ“Š Real-Time Price Engine

  • Live web search (sandbox/self-hosted): Fetches actual current prices from Skyscanner, Expedia, Google Flights, airline websites via z-ai SDK
  • DuckDuckGo scraping (Vercel): Searches DuckDuckGo Lite for flight prices and parses real prices from search result snippets β€” no API key needed
  • AI estimator (fallback): Deterministic pricing based on real airline models (distance Γ— seasonal Γ— advance-booking Γ— cabin Γ— airline factor)
  • Price validation layer: Every scraped price is validated against route-specific bounds, statistical outliers (IQR), and cross-source consistency before display
  • 50+ real airlines with hub airports and pricing factors
  • Deep links to booking sites for every quote
  • 30-minute auto-refresh + manual refresh button

🧠 TimesFM AI Forecasting

  • 14-day price forecast using TimesFM 2.5 (200M parameters) from Google Research
  • Quantile forecast bands (80% confidence interval)
  • Buy now / Wait / Keep monitoring recommendations
  • Multilingual reasoning (6 languages)
  • Falls back to statistical STL-decomposition if TimesFM unavailable

🌍 Multi-Language Support (6 Languages)

Language Code Direction Native Name
English en LTR English
Russian ru LTR Русский
Georgian ka LTR αƒ₯αƒαƒ αƒ—αƒ£αƒšαƒ˜
Hebrew he RTL Χ’Χ‘Χ¨Χ™Χͺ
Arabic ar RTL Ψ§Ω„ΨΉΨ±Ψ¨ΩŠΨ©
Spanish es LTR EspaΓ±ol
  • All UI strings translated
  • Automatic RTL/LTR layout switching
  • Locale-aware date formatting
  • Multilingual cabin class labels and region names
  • AI forecast reasoning in user's selected language
  • Language preference persisted in localStorage

πŸ”” Smart Alerts

  • Price drop alerts (>5% decrease from previous scan)
  • Target price alerts (price hits your threshold)
  • New historical low alerts (lowest price ever recorded)
  • Acknowledge/dismiss alerts
  • All alerts stored with full context (previous price, drop %, airline, source)

πŸ“ˆ Dashboard

  • Trackers tab: Grid of tracker cards with sparklines, price stats, deal badges
  • Overview tab: KPIs, live scanner status, recent alerts, hot routes, system health
  • AI Forecast tab: TimesFM 14-day forecast with confidence bands and recommendations
  • System tab: Health metrics, resource usage, daily summaries, filterable activity logs

πŸ“± Mobile-First Design

  • All touch targets β‰₯44px (Apple HIG / Material Design compliance)
  • Responsive layouts (mobile stacked β†’ desktop side-by-side)
  • Touch-friendly dialogs with full-height scroll
  • Adaptive charts (shorter on mobile)
  • Active-state animations for tactile feedback

🌐 Live Demo

Vercel Deployment: https://my-project-three-zeta-61.vercel.app/

Note: The Vercel demo shows a "Demo Mode" banner when prices are AI-estimated, and switches to a green "Live Prices Active" banner when DuckDuckGo scraping succeeds. For the full live experience (z-ai web search + TimesFM forecasting), self-host using the GitHub repo.


πŸ†š Vercel vs Self-Hosted (VPS)

The app runs in two modes depending on where it's deployed. Here's a clear comparison:

Feature Vercel (Demo) Self-Hosted VPS (Full)
Price source DuckDuckGo Lite scraping + AI estimator fallback z-ai SDK live web search (Skyscanner, Expedia, airline sites)
Price accuracy Real prices from search snippets (when scraping succeeds) + estimated prices (fallback) Real prices directly from travel sites
Price validation βœ… Full validation (bounds + IQR + consistency) βœ… Full validation (bounds + IQR + consistency)
TimesFM forecast ❌ Statistical fallback (STL decomposition) βœ… TimesFM 2.5 (200M params, JAX/Flax)
Forecast accuracy Good (trend + seasonality) Excellent (deep learning foundation model)
Banner Amber "Demo Mode" or Green "Live Prices Active" No banner (full mode)
Setup Zero config (just deploy) Install Python + TimesFM + z-ai SDK
Cost Free (Vercel hobby tier) VPS cost (~$5/mo)
Latency ~2-5s per price fetch ~1-3s per price fetch
Rate limits DuckDuckGo may rate-limit z-ai SDK (no public rate limit)

Which should you use?

  • Vercel: Quick demo, testing, sharing with friends. Works without any setup.
  • Self-Hosted VPS: Production use, real price monitoring, accurate AI forecasts. This is how the original flight agent was designed to run.

πŸ“‚ Code Files: Vercel vs Self-Hosted

Files used by BOTH environments

File Purpose
src/app/page.tsx Main dashboard (4 tabs, all UI)
src/app/layout.tsx Root layout with RTL/LTR sync
src/lib/airports.ts 432 airports across 182 countries
src/lib/localDb.ts localStorage database (zero-setup)
src/lib/priceRefresh.ts Background price refresh service
src/lib/priceEngine.ts Deterministic price engine + utilities
src/lib/trackerStore.ts Zustand tracker store
src/lib/i18n/translations.ts 6-language dictionaries
src/lib/i18n/index.ts i18n store + hooks
src/lib/priceValidator.ts Price validation (bounds + IQR + consistency)
src/components/dashboard/*.tsx All UI components
src/app/api/real-prices/route.ts Multi-layer price fetch (z-ai β†’ scrape β†’ AI)
src/app/api/client-scrape/route.ts DuckDuckGo scraping endpoint
src/app/api/forecast/route.ts Forecast endpoint (TimesFM or TS fallback)

Files for Vercel ONLY (scraping fallback)

File Purpose
src/lib/priceScraper.ts DuckDuckGo Lite/HTML/Brave search scraper with CORS proxy fallback. This is the creative workaround that gets real prices on Vercel without API keys.

Files for Self-Hosted ONLY (full live experience)

File Purpose
src/lib/realFlights.ts z-ai SDK integration (web_search + LLM extraction). Only works where the z-ai internal API is reachable (sandbox or VPS with z-ai access). Also contains the AI estimator fallback used by Vercel.
mini-services/forecast-service/index.py TimesFM 2.5 Python service (port 3030). Requires Python + JAX + Flax. Only runs on a VPS or local machine β€” cannot run on Vercel serverless.

Files for Vercel configuration

File Purpose
vercel.json (if present) Vercel-specific config
Environment variables ZAI_BASE_URL, ZAI_API_KEY, ZAI_CHAT_ID, ZAI_TOKEN, ZAI_USER_ID β€” set in Vercel dashboard. Used by ensureZaiConfig() in realFlights.ts to write a temp config file.

How the multi-layer fallback works

Price fetch request
      ↓
β”Œβ”€ Layer 1: z-ai SDK (self-hosted only) ──────────────────┐
β”‚  src/lib/realFlights.ts β†’ ZAI.create()                  β”‚
β”‚  β†’ web_search for live prices                           β”‚
β”‚  β†’ LLM extracts structured quotes                       β”‚
β”‚  β†’ If success: return real prices βœ…                    β”‚
β”‚  β†’ If fail (Vercel IP blocked): fall through ↓          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      ↓
β”Œβ”€ Layer 2: DuckDuckGo scraping (Vercel + self-hosted) ──┐
β”‚  src/lib/priceScraper.ts β†’ scrapeRealPrices()           β”‚
β”‚  β†’ Search DuckDuckGo Lite for "flight TLV to JFK price" β”‚
β”‚  β†’ Parse prices from search result snippets             β”‚
β”‚  β†’ Validate prices (src/lib/priceValidator.ts)          β”‚
β”‚  β†’ If success: return real prices βœ…                    β”‚
β”‚  β†’ If fail (rate limited): fall through ↓               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      ↓
β”Œβ”€ Layer 3: AI estimator (always works) ─────────────────┐
β”‚  src/lib/realFlights.ts β†’ fallbackEstimate()            β”‚
β”‚  β†’ Deterministic pricing based on real airline models   β”‚
β”‚  β†’ 50+ airlines with hub airports and pricing factors   β”‚
β”‚  β†’ Generates Skyscanner deep links                      β”‚
β”‚  β†’ Always returns prices βœ…                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Forecast fallback

Forecast request
      ↓
β”Œβ”€ Layer 1: TimesFM (self-hosted only) ──────────────────┐
β”‚  src/app/api/forecast/route.ts β†’ fetch(localhost:3030)  β”‚
β”‚  β†’ Python service runs TimesFM 2.5 (200M params)        β”‚
β”‚  β†’ Returns 14-day forecast with quantile bands          β”‚
β”‚  β†’ If success: return TimesFM forecast βœ…               β”‚
β”‚  β†’ If fail (service not running): fall through ↓        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      ↓
β”Œβ”€ Layer 2: Statistical fallback (Vercel + self-hosted) ─┐
β”‚  src/app/api/forecast/route.ts β†’ forecastStatistical()  β”‚
β”‚  β†’ STL decomposition (log-transform + trend + weekly)   β”‚
β”‚  β†’ 80% confidence band (z=1.28)                         β”‚
β”‚  β†’ Always returns forecast βœ…                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ›  Tech Stack

Category Technology
Framework Next.js 16 (App Router, Turbopack)
Language TypeScript 5
Styling Tailwind CSS 4 + shadcn/ui (New York)
Charts Recharts
Animations Framer Motion
State Zustand (with persist middleware)
Icons Lucide React
AI Forecasting TimesFM 2.5 (200M, JAX/Flax backend)
Real Prices z-ai-web-dev-sdk (web_search + LLM)
Database localStorage (zero-setup)
Deployment Vercel
Python Service Python 3.12 + stdlib HTTP server

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ / Bun
  • Python 3.10+ (optional, for TimesFM forecasting service)

Installation

# Clone the repository
git clone https://github.com/your-username/flight-monitor-agent.git
cd flight-monitor-agent

# Install dependencies
bun install

# (Optional) Install TimesFM for local forecasting
pip install timesfm jax jaxlib einshape flax jaxtyping

Development

# Start the Next.js dev server
bun run dev

# (Optional) Start the TimesFM forecast service in another terminal
cd mini-services/forecast-service
python index.py

The app will be available at http://localhost:3000.

Production Build

bun run build
bun run start

πŸ“ Project Structure

flight-monitor-agent/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   β”œβ”€β”€ forecast/route.ts        # TimesFM forecast endpoint
β”‚   β”‚   β”‚   └── real-prices/route.ts     # Live price search endpoint
β”‚   β”‚   β”œβ”€β”€ globals.css
β”‚   β”‚   β”œβ”€β”€ layout.tsx                   # Root layout with RTL/LTR sync
β”‚   β”‚   └── page.tsx                     # Main dashboard (4 tabs)
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ dashboard/
β”‚   β”‚   β”‚   β”œβ”€β”€ AirportCombobox.tsx      # Searchable airport picker (432 airports)
β”‚   β”‚   β”‚   β”œβ”€β”€ FlightDealsGrid.tsx      # Vendor deals grid with click-to-buy
β”‚   β”‚   β”‚   β”œβ”€β”€ ForecastPanel.tsx        # TimesFM forecast display
β”‚   β”‚   β”‚   β”œβ”€β”€ LanguageSwitcher.tsx     # 6-language dropdown
β”‚   β”‚   β”‚   β”œβ”€β”€ LanguageDirSync.tsx      # RTL/LTR attribute sync
β”‚   β”‚   β”‚   β”œβ”€β”€ NewTrackerDialog.tsx     # Create tracker modal
β”‚   β”‚   β”‚   β”œβ”€β”€ PriceHistoryChart.tsx    # Recharts area chart
β”‚   β”‚   β”‚   β”œβ”€β”€ TrackerCard.tsx          # Tracker card with sparkline
β”‚   β”‚   β”‚   β”œβ”€β”€ LogsViewer.tsx           # Filterable activity logs
β”‚   β”‚   β”‚   β”œβ”€β”€ ScannerPanel.tsx         # Live scanner status
β”‚   β”‚   β”‚   β”œβ”€β”€ StatCard.tsx             # KPI card
β”‚   β”‚   β”‚   β”œβ”€β”€ Sparkline.tsx            # Mini SVG sparkline
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   └── ui/                          # shadcn/ui components
β”‚   └── lib/
β”‚       β”œβ”€β”€ airports.ts                  # 432 airports, 182 countries
β”‚       β”œβ”€β”€ realFlights.ts               # Live price fetcher + AI estimator
β”‚       β”œβ”€β”€ localDb.ts                   # localStorage database layer
β”‚       β”œβ”€β”€ priceRefresh.ts              # Background price refresh service
β”‚       β”œβ”€β”€ priceEngine.ts               # Deterministic price engine
β”‚       β”œβ”€β”€ trackerStore.ts              # Zustand tracker store
β”‚       └── i18n/
β”‚           β”œβ”€β”€ translations.ts          # 6-language dictionaries
β”‚           └── index.ts                 # i18n store + hooks
β”œβ”€β”€ mini-services/
β”‚   └── forecast-service/
β”‚       └── index.py                     # TimesFM Python service (port 3030)
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ README.md                        # Test documentation
β”‚   β”œβ”€β”€ airport-search.test.ts           # Airport search tests
β”‚   β”œβ”€β”€ price-engine.test.ts             # Price engine tests
β”‚   β”œβ”€β”€ i18n.test.ts                     # Translation tests
β”‚   └── mobile-ui.test.ts                # Mobile UI tests
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ ARCHITECTURE.md                  # System architecture
β”‚   β”œβ”€β”€ TIMESFM.md                       # TimesFM integration guide
β”‚   β”œβ”€β”€ I18N.md                          # Internationalization guide
β”‚   └── DEPLOYMENT.md                    # Deployment guide
β”œβ”€β”€ .gitignore
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ LICENSE
└── README.md

πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Browser (Client)                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  React UI   β”‚  β”‚  Zustand     β”‚  β”‚  localStorage DB   β”‚ β”‚
β”‚  β”‚  (6 langs)  β”‚  β”‚  Stores      β”‚  β”‚  (snapshots,       β”‚ β”‚
β”‚  β”‚  (RTL/LTR)  β”‚  β”‚  (trackers,  β”‚  β”‚   alerts, logs)    β”‚ β”‚
β”‚  β”‚             β”‚  β”‚   i18n)      β”‚  β”‚                    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚         β”‚                                                     β”‚
β”‚         β”‚ fetch()                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚
          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Next.js API Routes                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ /api/real-prices β”‚  β”‚ /api/forecast                     β”‚β”‚
β”‚  β”‚ (live web search)β”‚  β”‚ (TimesFM or statistical fallback) β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚           β”‚                          β”‚                       β”‚
β”‚           β–Ό                          β–Ό                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ z-ai-web-dev-sdk β”‚  β”‚ Python Forecast Service          β”‚β”‚
β”‚  β”‚ (web_search +    β”‚  β”‚ (TimesFM 2.5, port 3030)         β”‚β”‚
β”‚  β”‚  LLM extraction) β”‚  β”‚ JAX/Flax backend                 β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data Flow

  1. User creates a tracker β†’ stored in Zustand + localStorage
  2. Background refresh (every 30 min) β†’ calls /api/real-prices
  3. API route β†’ uses z-ai SDK to web-search live prices β†’ LLM extracts structured quotes
  4. Price snapshot stored in localStorage with all vendor quotes
  5. Alerts generated if price dropped >5%, hit target, or new historical low
  6. Forecast panel β†’ calls /api/forecast β†’ proxies to Python TimesFM service
  7. TimesFM analyzes price history β†’ 14-day forecast + recommendation

🌍 Multi-Language Support

The app supports 6 languages with full RTL/LTR switching. See docs/I18N.md for details.

Adding a new language

  1. Add the language code to Language type in src/lib/i18n/translations.ts
  2. Add a new dictionary with all translation keys
  3. Add the language metadata to the languages array
  4. Add region label translations in src/lib/airports.ts
  5. Add cabin label translations in src/lib/priceEngine.ts

🧠 TimesFM Integration

The app uses TimesFM 2.5 (200M parameters) from Google Research for price forecasting. See docs/TIMESFM.md for setup details.

How it works

  1. The Next.js /api/forecast route receives price history + user's language
  2. It proxies to the Python service at localhost:3030
  3. The Python service loads TimesFM 2.5 (flax backend) via JAX
  4. TimesFM produces a 14-day forecast with quantile bands
  5. A recommendation engine combines forecast + historical stats + days-to-departure
  6. Reasoning text is generated in the user's selected language
  7. If Python is unavailable, a TS statistical fallback (STL decomposition) is used

⚑ Real-Time Data

Local Sandbox (Live Web Search)

  • Uses z-ai-web-dev-sdk to search the web for current flight prices
  • LLM extracts structured prices from search results
  • Fetches from Skyscanner, Expedia, Google Flights, airline websites

Vercel (AI Estimator)

  • The z-ai internal API is IP-restricted to the sandbox
  • Falls back to a deterministic price estimator based on real airline models
  • Uses 50+ real airlines with hub airports and pricing factors
  • Generates Skyscanner deep links for all quotes

πŸ“‘ API Reference

POST /api/real-prices

Fetch real flight prices for a route.

Request:

{
  "originIata": "TLV",
  "destIata": "JFK",
  "departDate": "2026-08-15",
  "returnDate": "2026-08-25",
  "cabin": "economy",
  "passengers": 1
}

Response:

{
  "quotes": [
    {
      "price": 416,
      "currency": "USD",
      "airline": "Unknown",
      "stops": 0,
      "source": "skyscanner.com",
      "deepLink": "https://www.skyscanner.com/...",
      "fetchedAt": "2026-06-21T19:20:34.277Z"
    }
  ],
  "lowest": { ... },
  "average": 615,
  "dataSource": "live_search",
  "distanceKm": 9116
}

POST /api/forecast

Get a 14-day TimesFM price forecast.

Request:

{
  "history": [200, 210, 215, 205, 195, ...],
  "routeId": "trk_abc123",
  "horizon": 14,
  "lang": "es",
  "route": {
    "daysToDeparture": 45
  }
}

Response:

{
  "model": "timesfm-2.5-200M-flax",
  "forecast": [185.98, 193.82, 199.79, ...],
  "lower": [185.98, 193.82, 186.97, ...],
  "upper": [210.34, 196.42, 229.05, ...],
  "recommendation": "buy_now",
  "confidence": 92,
  "expectedChangePct": 6.4,
  "reasoning": "El precio estΓ‘ cerca del mΓ­nimo histΓ³rico ($182)...",
  "usedTimesFM": true,
  "lang": "es"
}

πŸ§ͺ Testing

See tests/README.md for comprehensive test documentation.

Test categories

  • Airport search tests: Verify city/country/IATA filtering
  • Price engine tests: Verify deterministic pricing
  • i18n tests: Verify all 6 language translations
  • Mobile UI tests: Verify touch targets and responsive layouts
  • Forecast tests: Verify TimesFM integration and fallback
  • Alert tests: Verify price drop/target/historical low detection

🚒 Deployment

Vercel (Recommended)

# Install Vercel CLI
npm i -g vercel

# Deploy
vercel --prod

Environment variables (for z-ai SDK on Vercel):

  • ZAI_BASE_URL β€” z-ai API base URL
  • ZAI_API_KEY β€” z-ai API key
  • ZAI_CHAT_ID β€” chat session ID
  • ZAI_TOKEN β€” auth token
  • ZAI_USER_ID β€” user ID

See docs/DEPLOYMENT.md for full details.

Local with TimesFM

# Terminal 1: Start TimesFM service
cd mini-services/forecast-service
pip install timesfm jax jaxlib einshape flax jaxtyping
python index.py

# Terminal 2: Start Next.js
bun run dev

🀝 Contributing

See CONTRIBUTING.md for guidelines.


πŸ“„ License

This project is licensed under the MIT License β€” see LICENSE for details.


πŸ™ Acknowledgments

About

Multi-language AI-powered flight price monitoring dashboard with TimesFM forecasting, real-time data, and global airport coverage (432 airports, 182 countries, 6 languages)

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages