# netflix/falcor architecture

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

- Interactive diagram: https://gitdiagram.com/netflix/falcor
- Repository: https://github.com/netflix/falcor

## Overview

Falcor is a client-side model for traversing and updating a JSON Graph, with an optional data source for missing data. The principal workflow is a caller issuing a model read, Falcor resolving paths against its cache and requesting missing data, then merging the response into the cache for the model response. The graph also preserves set, invalidation, dereferencing, and cache-maintenance capabilities. Evidence is limited to the README and the supplied excerpts and source index; edges without direct relationship evidence are omitted.

Main entry points: [`lib/Model.js`](https://github.com/netflix/falcor/blob/master/lib/Model.js) (Falcor Model), [`lib/set/setJSONGraphs.js`](https://github.com/netflix/falcor/blob/master/lib/set/setJSONGraphs.js) (JSON Graph merge), [`lib/support/mergeJSONGraphNode.js`](https://github.com/netflix/falcor/blob/master/lib/support/mergeJSONGraphNode.js) (Cache node merge), [`lib/get/getBoundValue.js`](https://github.com/netflix/falcor/blob/master/lib/get/getBoundValue.js) (Bound value lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model_api["Model API"]
  node_model["Falcor Model<br/>[Model.js]"]
  node_model_response["Model responses<br/>[ModelResponse.js]"]
  node_deref["Bound models<br/>[index.js]"]
end

subgraph group_graph_access["Graph Access"]
  node_get_ops["Path reads<br/>[getValueSync.js]"]
  node_bound_value["Bound value lookup<br/>[getBoundValue.js]"]
  node_set_paths["Path value writes<br/>[setPathValues.js]"]
  node_set_graph["JSON Graph merge<br/>[setJSONGraphs.js]"]
  node_invalidation["Path invalidation"]
end

subgraph group_remote_requests["Remote Requests"]
  node_request_queue["Request batching<br/>[RequestQueueV2.js]"]
  node_get_request["Get request<br/>[GetRequestV2.js]"]
  node_get_cycle["Read request cycle<br/>[getRequestCycle.js]"]
  node_set_cycle["Set request cycle<br/>[setRequestCycle.js]"]
  node_data_source["Configured data source<br/>[DataSource.js]"]
end

subgraph group_cache_state["Cache State"]
  node_graph_cache[("JSON Graph cache<br/>[ModelRoot.js]")]
  node_graph_merge["Cache node merge"]
  node_cache_maintenance["Cache maintenance"]
  node_lru_collect["LRU collection<br/>[collect.js]"]
  node_ref_type["Reference type<br/>[ref.js]"]
  node_error_types["Error prototype setup"]
end

node_caller(("Application caller"))

node_caller -->|"calls get"| node_model
node_model -->|"configures source"| node_data_source
node_model -->|"returns response"| node_model_response
node_model -->|"uses queue"| node_request_queue
node_get_request -->|"merges response"| node_set_graph
node_set_graph -->|"merges nodes"| node_graph_merge
node_set_paths -->|"looks up bound value"| node_bound_value
node_invalidation -->|"looks up bound value"| node_bound_value
node_invalidation -->|"checks references"| node_ref_type
node_set_graph -->|"checks references"| node_ref_type
node_graph_merge -->|"checks references"| node_ref_type
node_graph_merge -->|"updates cache nodes"| node_cache_maintenance
node_lru_collect -->|"removes cache nodes"| node_cache_maintenance
node_get_cycle -->|"collects cache"| node_lru_collect
node_set_cycle -->|"reads model paths"| node_get_ops
node_deref -->|"resolves cache position"| node_bound_value
node_model -->|"owns cache root"| node_graph_cache

click node_model "https://github.com/netflix/falcor/blob/master/lib/Model.js"
click node_model_response "https://github.com/netflix/falcor/blob/master/lib/response/ModelResponse.js"
click node_deref "https://github.com/netflix/falcor/blob/master/lib/deref/index.js"
click node_get_ops "https://github.com/netflix/falcor/blob/master/lib/get/getValueSync.js"
click node_bound_value "https://github.com/netflix/falcor/blob/master/lib/get/getBoundValue.js"
click node_set_paths "https://github.com/netflix/falcor/blob/master/lib/set/setPathValues.js"
click node_set_graph "https://github.com/netflix/falcor/blob/master/lib/set/setJSONGraphs.js"
click node_invalidation "https://github.com/netflix/falcor/blob/master/lib/invalidate/invalidatePathSets.js"
click node_request_queue "https://github.com/netflix/falcor/blob/master/lib/request/RequestQueueV2.js"
click node_get_request "https://github.com/netflix/falcor/blob/master/lib/request/GetRequestV2.js"
click node_get_cycle "https://github.com/netflix/falcor/blob/master/lib/response/get/getRequestCycle.js"
click node_set_cycle "https://github.com/netflix/falcor/blob/master/lib/response/set/setRequestCycle.js"
click node_data_source "https://github.com/netflix/falcor/blob/master/lib/typedefs/DataSource.js"
click node_graph_cache "https://github.com/netflix/falcor/blob/master/lib/ModelRoot.js"
click node_graph_merge "https://github.com/netflix/falcor/blob/master/lib/support/mergeJSONGraphNode.js"
click node_cache_maintenance "https://github.com/netflix/falcor/tree/master/lib/support"
click node_lru_collect "https://github.com/netflix/falcor/blob/master/lib/lru/collect.js"
click node_ref_type "https://github.com/netflix/falcor/blob/master/lib/types/ref.js"
click node_error_types "https://github.com/netflix/falcor/blob/master/lib/errors/applyErrorPrototype.js"

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_model,node_model_response,node_deref toneBlue
class node_get_ops,node_bound_value,node_set_paths,node_set_graph,node_invalidation toneAmber
class node_request_queue,node_get_request,node_get_cycle,node_set_cycle,node_data_source toneMint
class node_graph_cache,node_graph_merge,node_cache_maintenance,node_lru_collect,node_ref_type,node_error_types toneRose
class node_caller toneIndigo
```

## Components

### Model API

- [Falcor Model](https://github.com/netflix/falcor/blob/master/lib/Model.js): `lib/Model.js`
- [Model responses](https://github.com/netflix/falcor/blob/master/lib/response/ModelResponse.js): `lib/response/ModelResponse.js`
- [Bound models](https://github.com/netflix/falcor/blob/master/lib/deref/index.js): `lib/deref/index.js`

### Graph Access

- [Path reads](https://github.com/netflix/falcor/blob/master/lib/get/getValueSync.js): `lib/get/getValueSync.js`
- [Bound value lookup](https://github.com/netflix/falcor/blob/master/lib/get/getBoundValue.js): `lib/get/getBoundValue.js`
- [Path value writes](https://github.com/netflix/falcor/blob/master/lib/set/setPathValues.js): `lib/set/setPathValues.js`
- [JSON Graph merge](https://github.com/netflix/falcor/blob/master/lib/set/setJSONGraphs.js): `lib/set/setJSONGraphs.js`
- [Path invalidation](https://github.com/netflix/falcor/blob/master/lib/invalidate/invalidatePathSets.js): `lib/invalidate/invalidatePathSets.js`

### Remote Requests

- [Request batching](https://github.com/netflix/falcor/blob/master/lib/request/RequestQueueV2.js): `lib/request/RequestQueueV2.js`
- [Get request](https://github.com/netflix/falcor/blob/master/lib/request/GetRequestV2.js): `lib/request/GetRequestV2.js`
- [Read request cycle](https://github.com/netflix/falcor/blob/master/lib/response/get/getRequestCycle.js): `lib/response/get/getRequestCycle.js`
- [Set request cycle](https://github.com/netflix/falcor/blob/master/lib/response/set/setRequestCycle.js): `lib/response/set/setRequestCycle.js`
- [Configured data source](https://github.com/netflix/falcor/blob/master/lib/typedefs/DataSource.js): `lib/typedefs/DataSource.js`

### Cache State

- [JSON Graph cache](https://github.com/netflix/falcor/blob/master/lib/ModelRoot.js): `lib/ModelRoot.js`
- [Cache node merge](https://github.com/netflix/falcor/blob/master/lib/support/mergeJSONGraphNode.js): `lib/support/mergeJSONGraphNode.js`
- [Cache maintenance](https://github.com/netflix/falcor/tree/master/lib/support): `lib/support`
- [LRU collection](https://github.com/netflix/falcor/blob/master/lib/lru/collect.js): `lib/lru/collect.js`
- [Reference type](https://github.com/netflix/falcor/blob/master/lib/types/ref.js): `lib/types/ref.js`
- [Error prototype setup](https://github.com/netflix/falcor/blob/master/lib/errors/applyErrorPrototype.js): `lib/errors/applyErrorPrototype.js`

### Other components

- **Application caller**

## Connections

- Application caller → Falcor Model: calls get (evidence: `README.md`)
- Falcor Model → Configured data source: configures source (evidence: `README.md`)
- Falcor Model → Model responses: returns response (evidence: `lib/Model.js`)
- Falcor Model → Request batching: uses queue (evidence: `lib/Model.js`)
- Get request → JSON Graph merge: merges response (evidence: `lib/request/GetRequestV2.js`)
- JSON Graph merge → Cache node merge: merges nodes (evidence: `lib/set/setJSONGraphs.js`)
- Path value writes → Bound value lookup: looks up bound value (evidence: `lib/set/setPathValues.js`)
- Path invalidation → Bound value lookup: looks up bound value (evidence: `lib/invalidate/invalidatePathSets.js`)
- Path invalidation → Reference type: checks references (evidence: `lib/invalidate/invalidatePathSets.js`)
- JSON Graph merge → Reference type: checks references (evidence: `lib/set/setJSONGraphs.js`)
- Cache node merge → Reference type: checks references (evidence: `lib/support/mergeJSONGraphNode.js`)
- Cache node merge → Cache maintenance: updates cache nodes (evidence: `lib/support/mergeJSONGraphNode.js`)
- LRU collection → Cache maintenance: removes cache nodes (evidence: `lib/lru/collect.js`)
- Read request cycle → LRU collection: collects cache (evidence: `lib/response/get/getRequestCycle.js`)
- Set request cycle → Path reads: reads model paths (evidence: `lib/response/set/setRequestCycle.js`)
- Bound models → Bound value lookup: resolves cache position (evidence: `lib/deref/index.js`)
- Falcor Model → JSON Graph cache: owns cache root (evidence: `lib/Model.js`)
