Implementing AI Assistant for Travel Route Planning in Mobile Apps
User inputs "Rome, 4 days, with 6-year-old, medium budget" and wants ready route with sequence of attractions, restaurant recommendations near each point, operating hours, logic to avoid crossing city twice. This isn't simple ChatGPT call—it needs combination of LLM, geospatial data, and routing.
Architecture: Why Plain GPT Isn't Enough
LLM generates text well but doesn't know Colosseum's schedule next week, can't optimize visit order geographically, can't verify real distances.
Working scheme—RAG (Retrieval-Augmented Generation) + external APIs:
- User query → intent parsing via LLM (GPT-4o/Claude 3 Haiku)—extract: city, dates, people count, children ages, interests, budget.
-
POI search — Google Places API or Foursquare Places API by parameters: city coordinates,
type(museum/restaurant/park),rating ≥ 4.0, open needed days. - Route geo-optimization — Travelling Salesman Problem simplified: for 8-15 points nearest-neighbor heuristic or Google Routes API Optimization (Compute Routes Matrix → greedy distribution per day).
- LLM enrichment — collected POI data + route passed to LLM for human descriptions, advice, coherent plan text.
-
Real-time — actual schedules via Google Places Details (
opening_hours.periods), crowd forecast via BestTime.app API (least crowded time).
Prompt Engineering for Routes
System prompt: "You are experienced travel consultant. Given POI list with coordinates, schedules, ratings, distributed by days. Compose coherent plan with time slots, logistics advice, recommendations near each point. Only facts from provided data—no invention."
Pass data in structured JSON inside user message—LLM works better with structure than text stream. Tokens: ~3000-5000 for 4-day route with 15 points. GPT-4o-mini optimal for production cost.
Mobile UX: How It Looks
Conversational Interface
Not form with fields—conversation. User types like in messenger, assistant clarifies: "You mentioned child—interested in children's museums or prefer to avoid?" Series of clarification questions before generation start.
iOS: UITextView with inputAccessoryView for send button. Messages in UICollectionView—bubbles like chat. Typing indicator while LLM generates.
Streaming response: OpenAI API supports SSE (Server-Sent Events)—text appears as generated, don't wait full response. iOS: URLSession.dataTask + parse SSE chunks via Scanner. Android: OkHttp EventSource. UI—typingLabel with sequential text addition.
Route Map
After generation—interactive map with day points (Mapbox or Google Maps), numbered markers and paths. Day switched by tab—map recenters on day's points with flyTo animation.
Tap marker → POI card: photo (Google Places Photos API), rating, hours, distance from previous point, "open in navigator" button (deeplink to Google Maps / Apple Maps / Yandex Maps).
Plan Editing
User wants to remove point or add new—drag & drop in day list, or chat command "remove Pantheon from day 2 and add something instead". LLM regenerates only affected day considering changes.
Reorder points: UITableView with UITableViewDragDelegate on iOS, ReorderableList in Compose.
Storage and Sync
Route saved to cloud (PostgreSQL: trips → trip_days → trip_stops). Offline copy in SQLite/CoreData: user must access route without internet. Sync on reconnect.
Export: PDF plan via server (WeasyPrint), Google Calendar via OAuth2 (calendar.events.insert per point with time), GPX for navigators.
LLM Call Cost
At ~3000 tokens per generation and GPT-4o-mini ($0.15/1M input, $0.60/1M output)—roughly $0.001-0.002 per route. For project with 1000 generations daily—$1-2/day. Cache results of similar queries (city + duration + type hash)—reduces API cost as audience grows.
Timeline
Basic AI route planner (dialog, generation, map)—2-3 weeks. With editing, export to PDF/Calendar, offline access, business hours optimization—5-8 weeks. Cost estimated individually: LLM provider and geospatial service choice significantly impacts architecture.







