Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

🌍 AI Travel Planning System

A production-ready Multi-Agent AI System built with LangGraph that automatically plans your complete trip — flights, hotels, itinerary and a final travel plan — using 4 specialized AI agents working together.


✨ Features

  • ✈️ Flight Agent — Real-time flight data via AviationStack API
  • 🏨 Hotel Agent — AI-powered hotel search via Tavily
  • 🗓️ Itinerary Agent — Day-by-day itinerary using Groq LLM (Llama 3.3 70B)
  • 🧠 Final Agent — Combines everything into a polished travel plan
  • 💾 Long-Term Memory — Conversation history stored in PostgreSQL
  • 🚀 FastAPI Backend — REST API with /api/health and /api/plan endpoints
  • 🎨 React Frontend — Modern UI built with Vite + React 19
  • 🐳 Docker Ready — One command to run backend + database

🏗️ Architecture

User Request (React Frontend)
        │
        ▼
  FastAPI Backend (server.py)
        │
        ▼
  LangGraph Pipeline (main.py)
        │
  ┌─────┴──────────────────────────┐
  │                                │
  ▼                                │
[1] Flight Agent                  │
  → AviationStack API             │
        │                         │
        ▼                         │
[2] Hotel Agent                   │
  → Tavily Search API             │
        │                         │
        ▼                         │
[3] Itinerary Agent               │
  → Groq LLM (Llama 3.3 70B)     │
        │                         │
        ▼                         │
[4] Final Agent                   │
  → Groq LLM (Llama 3.3 70B)     │
        │                         │
        └─────────────────────────┘
        │
        ▼
  PostgreSQL (Memory / Checkpointing)
        │
        ▼
  Response → React Frontend

🛠️ Tech Stack

AI / LLM

Technology Purpose
LangGraph Multi-agent graph orchestration
LangChain LLM toolkit and message handling
Groq Ultra-fast LLM inference platform
Llama 3.3 70B Open-source LLM by Meta (via Groq)
Tavily AI-optimized web search API
AviationStack Real-time flight data API

Backend

Technology Purpose
FastAPI REST API framework
Uvicorn ASGI server
Pydantic Request/Response validation
Python-dotenv Environment variable management

Database

Technology Purpose
PostgreSQL 15 Persistent memory storage
psycopg Python PostgreSQL driver
LangGraph PostgresSaver Conversation checkpointing

Frontend

Technology Purpose
React 19 UI framework
Vite Build tool and dev server
React Markdown Render LLM responses as formatted text

DevOps

Technology Purpose
Docker Containerization
Docker Compose Multi-container orchestration

📂 Project Structure

AI_Agent/
├── AiTools/                     # Backend (FastAPI + LangGraph)
│   ├── main.py                  # LangGraph graph + 4 agent definitions
│   ├── server.py                # FastAPI REST API server
│   ├── requirements.txt         # Python dependencies
│   ├── Dockerfile               # Backend Docker image
│   ├── docker-compose.yml       # Postgres + Backend orchestration
│   ├── check_health.py          # Health verification script
│   ├── .env.example             # Template for environment variables
│   └── tools/
│       ├── flight_tool.py       # AviationStack API wrapper
│       └── tavily_tool.py       # Tavily Search API wrapper
│
└── frontend/                    # React Frontend
    ├── src/
    │   ├── App.jsx              # Main application component
    │   ├── App.css              # Component styles
    │   └── index.css            # Global styles
    ├── index.html
    ├── package.json
    └── vite.config.js

🚀 Getting Started

Option A — Docker (Recommended for Backend)

The fastest way to get the backend + database running:

# 1. Clone the repo
git clone https://github.com/Katari-8055/TravelAI.git
cd TravelAI

# 2. Create your .env file
cp AiTools/.env.example AiTools/.env
# Fill in your API keys in AiTools/.env

# 3. Start backend + postgres with Docker
cd AiTools
docker compose up -d --build

# 4. Verify everything is healthy
python check_health.py

Option B — Manual Setup

Step 1: Create Python Virtual Environment

python -m venv venv

