Your personal travel envoy, that remembers
Features β’ Architecture β’ Getting Started β’ Tech Stack
legate is an intelligent travel assistant that automatically ingests your booking confirmation emails, builds a comprehensive record of your trips, and provides a conversational AI agent that understands your travel history and preferences.
Unlike generic travel apps, legate learns your preferences over time with your explicit consent β never silently. It proactively flags itinerary issues, fills knowledge gaps, and becomes more useful with every trip.
- Structured facts (dates, bookings, confirmations) are always queried from the database β never hallucinated
- User preferences (travel habits, favorite neighborhoods) are only saved with explicit user confirmation
- Live data (weather, exchange rates) is always fetched fresh β never cached as "memory"
- Gmail OAuth integration β secure mailbox connection with granular scoping
- LLM-powered extraction using Instructor + Google Gemini β reliable structured parsing without brittle regex
- Multi-format support β flights, accommodations, and activities
- Automatic trip grouping β intelligently associates bookings with the correct trip
Built on PydanticAI with a deliberately constrained, typed toolset:
Query tools:
query_tripsβ search and filter your trip databaseget_trip_detailβ retrieve full booking details for a specific tripfind_split_tripsβ identify trips that should be mergedget_weatherβ live weather lookups for trip dates/locations
Mutation tools (propose β confirm β execute flow):
- Create, update, and delete trips with human-readable diffs
- Manage flight and accommodation bookings
- Merge mis-split trips with automatic itinerary gap-checking
- All mutations require explicit user confirmation tokens
- Itinerary gap detection β flags tight layovers, overlapping bookings, and missing connections
- Semantic memory (planned) β preference storage with pgvector for natural language retrieval
- Multi-user support β full user isolation with Google OAuth authentication
- Rate limiting β SlowAPI integration for abuse prevention
- Observability β Langfuse tracing for all LLM calls
backend/
βββ agent/ # PydanticAI concierge with typed tool definitions
βββ extraction/ # Instructor-based email β structured data pipeline
βββ routers/ # FastAPI endpoints (trips, chat, OAuth, etc.)
βββ services/ # Business logic (ingestion, grouping, auth)
βββ schemas/ # Pydantic v2 models for all I/O
βββ models.py # SQLModel database schema
βββ main.py # FastAPI app with CORS, rate limiting, error handling
Key Design Decisions:
- Instructor for one-shot extraction tasks (email β
FlightBooking) - PydanticAI for multi-step reasoning and tool orchestration
- SQLModel for type-safe database operations with SQLAlchemy under the hood
- Alembic for database migrations
- Loguru for structured logging
- Python 3.12+ with uv installed
- Node.js 20+ and npm
- PostgreSQL 15+
- Google Cloud project with Gmail API enabled
cd backend
# Copy and configure environment
cp .env.example .env
# Fill in:
# - DATABASE_URL (PostgreSQL connection string)
# - GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET (OAuth credentials)
# - GEMINI_API_KEY (Google AI API key)
# - SESSION_SECRET_KEY (generate with `python -c "import secrets; print(secrets.token_urlsafe(32))"`)
# Install dependencies
uv sync
# Run migrations
uv run alembic upgrade head
# Start dev server
uv run uvicorn main:app --reloadBackend will be available at http://localhost:8000
cd frontend
# Install dependencies
npm install
# Generate TypeScript types from backend OpenAPI schema
npm run generate:types
# Start dev server
npm run devFrontend will be available at http://localhost:3000
- Navigate to
http://localhost:3000 - Sign in with Google
- Authorize Gmail access
- legate will begin ingesting travel-related emails automatically
Backend:
- FastAPI β modern Python web framework
- PydanticAI β agent framework with typed tools
- Instructor β structured LLM outputs
- SQLModel β SQL databases with Python types
- Google Gemini β LLM provider
- Alembic β database migrations
- Langfuse β LLM observability
Frontend:
- Next.js 14 β React framework with app router
- TypeScript β strict type safety
- react-markdown β render agent responses
Infrastructure:
- PostgreSQL β relational data storage
- (Planned) pgvector β semantic memory retrieval
See AGENTS.md for AI assistant guidelines and ARCHITECTURE.md for detailed design rationale.
Key tenets:
- All external I/O uses Pydantic models β no loose dicts
- Type hints are mandatory
- Agent toolset is deliberately constrained and documented
- Memory writes require explicit user confirmation
- New dependencies require justification
- Email ingestion + OAuth flow
- Structured extraction pipeline (flights, accommodations)
- Trip data model + schema
- Basic trip dashboard UI
- Concierge agent v1 (query, propose/confirm mutations)
- Itinerary gap-checking
- Multi-user support with auth isolation
- Semantic memory (pgvector) + preference learning
- Email notifications (Resend)
- Production deployment (Vercel + Railway/Fly.io)
- Mobile-responsive UI polish
MIT β see LICENSE for details.