# pointfreeco/swift-composable-architecture architecture

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

- Interactive diagram: https://gitdiagram.com/pointfreeco/swift-composable-architecture
- Repository: https://github.com/pointfreeco/swift-composable-architecture

## Overview

The Composable Architecture is a Swift library for modeling application state, composing reducers, running effects, and exposing state/actions to UI. Its principal workflow is a view or caller sending an action to a Store; the Store invokes reducers to mutate state and receive effects, and resulting actions re-enter the Store while state changes are observed by the UI. The package also provides navigation/presentation, bindings, macro-generated ergonomics, and TestStore-driven verification. Edges reflect the README and sampled/indexed source references; unsampled subsystem links are omitted where invocation ownership is not established.

Main entry points: [`Sources/ComposableArchitecture/Store.swift`](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Store.swift) (Store Runtime), [`Sources/ComposableArchitecture/Reducer.swift`](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Reducer.swift) (Reducer Protocol), [`Sources/ComposableArchitecture/Effect.swift`](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Effect.swift) (Effect Runtime), [`Sources/ComposableArchitecture/Observation/ObservableState.swift`](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Observation/ObservableState.swift) (Observable State)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Feature Runtime"]
  node_store["Store Runtime<br/>[Store.swift]"]
  node_state["Feature State"]
  node_actions["Feature Actions"]
end

subgraph group_composition["Reducer Composition"]
  node_reducer["Reducer Protocol<br/>[Reducer.swift]"]
  node_builder["Reducer Builder"]
  node_reduce["Reduce Closure<br/>[Reduce.swift]"]
  node_presentation["Presentation Reducers"]
  node_stack["Stack Reducer<br/>[StackReducer.swift]"]
end

subgraph group_stateui["State and UI"]
  node_observable["Observable State"]
  node_observation["Store Observation"]
  node_binding["SwiftUI Bindings<br/>[Binding.swift]"]
  node_navigation["Navigation Observation"]
  node_viewaction["View Actions<br/>[ViewAction.swift]"]
end

subgraph group_effects["Effects"]
  node_effect["Effect Runtime<br/>[Effect.swift]"]
  node_publisher["Publisher Adapter<br/>[Publisher.swift]"]
  node_external(("External Services"))
end

subgraph group_tooling["Macros and Testing"]
  node_macro["Reducer Macro<br/>[ReducerMacro.swift]"]
  node_obsmacro["Observable State Macro"]
  node_teststore["Test Store<br/>[TestStore.swift]"]
end

node_caller(("Feature Caller"))

node_caller -->|"sends actions"| node_store
node_store -->|"runs reducer"| node_reducer
node_reducer -->|"mutates state"| node_state
node_reducer -->|"handles action"| node_actions
node_reducer -->|"returns effects"| node_effect
node_store -->|"runs effects"| node_effect
node_effect -->|"sends actions"| node_store
node_effect -->|"communicates outward"| node_external
node_publisher -->|"adapts publisher"| node_effect
node_builder -->|"composes reducers"| node_reducer
node_builder -->|"builds closure reducer"| node_reduce
node_presentation -->|"implements reducer"| node_reducer
node_stack -->|"implements reducer"| node_reducer
node_store -->|"exposes observations"| node_observation
node_observation -->|"observes state"| node_observable
node_binding -->|"binds state fields"| node_observable
node_navigation -->|"uses scoped stores"| node_store
node_viewaction -->|"sends view actions"| node_store
node_macro -->|"generates reducer APIs"| node_reducer
node_obsmacro -->|"generates observation support"| node_observable
node_teststore -->|"tests feature runtime"| node_store

