# jmcico/triplanify architecture

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

- Interactive diagram: https://gitdiagram.com/jmcico/triplanify
- Repository: https://github.com/jmcico/triplanify

## Overview

Triplanify is a stateful travel-planning API with a separate workflow worker. Users submit trip details and commands, the API persists and queues them, and the worker advances plans through input collection, travel-data retrieval, planning, evaluation, review, and confirmation. PostgreSQL stores business state and graph checkpoints. The README documents a temporary legacy Azure Foundry API alongside v1; the current v1 runtime uses mock travel providers and a deterministic model. Some workflow wiring is unsampled, so the graph omits unverified stage-to-stage transitions.

Main entry points: [`app/graph/factory.py`](https://github.com/jmcico/triplanify/blob/main/app/graph/factory.py) (Plan workflow), [`app/core/runtime.py`](https://github.com/jmcico/triplanify/blob/main/app/core/runtime.py) (Runtime wiring), [`app/providers/aggregation.py`](https://github.com/jmcico/triplanify/blob/main/app/providers/aggregation.py) (Provider aggregation), [`app/worker.py`](https://github.com/jmcico/triplanify/blob/main/app/worker.py) (Workflow worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API and commands"]
  node_api["FastAPI entry<br/>[main.py]"]
  node_v1["V1 endpoints<br/>[router.py]"]
  node_legacy["Legacy endpoints<br/>[agent_service.py]"]
  node_worker["Workflow worker<br/>[worker.py]"]
end

subgraph group_workflow["Planning workflow"]
  node_runtime["Runtime wiring<br/>[runtime.py]"]
  node_graph["Plan workflow<br/>[factory.py]"]
  node_projection["Graph projection<br/>[projection.py]"]
  node_graph_state["Workflow state<br/>[state.py]"]
end

subgraph group_domain["Trip domain"]
  node_trip_request["Trip requirements<br/>[trip_request.py]"]
  node_itinerary["Itinerary plans<br/>[itinerary.py]"]
  node_provider_data["Travel data models<br/>[providers.py]"]
  node_rules["Plan evaluation rules<br/>[rules.py]"]
end

subgraph group_integrations["Providers and model"]
  node_provider_aggregation["Provider aggregation<br/>[aggregation.py]"]
  node_provider_adapters["Provider adapters<br/>[mock.py]"]
  node_provider_resilience["Provider resilience<br/>[resilience.py]"]
  node_llm["Deterministic model<br/>[deterministic.py]"]
end

subgraph group_storage["Persistence"]
  node_database["Database sessions<br/>[database.py]"]
  node_repositories["Business repositories<br/>[repositories.py]"]
  node_models["Business records<br/>[models.py]"]
  node_checkpoints["Graph checkpoints<br/>[checkpoints.py]"]
end

node_traveler(("Traveler"))
node_postgres[("PostgreSQL")]

node_traveler -->|"submits trip"| node_api
node_api -->|"routes v1"| node_v1
node_api -->|"routes legacy"| node_legacy
node_traveler -.->|"uses legacy API"| node_legacy
node_v1 -->|"reads and writes"| node_repositories
node_v1 -->|"queues commands"| node_worker
node_traveler -->|"polls and refines"| node_v1
node_worker -->|"runs workflow"| node_graph
node_worker -->|"claims and updates runs"| node_repositories
node_worker -->|"initializes checkpoints"| node_checkpoints
node_runtime -->|"creates sessions"| node_database
node_runtime -->|"provides dependencies"| node_graph
node_runtime -->|"configures providers"| node_provider_aggregation
node_runtime -->|"instantiates mocks"| node_provider_adapters
node_runtime -->|"configures retries"| node_provider_resilience
node_runtime -->|"selects model"| node_llm
node_runtime -->|"configures projection"| node_projection
node_graph -->|"extracts trip details"| node_llm
node_graph -->|"fetches travel data"| node_provider_aggregation
node_graph -->|"saves snapshots"| node_projection
node_graph -->|"uses state"| node_graph_state
node_graph -->|"evaluates plans"| node_rules
node_graph -->|"parses requirements"| node_trip_request
node_graph -->|"validates plan"| node_itinerary
node_graph -->|"uses travel results"| node_provider_data
node_provider_aggregation -->|"dispatches requests"| node_provider_adapters
node_provider_aggregation -->|"executes resiliently"| node_provider_resilience
node_provider_aggregation -->|"returns normalized data"| node_provider_data
node_projection -->|"persists projections"| node_repositories
node_repositories -->|"queries records"| node_models
node_database -->|"connects"| node_postgres
node_checkpoints -->|"stores checkpoints"| node_postgres
node_database -->|"provides ORM base"| node_models
node_trip_request -.->|"informs planning"| node_itinerary

click node_api "https://github.com/jmcico/triplanify/blob/main/app/main.py"
click node_v1 "https://github.com/jmcico/triplanify/blob/main/app/api/v1/router.py"
click node_legacy "https://github.com/jmcico/triplanify/blob/main/app/api/agent_service.py"
click node_worker "https://github.com/jmcico/triplanify/blob/main/app/worker.py"
click node_runtime "https://github.com/jmcico/triplanify/blob/main/app/core/runtime.py"
click node_graph "https://github.com/jmcico/triplanify/blob/main/app/graph/factory.py"
click node_projection "https://github.com/jmcico/triplanify/blob/main/app/graph/projection.py"
click node_graph_state "https://github.com/jmcico/triplanify/blob/main/app/graph/state.py"
click node_trip_request "https://github.com/jmcico/triplanify/blob/main/app/domain/trip_request.py"
click node_itinerary "https://github.com/jmcico/triplanify/blob/main/app/domain/itinerary.py"
click node_provider_data "https://github.com/jmcico/triplanify/blob/main/app/domain/providers.py"
click node_rules "https://github.com/jmcico/triplanify/blob/main/app/domain/rules.py"
click node_provider_aggregation "https://github.com/jmcico/triplanify/blob/main/app/providers/aggregation.py"
click node_provider_adapters "https://github.com/jmcico/triplanify/blob/main/app/providers/mock.py"
click node_provider_resilience "https://github.com/jmcico/triplanify/blob/main/app/providers/resilience.py"
click node_llm "https://github.com/jmcico/triplanify/blob/main/app/llm/deterministic.py"
click node_database "https://github.com/jmcico/triplanify/blob/main/app/persistence/database.py"
click node_repositories "https://github.com/jmcico/triplanify/blob/main/app/persistence/repositories.py"
click node_models "https://github.com/jmcico/triplanify/blob/main/app/persistence/models.py"
click node_checkpoints "https://github.com/jmcico/triplanify/blob/main/app/persistence/checkpoints.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_api,node_v1,node_legacy,node_worker toneBlue
class node_runtime,node_graph,node_projection,node_graph_state,node_postgres toneAmber
class node_trip_request,node_itinerary,node_provider_data,node_rules toneMint
class node_provider_aggregation,node_provider_adapters,node_provider_resilience,node_llm toneRose
class node_database,node_repositories,node_models,node_checkpoints,node_traveler toneIndigo
```

## Components

### API and commands

- [FastAPI entry](https://github.com/jmcico/triplanify/blob/main/app/main.py): `app/main.py`
- [V1 endpoints](https://github.com/jmcico/triplanify/blob/main/app/api/v1/router.py): `app/api/v1/router.py`
- [Legacy endpoints](https://github.com/jmcico/triplanify/blob/main/app/api/agent_service.py): `app/api/agent_service.py`
- [Workflow worker](https://github.com/jmcico/triplanify/blob/main/app/worker.py): `app/worker.py`

### Planning workflow

- [Runtime wiring](https://github.com/jmcico/triplanify/blob/main/app/core/runtime.py): `app/core/runtime.py`
- [Plan workflow](https://github.com/jmcico/triplanify/blob/main/app/graph/factory.py): `app/graph/factory.py`
- [Graph projection](https://github.com/jmcico/triplanify/blob/main/app/graph/projection.py): `app/graph/projection.py`
- [Workflow state](https://github.com/jmcico/triplanify/blob/main/app/graph/state.py): `app/graph/state.py`

### Trip domain

- [Trip requirements](https://github.com/jmcico/triplanify/blob/main/app/domain/trip_request.py): `app/domain/trip_request.py`
- [Itinerary plans](https://github.com/jmcico/triplanify/blob/main/app/domain/itinerary.py): `app/domain/itinerary.py`
- [Travel data models](https://github.com/jmcico/triplanify/blob/main/app/domain/providers.py): `app/domain/providers.py`
- [Plan evaluation rules](https://github.com/jmcico/triplanify/blob/main/app/domain/rules.py): `app/domain/rules.py`

### Providers and model

- [Provider aggregation](https://github.com/jmcico/triplanify/blob/main/app/providers/aggregation.py): `app/providers/aggregation.py`
- [Provider adapters](https://github.com/jmcico/triplanify/blob/main/app/providers/mock.py): `app/providers/mock.py`
- [Provider resilience](https://github.com/jmcico/triplanify/blob/main/app/providers/resilience.py): `app/providers/resilience.py`
- [Deterministic model](https://github.com/jmcico/triplanify/blob/main/app/llm/deterministic.py): `app/llm/deterministic.py`

### Persistence

- [Database sessions](https://github.com/jmcico/triplanify/blob/main/app/persistence/database.py): `app/persistence/database.py`
- [Business repositories](https://github.com/jmcico/triplanify/blob/main/app/persistence/repositories.py): `app/persistence/repositories.py`
- [Business records](https://github.com/jmcico/triplanify/blob/main/app/persistence/models.py): `app/persistence/models.py`
- [Graph checkpoints](https://github.com/jmcico/triplanify/blob/main/app/persistence/checkpoints.py): `app/persistence/checkpoints.py`

### Other components

- **Traveler**
- **PostgreSQL**

## Connections

- Traveler → FastAPI entry: submits trip (evidence: `README.md`)
- FastAPI entry → V1 endpoints: routes v1 (evidence: `app/main.py`)
- FastAPI entry → Legacy endpoints: routes legacy (evidence: `app/main.py`)
- Traveler → Legacy endpoints: uses legacy API (evidence: `README.md`)
- V1 endpoints → Business repositories: reads and writes (evidence: `app/api/v1/router.py`)
- V1 endpoints → Workflow worker: queues commands (evidence: `README.md`)
- Traveler → V1 endpoints: polls and refines (evidence: `README.md`)
- Workflow worker → Plan workflow: runs workflow (evidence: `app/worker.py`)
- Workflow worker → Business repositories: claims and updates runs (evidence: `app/worker.py`)
- Workflow worker → Graph checkpoints: initializes checkpoints (evidence: `app/worker.py`)
- Runtime wiring → Database sessions: creates sessions (evidence: `app/core/runtime.py`)
- Runtime wiring → Plan workflow: provides dependencies (evidence: `app/core/runtime.py`)
- Runtime wiring → Provider aggregation: configures providers (evidence: `app/core/runtime.py`)
- Runtime wiring → Provider adapters: instantiates mocks (evidence: `app/core/runtime.py`)
- Runtime wiring → Provider resilience: configures retries (evidence: `app/core/runtime.py`)
- Runtime wiring → Deterministic model: selects model (evidence: `app/core/runtime.py`)
- Runtime wiring → Graph projection: configures projection (evidence: `app/core/runtime.py`)
- Plan workflow → Deterministic model: extracts trip details (evidence: `app/graph/factory.py`)
- Plan workflow → Provider aggregation: fetches travel data (evidence: `app/graph/factory.py`)
- Plan workflow → Graph projection: saves snapshots (evidence: `app/graph/factory.py`)
- Plan workflow → Workflow state: uses state (evidence: `app/graph/factory.py`)
- Plan workflow → Plan evaluation rules: evaluates plans (evidence: `app/graph/factory.py`)
- Plan workflow → Trip requirements: parses requirements (evidence: `app/graph/factory.py`)
- Plan workflow → Itinerary plans: validates plan (evidence: `app/graph/factory.py`)
- Plan workflow → Travel data models: uses travel results (evidence: `app/graph/factory.py`)
- Provider aggregation → Provider adapters: dispatches requests (evidence: `app/providers/aggregation.py`)
- Provider aggregation → Provider resilience: executes resiliently (evidence: `app/providers/aggregation.py`)
- Provider aggregation → Travel data models: returns normalized data (evidence: `app/providers/aggregation.py`)
- Graph projection → Business repositories: persists projections (evidence: `app/graph/projection.py`)
- Business repositories → Business records: queries records (evidence: `app/persistence/repositories.py`)
- Database sessions → PostgreSQL: connects (evidence: `app/persistence/database.py`)
- Graph checkpoints → PostgreSQL: stores checkpoints (evidence: `app/persistence/checkpoints.py`)
- Database sessions → Business records: provides ORM base (evidence: `app/persistence/models.py`)
- Trip requirements → Itinerary plans: informs planning
