# syrupy-project/syrupy architecture

> Architecture diagram of the GitHub repository syrupy-project/syrupy, 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/syrupy-project/syrupy
- Repository: https://github.com/syrupy-project/syrupy

## Overview

Syrupy is a pytest snapshot-testing plugin: a test compares a computed value with the `snapshot` assertion, which serializes it, recalls the saved value, and records the result. At session/report time, Syrupy discovers snapshots, tracks unused entries, and applies update or cleanup behavior. The README also documents Amber and JSON snapshots, image and single-file extensions, customizable serialization, and CLI reporting. The graph uses README statements and SOURCE INDEX references; unsampled subsystem internals and connections are not inferred.

Main entry points: [`src/syrupy/assertion.py`](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/assertion.py) (Snapshot assertion), [`src/syrupy/extensions/base.py`](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/extensions/base.py) (Extension base), [`src/syrupy/__init__.py`](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/__init__.py) (Plugin hooks), [`src/syrupy/session.py`](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/session.py) (Snapshot session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pytest["Pytest integration"]
  node_plugin["Plugin hooks<br/>[__init__.py]"]
  node_location["Test location<br/>[location.py]"]
end

subgraph group_assertion["Assertion flow"]
  node_assertion["Snapshot assertion<br/>[assertion.py]"]
  node_data["Snapshot collections<br/>[data.py]"]
end

subgraph group_formats["Snapshot formats"]
  node_amber["Amber extension<br/>[__init__.py]"]
  node_serializer["Amber serializer<br/>[serializer.py]"]
  node_extension["Extension base<br/>[base.py]"]
  node_singlefile["Single-file format<br/>[single_file.py]"]
  node_json["JSON format<br/>[__init__.py]"]
  node_image["Image format<br/>[image.py]"]
end

subgraph group_session["Session and reporting"]
  node_session["Snapshot session<br/>[session.py]"]
  node_report["Snapshot report<br/>[report.py]"]
  node_terminal["Terminal output<br/>[terminal.py]"]
  node_pycharm["PyCharm diff patch<br/>[pycharm_diff.py]"]
end

subgraph group_support["Utilities"]
  node_filters["Property filters<br/>[filters.py]"]
  node_matchers["Property matchers<br/>[matchers.py]"]
  node_utils["File and diff utilities<br/>[utils.py]"]
  node_exceptions["Snapshot exceptions<br/>[exceptions.py]"]
end

node_developer(("Test author"))
node_pytest(("Pytest"))

node_developer -->|"runs tests"| node_pytest
node_pytest -->|"loads plugin"| node_plugin
node_plugin -->|"provides fixture"| node_assertion
node_plugin -->|"creates session"| node_session
node_plugin -->|"uses locations"| node_location
node_assertion -->|"registers request"| node_session
node_assertion -->|"resolves names"| node_location
node_assertion -->|"serializes and recalls"| node_extension
node_assertion -->|"uses default"| node_amber
node_amber -->|"implements storage"| node_extension
node_amber -->|"uses serializer"| node_serializer
node_extension -->|"reads collections"| node_data
node_extension -->|"resolves paths"| node_location
node_serializer -->|"serializes snapshots"| node_data
node_session -->|"queues writes"| node_data
node_session -->|"builds report"| node_report
node_session -->|"writes and reads"| node_extension
node_session -->|"reconstructs locations"| node_location
node_report -->|"collects results"| node_assertion
node_report -->|"matches snapshots"| node_location
node_report -->|"compares collections"| node_data
node_report -->|"formats output"| node_terminal
node_plugin -->|"configures output"| node_terminal
node_pycharm -->|"patches diff"| node_assertion
node_json -->|"uses serializer"| node_serializer
node_json -->|"uses storage"| node_singlefile
node_image -->|"uses storage"| node_singlefile
node_singlefile -->|"extends storage"| node_extension
node_extension -->|"uses utilities"| node_utils
node_extension -->|"formats diffs"| node_terminal
node_assertion -->|"raises errors"| node_exceptions
node_session -->|"handles errors"| node_exceptions
node_plugin -.->|"offers format"| node_json
node_plugin -.->|"offers format"| node_image
node_assertion -.->|"accepts filters"| node_filters
node_assertion -.->|"accepts matchers"| node_matchers

click node_plugin "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/__init__.py"
click node_location "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/location.py"
click node_assertion "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/assertion.py"
click node_data "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/data.py"
click node_amber "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/extensions/amber/__init__.py"
click node_serializer "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/extensions/amber/serializer.py"
click node_extension "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/extensions/base.py"
click node_singlefile "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/extensions/single_file.py"
click node_json "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/extensions/json/__init__.py"
click node_image "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/extensions/image.py"
click node_session "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/session.py"
click node_report "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/report.py"
click node_terminal "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/terminal.py"
click node_pycharm "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/patches/pycharm_diff.py"
click node_filters "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/filters.py"
click node_matchers "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/matchers.py"
click node_utils "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/utils.py"
click node_exceptions "https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/exceptions.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_plugin,node_location toneBlue
class node_assertion,node_data toneAmber
class node_amber,node_serializer,node_extension,node_singlefile,node_json,node_image toneMint
class node_session,node_report,node_terminal,node_pycharm toneRose
class node_filters,node_matchers,node_utils,node_exceptions,node_developer,node_pytest toneIndigo
```

## Components

### Pytest integration

- [Plugin hooks](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/__init__.py): `src/syrupy/__init__.py`
- [Test location](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/location.py): `src/syrupy/location.py`

### Assertion flow

- [Snapshot assertion](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/assertion.py): `src/syrupy/assertion.py`
- [Snapshot collections](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/data.py): `src/syrupy/data.py`

### Snapshot formats

- [Amber extension](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/extensions/amber/__init__.py): `src/syrupy/extensions/amber/__init__.py`
- [Amber serializer](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/extensions/amber/serializer.py): `src/syrupy/extensions/amber/serializer.py`
- [Extension base](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/extensions/base.py): `src/syrupy/extensions/base.py`
- [Single-file format](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/extensions/single_file.py): `src/syrupy/extensions/single_file.py`
- [JSON format](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/extensions/json/__init__.py): `src/syrupy/extensions/json/__init__.py`
- [Image format](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/extensions/image.py): `src/syrupy/extensions/image.py`

### Session and reporting

- [Snapshot session](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/session.py): `src/syrupy/session.py`
- [Snapshot report](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/report.py): `src/syrupy/report.py`
- [Terminal output](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/terminal.py): `src/syrupy/terminal.py`
- [PyCharm diff patch](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/patches/pycharm_diff.py): `src/syrupy/patches/pycharm_diff.py`

### Utilities

- [Property filters](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/filters.py): `src/syrupy/filters.py`
- [Property matchers](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/matchers.py): `src/syrupy/matchers.py`
- [File and diff utilities](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/utils.py): `src/syrupy/utils.py`
- [Snapshot exceptions](https://github.com/syrupy-project/syrupy/blob/main/src/syrupy/exceptions.py): `src/syrupy/exceptions.py`

### Other components

- **Test author**
- **Pytest**

## Connections

- Test author → Pytest: runs tests (evidence: `README.md`)
- Pytest → Plugin hooks: loads plugin (evidence: `README.md`)
- Plugin hooks → Snapshot assertion: provides fixture (evidence: `src/syrupy/__init__.py`)
- Plugin hooks → Snapshot session: creates session (evidence: `src/syrupy/__init__.py`)
- Plugin hooks → Test location: uses locations (evidence: `src/syrupy/__init__.py`)
- Snapshot assertion → Snapshot session: registers request (evidence: `src/syrupy/assertion.py`)
- Snapshot assertion → Test location: resolves names (evidence: `src/syrupy/assertion.py`)
- Snapshot assertion → Extension base: serializes and recalls (evidence: `src/syrupy/assertion.py`)
- Snapshot assertion → Amber extension: uses default (evidence: `src/syrupy/assertion.py`)
- Amber extension → Extension base: implements storage (evidence: `src/syrupy/extensions/amber/__init__.py`)
- Amber extension → Amber serializer: uses serializer (evidence: `src/syrupy/extensions/amber/__init__.py`)
- Extension base → Snapshot collections: reads collections (evidence: `src/syrupy/extensions/base.py`)
- Extension base → Test location: resolves paths (evidence: `src/syrupy/extensions/base.py`)
- Amber serializer → Snapshot collections: serializes snapshots (evidence: `src/syrupy/extensions/amber/serializer.py`)
- Snapshot session → Snapshot collections: queues writes (evidence: `src/syrupy/session.py`)
- Snapshot session → Snapshot report: builds report (evidence: `src/syrupy/session.py`)
- Snapshot session → Extension base: writes and reads (evidence: `src/syrupy/session.py`)
- Snapshot session → Test location: reconstructs locations (evidence: `src/syrupy/session.py`)
- Snapshot report → Snapshot assertion: collects results (evidence: `src/syrupy/report.py`)
- Snapshot report → Test location: matches snapshots (evidence: `src/syrupy/report.py`)
- Snapshot report → Snapshot collections: compares collections (evidence: `src/syrupy/report.py`)
- Snapshot report → Terminal output: formats output (evidence: `src/syrupy/report.py`)
- Plugin hooks → Terminal output: configures output (evidence: `src/syrupy/__init__.py`)
- PyCharm diff patch → Snapshot assertion: patches diff (evidence: `src/syrupy/patches/pycharm_diff.py`)
- JSON format → Amber serializer: uses serializer (evidence: `src/syrupy/extensions/json/__init__.py`)
- JSON format → Single-file format: uses storage (evidence: `src/syrupy/extensions/json/__init__.py`)
- Image format → Single-file format: uses storage (evidence: `src/syrupy/extensions/image.py`)
- Single-file format → Extension base: extends storage (evidence: `src/syrupy/extensions/single_file.py`)
- Extension base → File and diff utilities: uses utilities (evidence: `src/syrupy/extensions/base.py`)
- Extension base → Terminal output: formats diffs (evidence: `src/syrupy/extensions/base.py`)
- Snapshot assertion → Snapshot exceptions: raises errors (evidence: `src/syrupy/assertion.py`)
- Snapshot session → Snapshot exceptions: handles errors (evidence: `src/syrupy/session.py`)
- Plugin hooks → JSON format: offers format (evidence: `README.md`)
- Plugin hooks → Image format: offers format (evidence: `README.md`)
- Snapshot assertion → Property filters: accepts filters (evidence: `README.md`)
- Snapshot assertion → Property matchers: accepts matchers (evidence: `src/syrupy/assertion.py`)