click node_store "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Store.swift"
click node_reducer "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Reducer.swift"
click node_builder "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Reducer/ReducerBuilder.swift"
click node_reduce "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Reducer/Reducers/Reduce.swift"
click node_presentation "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Reducer/Reducers/PresentationReducer.swift"
click node_stack "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Reducer/Reducers/StackReducer.swift"
click node_effect "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Effect.swift"
click node_publisher "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Effects/Publisher.swift"
click node_observable "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Observation/ObservableState.swift"
click node_observation "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Observation/Store%2BObservation.swift"
click node_binding "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/SwiftUI/Binding.swift"
click node_navigation "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Observation/NavigationStack%2BObservation.swift"
click node_viewaction "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Observation/ViewAction.swift"
click node_macro "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitectureMacros/ReducerMacro.swift"
click node_obsmacro "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitectureMacros/ObservableStateMacro.swift"
click node_teststore "https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/TestStore.swift"

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_store,node_state,node_actions toneBlue
class node_reducer,node_builder,node_reduce,node_presentation,node_stack toneAmber
class node_observable,node_observation,node_binding,node_navigation,node_viewaction toneMint
class node_effect,node_publisher,node_external toneRose
class node_macro,node_obsmacro,node_teststore,node_caller toneIndigo
```

## Components

### Feature Runtime

- [Store Runtime](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Store.swift): `Sources/ComposableArchitecture/Store.swift`
- **Feature State**
- **Feature Actions**

### Reducer Composition

- [Reducer Protocol](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Reducer.swift): `Sources/ComposableArchitecture/Reducer.swift`
- [Reducer Builder](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Reducer/ReducerBuilder.swift): `Sources/ComposableArchitecture/Reducer/ReducerBuilder.swift`
- [Reduce Closure](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Reducer/Reducers/Reduce.swift): `Sources/ComposableArchitecture/Reducer/Reducers/Reduce.swift`
- [Presentation Reducers](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Reducer/Reducers/PresentationReducer.swift): `Sources/ComposableArchitecture/Reducer/Reducers/PresentationReducer.swift`
- [Stack Reducer](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Reducer/Reducers/StackReducer.swift): `Sources/ComposableArchitecture/Reducer/Reducers/StackReducer.swift`

### State and UI

- [Observable State](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Observation/ObservableState.swift): `Sources/ComposableArchitecture/Observation/ObservableState.swift`
- [Store Observation](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Observation/Store%2BObservation.swift): `Sources/ComposableArchitecture/Observation/Store+Observation.swift`
- [SwiftUI Bindings](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/SwiftUI/Binding.swift): `Sources/ComposableArchitecture/SwiftUI/Binding.swift`
- [Navigation Observation](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Observation/NavigationStack%2BObservation.swift): `Sources/ComposableArchitecture/Observation/NavigationStack+Observation.swift`
- [View Actions](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Observation/ViewAction.swift): `Sources/ComposableArchitecture/Observation/ViewAction.swift`

### Effects

- [Effect Runtime](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Effect.swift): `Sources/ComposableArchitecture/Effect.swift`
- [Publisher Adapter](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/Effects/Publisher.swift): `Sources/ComposableArchitecture/Effects/Publisher.swift`
- **External Services**

### Macros and Testing

- [Reducer Macro](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitectureMacros/ReducerMacro.swift): `Sources/ComposableArchitectureMacros/ReducerMacro.swift`
- [Observable State Macro](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitectureMacros/ObservableStateMacro.swift): `Sources/ComposableArchitectureMacros/ObservableStateMacro.swift`
- [Test Store](https://github.com/pointfreeco/swift-composable-architecture/blob/main/Sources/ComposableArchitecture/TestStore.swift): `Sources/ComposableArchitecture/TestStore.swift`

### Other components

- **Feature Caller**

## Connections

- Feature Caller → Store Runtime: sends actions (evidence: `README.md`)
- Store Runtime → Reducer Protocol: runs reducer (evidence: `Sources/ComposableArchitecture/Store.swift`)
- Reducer Protocol → Feature State: mutates state (evidence: `README.md`)
- Reducer Protocol → Feature Actions: handles action (evidence: `README.md`)
- Reducer Protocol → Effect Runtime: returns effects (evidence: `Sources/ComposableArchitecture/Reducer.swift`)
- Store Runtime → Effect Runtime: runs effects (evidence: `README.md`)
- Effect Runtime → Store Runtime: sends actions (evidence: `README.md`)
- Effect Runtime → External Services: communicates outward (evidence: `README.md`)
- Publisher Adapter → Effect Runtime: adapts publisher (evidence: `Sources/ComposableArchitecture/Effects/Publisher.swift`)
- Reducer Builder → Reducer Protocol: composes reducers (evidence: `Sources/ComposableArchitecture/Reducer/ReducerBuilder.swift`)
- Reducer Builder → Reduce Closure: builds closure reducer (evidence: `Sources/ComposableArchitecture/Reducer/ReducerBuilder.swift`)
- Presentation Reducers → Reducer Protocol: implements reducer (evidence: `Sources/ComposableArchitecture/Reducer/Reducers/PresentationReducer.swift`)
- Stack Reducer → Reducer Protocol: implements reducer (evidence: `Sources/ComposableArchitecture/Reducer/Reducers/StackReducer.swift`)
- Store Runtime → Store Observation: exposes observations (evidence: `Sources/ComposableArchitecture/Observation/Store+Observation.swift`)
- Store Observation → Observable State: observes state (evidence: `Sources/ComposableArchitecture/Observation/Store+Observation.swift`)
- SwiftUI Bindings → Observable State: binds state fields (evidence: `Sources/ComposableArchitecture/SwiftUI/Binding.swift`)
- Navigation Observation → Store Runtime: uses scoped stores (evidence: `Sources/ComposableArchitecture/Observation/NavigationStack+Observation.swift`)
- View Actions → Store Runtime: sends view actions (evidence: `Sources/ComposableArchitecture/Observation/ViewAction.swift`)
- Reducer Macro → Reducer Protocol: generates reducer APIs (evidence: `Sources/ComposableArchitectureMacros/ReducerMacro.swift`)
- Observable State Macro → Observable State: generates observation support (evidence: `Sources/ComposableArchitectureMacros/ObservableStateMacro.swift`)
- Test Store → Store Runtime: tests feature runtime (evidence: `Sources/ComposableArchitecture/TestStore.swift`)