# Activate on Windows
venv\Scripts\activate

# Activate on Mac/Linux
source venv/bin/activate

Step 2: Install Dependencies

cd AiTools
pip install -r requirements.txt

Step 3: Setup PostgreSQL

Install PostgreSQL: https://www.postgresql.org/download/

Then create the database:

CREATE DATABASE langgraph_memory;

Step 4: Configure Environment Variables

cp AiTools/.env.example AiTools/.env

Edit AiTools/.env with your actual keys:

GROQ_API_KEY=your_groq_api_key
TAVILY_API_KEY=your_tavily_api_key
AVIATIONSTACK_API_KEY=your_aviationstack_api_key
DATABASE_URL=postgresql://postgres:postgres@localhost:5433/langgraph_memory

Step 5: Run the Backend

cd AiTools
uvicorn server:app --host 0.0.0.0 --port 8000 --reload

Step 6: Run the Frontend

cd frontend
npm install
npm run dev

🔑 API Keys

Key Where to Get
GROQ_API_KEY https://console.groq.com
TAVILY_API_KEY https://tavily.com
AVIATIONSTACK_API_KEY https://aviationstack.com

🌐 API Endpoints

Endpoint Method Description
/api/health GET Check if backend and database are running
/api/plan POST Generate a complete travel plan
/docs GET Interactive Swagger API documentation

Example Request

curl -X POST http://localhost:8000/api/plan \
  -H "Content-Type: application/json" \
  -d '{
    "user_query": "Plan a 7-day trip to Tokyo under 2 Lakhs",
    "thread_id": "my_session"
  }'

Example Response

{
  "status": "success",
  "flight_results": "Airline: Japan Airlines\nDeparture: Indira Gandhi...",
  "hotel_results": "1. **Park Hyatt Tokyo**\n   https://...",
  "itinerary": "Day 1: Arrival in Tokyo...",
  "final_response": "Here is your complete 7-day Tokyo travel plan...",
  "llm_calls": 2,
  "agent_logs": [...]
}

🧪 Health Check

After running docker compose up -d:

cd AiTools
python check_health.py

Expected output:

============================================================
   AiTools -- Docker Health Check
============================================================

Checking: Backend -- FastAPI
  [OK]  status='ok'

Checking: PostgreSQL -- via Backend health response
  [OK]  database='PostgreSQL Docker'

------------------------------------------------------------
  Result: 2 passed  |  0 failed
------------------------------------------------------------

*** All services are UP and HEALTHY! ***

  Backend API  -->  http://localhost:8000
  API Docs     -->  http://localhost:8000/docs
  PostgreSQL   -->  localhost:5433

💡 How the 4 Agents Work

1. Flight Agent ✈️

Calls the AviationStack API to fetch real-time flight data. Extracts airline name, departure/arrival airports, and flight status. Stores results in the shared LangGraph State.

2. Hotel Agent 🏨

Uses Tavily Search API (AI-optimized web search) to find the best hotels for the destination. Returns top 5 results with titles, URLs, and summaries.

3. Itinerary Agent 🗓️

Sends flight + hotel data to Groq LLM (Llama 3.3 70B) with a prompt to act as an expert travel planner. Generates a detailed day-by-day itinerary based on all collected data.

4. Final Agent 🧠

Takes all collected information and generates a final polished travel plan using Groq LLM. This is the response shown to the user.

Memory System 💾

Every conversation is saved to PostgreSQL using LangGraph's PostgresSaver checkpointing. The thread_id parameter allows users to continue past conversations with full context.


📌 Example Prompts

Plan a complete 7-day Japan trip under 2 lakhs with flights and hotels
Plan a 5-day Paris luxury trip with 5-star hotels
Budget trip to Bangkok for 6 days
Weekend trip to Dubai — best hotels and attractions

⚠️ Important Notes

  • Keep your .env file private — never commit it to git
  • Use .env.example as a template to share required keys
  • The travel_plans/ folder is gitignored (generated output)
  • Regenerate your API keys if they were accidentally exposed

📄 License

MIT License — feel free to use and modify.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages