A full-stack travel planning application built with LangGraph multi-agent architecture, featuring real-time streaming, request interruption handling, and seamless context preservation.
- Coordinator Agent: Analyzes user intent and routes requests
- Flight Agent: Searches flights with real-time data
- Hotel Agent: Finds hotels and accommodations
- Research Agent: Provides general travel information via web search
- Detection: Recognizes when new queries arrive during processing
- Cancellation: Gracefully stops running operations with one click
- Partial Result Preservation: Saves progress before interruption
- Continuation: Resumes with preserved context and state
- Server-Sent Events (SSE): Live streaming of agent actions
- Status Updates: Visual indicators for each active agent
- Token Streaming: Real-time LLM response display
- Conversation Persistence: Maintains chat history across sessions
- Context Transfer: Seamless handoffs between agents
- Thread-Based Storage: Each conversation has unique state
- Node.js 18+ and npm/yarn/bun
- Python 3.10+ with pip
- OpenAI API Key (required)
# Install frontend dependencies
npm install
# or
bun install
# Install backend dependencies
cd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtBackend (.env)
cd backend
cp .env.example .env
# Edit .env and add your OpenAI API keyRequired:
OPENAI_API_KEY=sk-your-openai-api-keyFrontend (.env.local) - Already configured
NEXT_PUBLIC_PYTHON_BACKEND_URL=http://localhost:8000Terminal 1 - Python Backend
cd backend
source venv/bin/activate
python main.pyServer starts at: http://localhost:8000
Terminal 2 - Next.js Frontend
npm run dev
# or
bun devFrontend starts at: http://localhost:3000
- Navigate to http://localhost:3000
- Click "Start Planning Your Trip"
- Try queries like:
- "Find flights from NYC to LAX"
- "Hotels in Paris"
- "Plan a trip to Tokyo"
- Click "Cancel Query" while processing to test interruption
- User sends query: "Find flights from NYC to Tokyo"
- Coordinator routes to Flight Agent
- Flight Agent starts searching (shows spinner)
- User clicks "Cancel": Interruption signal sent
- Agent detects flag: Stops gracefully, saves partial results
- UI updates: Shows interruption message
- State preserved: Next query resumes with context
Frontend (Next.js) <--SSE Stream--> Backend (FastAPI + LangGraph)
β β
β StateGraph
β β
β βββββββββββββββ΄ββββββββββββββ
β β β
Chat UI Coordinator Agent Tools
β β β
β ββββββββββ΄βββββββββ (search_flights,
β β β search_hotels,
SSE Hook Flight Agent Hotel Agent web_search)
β β β
β βββββββββββββββββββ
β β
Cancel Button State Management
(Checkpointing)
travel-assistant/
βββ backend/ # Python FastAPI + LangGraph
β βββ main.py # FastAPI app with SSE endpoints
β βββ graph.py # LangGraph multi-agent workflow
β βββ agents.py # Agent implementations
β βββ tools.py # Search tools
β βββ state.py # State management schema
β βββ requirements.txt # Python dependencies
βββ src/
β βββ app/
β β βββ page.tsx # Landing page
β β βββ chat/page.tsx # Chat interface
β βββ components/
β β βββ chat/ # Chat components
β β βββ travel/ # Flight/hotel cards
β βββ hooks/
β βββ useSSEChat.ts # SSE integration hook
βββ .env.local # Frontend config
| Endpoint | Method | Description |
|---|---|---|
/api/chat/stream |
POST | Stream agent responses via SSE |
/api/chat/cancel |
POST | Cancel active query |
/api/chat/status/:id |
GET | Get query status |
/api/chat/resume |
POST | Resume after interruption |
/api/health |
GET | Health check |
# Check Python version
python --version # Should be 3.10+
# Reinstall dependencies
pip install -r requirements.txt
# Verify OpenAI API key
cat backend/.env | grep OPENAI_API_KEY# Verify backend is running
curl http://localhost:8000/api/health
# Should return: {"status": "healthy", ...}- Click "Cancel Query" button in header while query is active
- Check browser console for errors
- Verify backend logs show interruption signal
- Backend Details: See
backend/README.md - LangGraph Docs: https://langchain-ai.github.io/langgraph/
- FastAPI Docs: https://fastapi.tiangolo.com/
- Dark theme with gradient backgrounds
- Fluid animations with Framer Motion
- Real-time agent status indicators
- Color-coded agents: Coordinator (Green), Flight (Blue), Hotel (Purple)
- Interruption controls with visual feedback
Built with β€οΈ using LangGraph, FastAPI, Next.js, and Framer Motion