LangGraph AI travel agent with 15+ tools for flight, hotel, car, and excursion booking using Google AI.
A sophisticated full-stack travel booking system that combines the power of LangGraph, Google Generative AI, and modern web technologies to provide an intelligent conversational interface for comprehensive travel management.
- Python 3.8+ for backend
- Node.js 18+ for frontend
- API Keys: Google AI, Groq, Tavily, LangSmith
-
Clone the repository
git clone <repository-url> cd LangGraph-Booking-Agent
-
Backend Setup
cd backend pip install -r requirements.txt cp env.yaml.template env.yaml # Edit env.yaml with your API keys
-
Frontend Setup
cd frontend npm install cp .env.local.example .env.local # Edit .env.local with your backend URL
-
Start the System
# Terminal 1: Backend cd backend python app.py # Terminal 2: Frontend cd frontend npm run dev
-
Access the Application
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
LangGraph Booking Agent
βββ backend/ # LangGraph AI Backend
β βββ app.py # Main LangGraph application
β βββ agent_service.py # FastAPI service wrapper
β βββ database.py # Database utilities
β βββ requirements.txt # Python dependencies
βββ frontend/ # React Frontend
β βββ src/
β β βββ components/ # React components
β β βββ contexts/ # State management
β β βββ services/ # API communication
β β βββ types/ # TypeScript definitions
β βββ package.json # Node.js dependencies
βββ README.md # This file
- LangGraph: Stateful conversation management
- Google Generative AI: Gemini 2.5 Flash for chat completions
- Custom Vector Store: Semantic policy lookup
- SQLite Database: Travel data with automatic date sync
- FastAPI: RESTful API service
- 18+ Specialized Tools: Flight, hotel, car rental, excursion management
- Stateful Conversations: Persistent memory across sessions
- Real-time Data Sync: Automatic timezone-aware updates
- Error Recovery: Graceful fallbacks and retry mechanisms
- Business Logic Validation: Ticket ownership, booking rules
- 8 Main Tables: flights, tickets, hotels, car_rentals, trip_recommendations
- Hosted: Google Cloud Storage with local caching
- Auto-updates: Flight dates synchronized to current time
- Next.js 15: React framework with App Router
- TypeScript: Type-safe development
- Tailwind CSS 4: Utility-first styling
- React Context: State management
- Axios: HTTP client with retry logic
- Glass Morphism UI: Modern, futuristic design
- Real-time Chat: Streaming message updates
- Responsive Design: Mobile-first approach
- Suggested Questions: Quick-start interactions
- Thread Persistence: Conversation history across sessions
# env.yaml
GROQ_API_KEY: your_groq_api_key
GOOGLE_API_KEY: your_google_api_key
TAVILY_API_KEY: your_tavily_api_key
LANGSMITH_API_KEY: your_langsmith_api_key
LANGSMITH_TRACING: true
LANGSMITH_ENDPOINT: https://api.smith.langchain.com
LANGSMITH_PROJECT: Booking-Agent-LC
# .env.local
NEXT_PUBLIC_API_URL=http://localhost:8000
fetch_user_flight_information
- Get user's flight detailssearch_flights
- Search available flightsupdate_ticket_to_new_flight
- Change flight bookingscancel_ticket
- Cancel flight tickets
search_hotels
- Find available hotelsbook_hotel
- Reserve hotel roomsupdate_hotel
- Modify hotel bookingscancel_hotel
- Cancel hotel reservations
search_car_rentals
- Find car rental optionsbook_car_rental
- Reserve vehiclesupdate_car_rental
- Modify rental detailscancel_car_rental
- Cancel car rentals
search_trip_recommendations
- Find excursions and activitiesbook_excursion
- Reserve excursionsupdate_excursion
- Modify excursion detailscancel_excursion
- Cancel excursions
lookup_policy
- Semantic search through company policiesTavilySearch
- Real-time web search for current information
cd backend
gcloud run deploy travel-agent-backend \
--source . \
--platform managed \
--region us-central1 \
--allow-unauthenticated
cd frontend
npm run build
# Deploy the 'out' directory to Netlify
cd backend
python -m pytest tests/
cd frontend
npm test
npm run test:coverage
- Lazy Loading: Database and retriever initialization
- Caching: Embeddings and database queries
- Streaming: Real-time response streaming
- Error Recovery: Automatic retry mechanisms
- Code Splitting: Next.js automatic optimization
- Bundle Optimization: Tree shaking and CSS purging
- Caching: Local storage and service workers
- Responsive Images: Next.js image optimization
- Input Validation: SQL injection prevention
- Authentication: Passenger ID verification
- API Key Protection: Environment variable security
- Business Logic: Booking rule enforcement
- TypeScript: Type safety and validation
- HTTPS: Secure API communication
- Input Sanitization: XSS prevention
- Error Handling: Graceful error recovery
-
API Connection Failed
- Verify backend is running on correct port
- Check environment variables
- Ensure CORS is properly configured
-
Database Issues
- Check database URL accessibility
- Verify SQLite file permissions
- Monitor disk space for caching
-
Tool Execution Errors
- Verify passenger ID configuration
- Check API key validity
- Review error logs for details
# Backend
LANGSMITH_TRACING=true python app.py
# Frontend
NODE_ENV=development npm run dev
- Conversation Tracing: Full conversation flow
- Tool Execution: Performance monitoring
- Error Tracking: Automatic error reporting
- Analytics: Usage patterns and insights
- Backend:
/health
endpoint - Frontend: Service availability monitoring
- Database: Connection status checks
- Fork the repository
- Create a feature branch
- Follow coding standards
- TypeScript for frontend
- Python type hints for backend
- Comprehensive testing
- Submit a pull request
- Write tests for new features
- Update documentation
- Follow existing code patterns
- Ensure responsive design
- Test across browsers
This project is licensed under the MIT License - see the LICENSE file for details.
- LangGraph Team: For the powerful conversation framework
- Google AI: For the Gemini model integration
- Next.js Team: For the excellent React framework
- Tailwind CSS: For the utility-first CSS framework
Built with β€οΈ using LangGraph, Google AI, and modern web technologies