# aasthajjw/tripmate_ai architecture

> Architecture diagram of the GitHub repository aasthajjw/tripmate_ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aasthajjw/tripmate_ai
- Repository: https://github.com/aasthajjw/tripmate_ai

## Overview

TripMate AI turns a user's travel request into a combined travel plan through a FastAPI web app and a LangGraph agent workflow. The implemented workflow runs flight research, hotel research, itinerary generation, and final response generation in sequence; this differs from the README's illustrative parallel-agent diagram. Flight and hotel research use external services, while Groq supports itinerary and final-response generation. PostgreSQL stores graph checkpoints. The frontend also retains a conversation thread ID and offers copy and PDF-download actions. Unsampled template and styling details are not expanded here.

Main entry points: [`app.py`](https://github.com/aasthajjw/tripmate_ai/blob/main/app.py) (FastAPI routes), [`static/script.js`](https://github.com/aasthajjw/tripmate_ai/blob/main/static/script.js) (Request and results), [`backend.py`](https://github.com/aasthajjw/tripmate_ai/blob/main/backend.py) (LangGraph workflow), [`templates/index.html`](https://github.com/aasthajjw/tripmate_ai/blob/main/templates/index.html) (Travel interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_web_ui["Travel interface<br/>[index.html]"]
  node_browser_logic["Request and results<br/>[script.js]"]
  node_api["FastAPI routes<br/>[app.py]"]
end

subgraph group_orchestration["Travel workflow"]
  node_workflow["LangGraph workflow<br/>[backend.py]"]
  node_flight_agent["Flight agent<br/>[backend.py]"]
  node_hotel_agent["Hotel agent<br/>[backend.py]"]
  node_itinerary_agent["Itinerary agent<br/>[backend.py]"]
  node_final_agent["Final response agent<br/>[backend.py]"]
end

subgraph group_research["Research integrations"]
  node_flight_search["Flight search<br/>[flight_tool.py]"]
  node_hotel_search["Hotel search<br/>[tavily_tool.py]"]
end

subgraph group_persistence["Conversation persistence"]
  node_checkpoint["Postgres checkpointer<br/>[backend.py]"]
end

node_traveler(("Traveler"))
node_aviationstack{{"AviationStack"}}
node_tavily{{"Tavily search"}}
node_groq{{"Groq LLM"}}
node_postgres[("PostgreSQL")]

node_traveler -->|"enters request"| node_web_ui
node_web_ui -.->|"uses interface logic"| node_browser_logic
node_browser_logic -->|"POST /api/travel"| node_api
node_api -->|"renders page"| node_web_ui
node_api -->|"runs request"| node_workflow
node_workflow -->|"starts workflow"| node_flight_agent
node_flight_agent -->|"dispatches next"| node_hotel_agent
node_hotel_agent -->|"dispatches next"| node_itinerary_agent
node_itinerary_agent -->|"dispatches next"| node_final_agent
node_flight_agent -->|"searches flights"| node_flight_search
node_flight_search -->|"requests flight data"| node_aviationstack
node_hotel_agent -->|"searches hotels"| node_hotel_search
node_hotel_search -->|"searches web"| node_tavily
node_itinerary_agent -->|"generates itinerary"| node_groq
node_final_agent -->|"generates response"| node_groq
node_workflow -->|"configures checkpoints"| node_checkpoint
node_checkpoint -->|"persists state"| node_postgres
node_api -->|"returns plan"| node_browser_logic
node_browser_logic -->|"displays plan"| node_traveler

click node_web_ui "https://github.com/aasthajjw/tripmate_ai/blob/main/templates/index.html"
click node_browser_logic "https://github.com/aasthajjw/tripmate_ai/blob/main/static/script.js"
click node_api "https://github.com/aasthajjw/tripmate_ai/blob/main/app.py"
click node_workflow "https://github.com/aasthajjw/tripmate_ai/blob/main/backend.py"
click node_flight_agent "https://github.com/aasthajjw/tripmate_ai/blob/main/backend.py"
click node_hotel_agent "https://github.com/aasthajjw/tripmate_ai/blob/main/backend.py"
click node_itinerary_agent "https://github.com/aasthajjw/tripmate_ai/blob/main/backend.py"
click node_final_agent "https://github.com/aasthajjw/tripmate_ai/blob/main/backend.py"
click node_flight_search "https://github.com/aasthajjw/tripmate_ai/blob/main/tools/flight_tool.py"
click node_hotel_search "https://github.com/aasthajjw/tripmate_ai/blob/main/tools/tavily_tool.py"
click node_checkpoint "https://github.com/aasthajjw/tripmate_ai/blob/main/backend.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web_ui,node_browser_logic,node_api toneBlue
class node_workflow,node_flight_agent,node_hotel_agent,node_itinerary_agent,node_final_agent,node_postgres toneAmber
class node_flight_search,node_hotel_search toneMint
class node_checkpoint toneRose
class node_traveler,node_aviationstack,node_tavily,node_groq toneIndigo
```

## Components

### Web experience

- [Travel interface](https://github.com/aasthajjw/tripmate_ai/blob/main/templates/index.html): `templates/index.html`
- [Request and results](https://github.com/aasthajjw/tripmate_ai/blob/main/static/script.js): `static/script.js`
- [FastAPI routes](https://github.com/aasthajjw/tripmate_ai/blob/main/app.py): `app.py`

### Travel workflow

- [LangGraph workflow](https://github.com/aasthajjw/tripmate_ai/blob/main/backend.py): `backend.py`
- [Flight agent](https://github.com/aasthajjw/tripmate_ai/blob/main/backend.py): `backend.py`
- [Hotel agent](https://github.com/aasthajjw/tripmate_ai/blob/main/backend.py): `backend.py`
- [Itinerary agent](https://github.com/aasthajjw/tripmate_ai/blob/main/backend.py): `backend.py`
- [Final response agent](https://github.com/aasthajjw/tripmate_ai/blob/main/backend.py): `backend.py`

### Research integrations

- [Flight search](https://github.com/aasthajjw/tripmate_ai/blob/main/tools/flight_tool.py): `tools/flight_tool.py`
- [Hotel search](https://github.com/aasthajjw/tripmate_ai/blob/main/tools/tavily_tool.py): `tools/tavily_tool.py`

### Conversation persistence

- [Postgres checkpointer](https://github.com/aasthajjw/tripmate_ai/blob/main/backend.py): `backend.py`

### Other components

- **Traveler**
- **AviationStack**
- **Tavily search**
- **Groq LLM**
- **PostgreSQL**

## Connections

- Traveler → Travel interface: enters request (evidence: `README.md`)
- Travel interface → Request and results: uses interface logic
- Request and results → FastAPI routes: POST /api/travel (evidence: `static/script.js`)
- FastAPI routes → Travel interface: renders page (evidence: `app.py`)
- FastAPI routes → LangGraph workflow: runs request (evidence: `app.py`)
- LangGraph workflow → Flight agent: starts workflow (evidence: `backend.py`)
- Flight agent → Hotel agent: dispatches next (evidence: `backend.py`)
- Hotel agent → Itinerary agent: dispatches next (evidence: `backend.py`)
- Itinerary agent → Final response agent: dispatches next (evidence: `backend.py`)
- Flight agent → Flight search: searches flights (evidence: `backend.py`)
- Flight search → AviationStack: requests flight data (evidence: `README.md`)
- Hotel agent → Hotel search: searches hotels (evidence: `backend.py`)
- Hotel search → Tavily search: searches web (evidence: `tools/tavily_tool.py`)
- Itinerary agent → Groq LLM: generates itinerary (evidence: `backend.py`)
- Final response agent → Groq LLM: generates response (evidence: `backend.py`)
- LangGraph workflow → Postgres checkpointer: configures checkpoints (evidence: `backend.py`)
- Postgres checkpointer → PostgreSQL: persists state (evidence: `README.md`)
- FastAPI routes → Request and results: returns plan (evidence: `app.py`)
- Request and results → Traveler: displays plan (evidence: `static/script.js`)
