Skip to content

sholgaat/legate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

52 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Legate ✈️πŸͺ

Your personal travel envoy, that remembers

Features β€’ Architecture β€’ Getting Started β€’ Tech Stack

Overview

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.

Core Philosophy

  • 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"

Features

Email Ingestion & Extraction

  • 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

Conversational Concierge Agent

Built on PydanticAI with a deliberately constrained, typed toolset:

Query tools:

  • query_trips β€” search and filter your trip database
  • get_trip_detail β€” retrieve full booking details for a specific trip
  • find_split_trips β€” identify trips that should be merged
  • get_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

Intelligent Features

  • 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

Architecture

Backend (FastAPI + Python)

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

Getting Started

Prerequisites

  • Python 3.12+ with uv installed
  • Node.js 20+ and npm
  • PostgreSQL 15+
  • Google Cloud project with Gmail API enabled

1. Backend Setup

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 --reload

Backend will be available at http://localhost:8000

2. Frontend Setup

cd frontend

# Install dependencies
npm install

# Generate TypeScript types from backend OpenAPI schema
npm run generate:types

# Start dev server
npm run dev

Frontend will be available at http://localhost:3000

3. Connect Your Gmail

  1. Navigate to http://localhost:3000
  2. Sign in with Google
  3. Authorize Gmail access
  4. legate will begin ingesting travel-related emails automatically

Tech Stack

Backend:

Frontend:

Infrastructure:

  • PostgreSQL β€” relational data storage
  • (Planned) pgvector β€” semantic memory retrieval

Development Principles

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

Roadmap

  • 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

License

MIT β€” see LICENSE for details.

About

Your personal travel envoy ✈️πŸͺ

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors