TripFlow
Describe a trip in one sentence — typed or spoken — and get trains, stays and a day-by-day plan back.
- Role
- Frontend (Next.js) and AI backend (FastAPI + LangChain): LLM failover, memory, cost cuts
- Team
- Team project — I owned the frontend and large parts of the AI backend
- Period
- Jan – Oct 2026
- Stack
- Next.js 16 · React 19 · FastAPI · LangChain · OpenAI · Grok · Supabase · Redis · Razorpay · PostHog
- Live
- tripflow.live

01 — Context
The problem
Planning a trip in India means a dozen tabs: train availability, flights, buses, hotels, weather, what's worth seeing. TripFlow collapses that into one conversation. You say where and roughly when, by text or by voice, and an agent comes back with transport options, stays, destination notes, a day-by-day itinerary and a packing list based on the forecast.
It's live at tripflow.live. 250+ users have planned 2,000+ trips on it — product numbers, served by the system described here.
02 — My role & scope
What I built
TripFlow is a team product. My scope:
- Frontend (57 commits): Next.js 16, React 19, Tailwind 4, Supabase with Google OAuth, the voice planner, the multi-step agent loader, itinerary and booking views, the ₹49 Razorpay unlock, PostHog funnels and Sentry.
- AI backend (76 commits) on FastAPI + LangChain: trains and budget (phase 1), OpenAI-primary with Grok fallback, the memory gate, and cuts to Google/SerpAPI spend.
The rest of the backend and product decisions were shared with the team.
03 — Architecture
How it fits together
A Next.js client talks to a FastAPI agent backend over HTTP for text and over WebSockets for voice. The backend turns free text into a structured trip intent, then fans out to transport, stay and destination tools.
04 — Hard problems
Three hard problems
- A.
Voice that feels like a conversation
- Problem
- Voice planning dies if the user waits in silence for a full response to be synthesised, and it sounds broken if audio arrives in chunks that play with gaps or overlaps.
- Options
- Wait for the complete TTS file and play it — simplest, but long dead air.
- Play each chunk as it arrives — fast, but audible gaps between chunks.
- Stream audio over a WebSocket and schedule chunks through a playback queue.
- Choice
- Audio streams over WebSockets, and incoming TTS chunks go into a gapless playback queue: each chunk is scheduled to start exactly when the previous one ends, instead of being played the moment it lands.
- Result
- Speech starts as soon as the first chunk arrives and plays continuously after that. While the agent works, the multi-step loader (Understanding → Transport → Stay → Destination intel) shows real progress instead of a spinner.
- B.
Staying up when the model provider isn't
- Problem
- Every trip depends on an LLM call. A provider outage or rate limit means a user who just described their trip gets nothing back — the worst possible moment to fail.
- Options
- Retry the same provider with backoff — fine for blips, useless for outages.
- Switch providers manually when something breaks — too slow.
- Put a second provider behind the same interface.
- Choice
- OpenAI stays primary; on failure the same call falls back to Grok through LangChain, so the rest of the pipeline doesn't know or care which model answered.
- Result
- A provider incident becomes a quality dip on some answers instead of an outage for every user.
- C.
When should the agent remember you?
- Problem
- Stored user memory — preferences, past trips — makes plans better when it's relevant and worse when it isn't. Injecting it into every prompt adds cost and drags old context into new trips.
- Options
- Always include memory — expensive and often wrong.
- Never include it — every trip starts cold.
- Decide per request.
- Choice
- I added a memory gate: a step that decides, per request, whether stored user memory is relevant before it ever reaches the planning prompt.
- Result
- Memory shows up when it helps and stays out when it doesn't, and prompts stay smaller on the common path.
05 — AI specifics
The AI part
The agent is a pipeline of narrow steps rather than one giant prompt.
Structured intent first
Free text like "Goa next long weekend, 4 of us, under 20k" becomes a structured trip intent before any tool runs, so every later step works on fields, not prose.
Trains and budget
I built phase 1 of trains and budget handling — the part of Indian travel that most generic trip planners skip.
Cost as a feature
Paid search (Google, SerpAPI) costs money on every call. I reduced how often the pipeline calls it, so each plan costs less to produce.
Fallback model
OpenAI primary, Grok fallback, behind one interface.
06 — Outcome
Where it landed
Live at tripflow.live with 250+ users and 2,000+ trips planned. The funnel is instrumented end to end with PostHog, and errors go to Sentry.
Anonymous sessions are persisted before signup, so a user who plans first and signs in later keeps their trip. Exact bookings unlock with a ₹49 one-time payment via Razorpay — a real payment flow in front of real users.
07 — Differently
What I’d do differently
- 01Build an eval set of real (anonymised) trip requests early, so changes to intent extraction are measured, not spot-checked.
- 02Track cost per trip as a first-class metric from the start instead of discovering it on the invoice.
- 03Split the voice transport into its own service sooner; it has very different scaling needs from the planner.
