# explosion/spacy architecture

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

## Overview

spaCy is an NLP library: users process text through a language-specific tokenizer and configurable pipeline, producing annotated Docs for downstream use. Its separate training workflow converts and initializes data, trains components, evaluates them, and packages deployable pipelines; project commands support end-to-end workflows. The graph preserves major documented NLP capabilities and the website’s documentation/universe surfaces. Edges are limited to README statements and relationships visible in the supplied excerpts or source index; unsampled implementation details are not inferred.

Main entry points: [`spacy/language.py`](https://github.com/explosion/spacy/blob/master/spacy/language.py) (Language Pipeline), [`spacy/cli/train.py`](https://github.com/explosion/spacy/blob/master/spacy/cli/train.py) (Training CLI), [`spacy/pipeline/factories.py`](https://github.com/explosion/spacy/blob/master/spacy/pipeline/factories.py) (Component Factories), [`website/src/templates/index.js`](https://github.com/explosion/spacy/blob/master/website/src/templates/index.js) (Website Layout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["NLP Runtime"]
  node_language["Language Pipeline<br/>[language.py]"]
  node_languages["Language Rules"]
  node_docsdata["Doc Data<br/>[_serialize.py]"]
  node_lookups[("Lookup Data<br/>[lookups.py]")]
  node_factories["Component Factories<br/>[factories.py]"]
  node_registry["Registrations<br/>[registrations.py]"]
end

subgraph group_models["Pipeline Models"]
  node_tagparse["Tagging and Parsing<br/>[parser.py]"]
  node_ner["Named Entities<br/>[factories.py]"]
  node_textcat["Text Classification<br/>[textcat.py]"]
  node_spans["Span Categorization<br/>[spancat.py]"]
  node_linking["Entity Linking<br/>[entity_linker.py]"]
  node_lemmatization["Lemmatization"]
  node_scoring["Scoring<br/>[scorer.py]"]
end

subgraph group_training["Training and Projects"]
  node_convert["Data Conversion"]
  node_initialize["Model Initialization<br/>[initialize.py]"]
  node_trainloop["Training Loop<br/>[loop.py]"]
  node_cli["Training CLI<br/>[train.py]"]
  node_project["Project Workflows"]
  node_package["Model Packaging<br/>[package.py]"]
end

subgraph group_docs["Documentation Site"]
  node_site["Website Layout<br/>[index.js]"]
  node_home["Landing Page<br/>[index.tsx]"]
  node_universe["Universe Catalog<br/>[universe.js]"]
  node_linkcomponent["Site Links<br/>[link.js]"]
end

node_user(("Application Developer"))

node_user -->|"processes text"| node_language
node_language -->|"uses language rules"| node_languages
node_language -->|"loads factories"| node_factories
node_language -->|"serializes Docs"| node_docsdata
node_factories -->|"registers entity ruler"| node_ner
node_factories -->|"constructs categorizer"| node_spans
node_factories -->|"constructs linker"| node_linking
node_language -->|"uses lookup data"| node_lookups
node_language -->|"uses scorer"| node_scoring
node_language -->|"uses registrations"| node_registry
node_language -.->|"runs model pipeline"| node_tagparse
node_language -.->|"runs classifier"| node_textcat
node_language -.->|"runs lemmatizer"| node_lemmatization
node_cli -.->|"converts training data"| node_convert
node_cli -->|"initializes pipeline"| node_initialize
node_initialize -->|"configures pipeline"| node_language
node_cli -.->|"starts training"| node_trainloop
node_trainloop -->|"updates components"| node_language
node_project -.->|"orchestrates workflows"| node_cli
node_cli -.->|"packages trained model"| node_package
node_home -->|"renders in layout"| node_site
node_site -->|"uses links"| node_linkcomponent
node_site -.->|"renders universe pages"| node_universe

click node_language "https://github.com/explosion/spacy/blob/master/spacy/language.py"
click node_languages "https://github.com/explosion/spacy/tree/master/spacy/lang"
click node_docsdata "https://github.com/explosion/spacy/blob/master/spacy/tokens/_serialize.py"
click node_lookups "https://github.com/explosion/spacy/blob/master/spacy/lookups.py"
click node_factories "https://github.com/explosion/spacy/blob/master/spacy/pipeline/factories.py"
click node_registry "https://github.com/explosion/spacy/blob/master/spacy/registrations.py"
click node_tagparse "https://github.com/explosion/spacy/blob/master/spacy/ml/models/parser.py"
click node_ner "https://github.com/explosion/spacy/blob/master/spacy/pipeline/factories.py"
click node_textcat "https://github.com/explosion/spacy/blob/master/spacy/pipeline/textcat.py"
click node_spans "https://github.com/explosion/spacy/blob/master/spacy/pipeline/spancat.py"
click node_linking "https://github.com/explosion/spacy/blob/master/spacy/pipeline/entity_linker.py"
click node_lemmatization "https://github.com/explosion/spacy/blob/master/spacy/pipeline/edit_tree_lemmatizer.py"
click node_scoring "https://github.com/explosion/spacy/blob/master/spacy/scorer.py"
click node_convert "https://github.com/explosion/spacy/tree/master/spacy/training/converters"
click node_initialize "https://github.com/explosion/spacy/blob/master/spacy/training/initialize.py"
click node_trainloop "https://github.com/explosion/spacy/blob/master/spacy/training/loop.py"
click node_cli "https://github.com/explosion/spacy/blob/master/spacy/cli/train.py"
click node_project "https://github.com/explosion/spacy/tree/master/spacy/cli/project"
click node_package "https://github.com/explosion/spacy/blob/master/spacy/cli/package.py"
click node_site "https://github.com/explosion/spacy/blob/master/website/src/templates/index.js"
click node_home "https://github.com/explosion/spacy/blob/master/website/pages/index.tsx"
click node_universe "https://github.com/explosion/spacy/blob/master/website/src/templates/universe.js"
click node_linkcomponent "https://github.com/explosion/spacy/blob/master/website/src/components/link.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_language,node_languages,node_docsdata,node_lookups,node_factories,node_registry toneBlue
class node_tagparse,node_ner,node_textcat,node_spans,node_linking,node_lemmatization,node_scoring toneAmber
class node_convert,node_initialize,node_trainloop,node_cli,node_project,node_package toneMint
class node_site,node_home,node_universe,node_linkcomponent toneRose
class node_user toneIndigo
```

## Components

### NLP Runtime

- [Language Pipeline](https://github.com/explosion/spacy/blob/master/spacy/language.py): `spacy/language.py`
- [Language Rules](https://github.com/explosion/spacy/tree/master/spacy/lang): `spacy/lang`
- [Doc Data](https://github.com/explosion/spacy/blob/master/spacy/tokens/_serialize.py): `spacy/tokens/_serialize.py`
- [Lookup Data](https://github.com/explosion/spacy/blob/master/spacy/lookups.py): `spacy/lookups.py`
- [Component Factories](https://github.com/explosion/spacy/blob/master/spacy/pipeline/factories.py): `spacy/pipeline/factories.py`
- [Registrations](https://github.com/explosion/spacy/blob/master/spacy/registrations.py): `spacy/registrations.py`

### Pipeline Models

- [Tagging and Parsing](https://github.com/explosion/spacy/blob/master/spacy/ml/models/parser.py): `spacy/ml/models/parser.py`
- [Named Entities](https://github.com/explosion/spacy/blob/master/spacy/pipeline/factories.py): `spacy/pipeline/factories.py`
- [Text Classification](https://github.com/explosion/spacy/blob/master/spacy/pipeline/textcat.py): `spacy/pipeline/textcat.py`
- [Span Categorization](https://github.com/explosion/spacy/blob/master/spacy/pipeline/spancat.py): `spacy/pipeline/spancat.py`
- [Entity Linking](https://github.com/explosion/spacy/blob/master/spacy/pipeline/entity_linker.py): `spacy/pipeline/entity_linker.py`
- [Lemmatization](https://github.com/explosion/spacy/blob/master/spacy/pipeline/edit_tree_lemmatizer.py): `spacy/pipeline/edit_tree_lemmatizer.py`
- [Scoring](https://github.com/explosion/spacy/blob/master/spacy/scorer.py): `spacy/scorer.py`

### Training and Projects

- [Data Conversion](https://github.com/explosion/spacy/tree/master/spacy/training/converters): `spacy/training/converters`
- [Model Initialization](https://github.com/explosion/spacy/blob/master/spacy/training/initialize.py): `spacy/training/initialize.py`
- [Training Loop](https://github.com/explosion/spacy/blob/master/spacy/training/loop.py): `spacy/training/loop.py`
- [Training CLI](https://github.com/explosion/spacy/blob/master/spacy/cli/train.py): `spacy/cli/train.py`
- [Project Workflows](https://github.com/explosion/spacy/tree/master/spacy/cli/project): `spacy/cli/project`
- [Model Packaging](https://github.com/explosion/spacy/blob/master/spacy/cli/package.py): `spacy/cli/package.py`

### Documentation Site

- [Website Layout](https://github.com/explosion/spacy/blob/master/website/src/templates/index.js): `website/src/templates/index.js`
- [Landing Page](https://github.com/explosion/spacy/blob/master/website/pages/index.tsx): `website/pages/index.tsx`
- [Universe Catalog](https://github.com/explosion/spacy/blob/master/website/src/templates/universe.js): `website/src/templates/universe.js`
- [Site Links](https://github.com/explosion/spacy/blob/master/website/src/components/link.js): `website/src/components/link.js`

### Other components

- **Application Developer**

## Connections

- Application Developer → Language Pipeline: processes text
- Language Pipeline → Language Rules: uses language rules (evidence: `spacy/language.py`)
- Language Pipeline → Component Factories: loads factories (evidence: `spacy/language.py`)
- Language Pipeline → Doc Data: serializes Docs
- Component Factories → Named Entities: registers entity ruler (evidence: `spacy/pipeline/factories.py`)
- Component Factories → Span Categorization: constructs categorizer (evidence: `spacy/pipeline/factories.py`)
- Component Factories → Entity Linking: constructs linker (evidence: `spacy/pipeline/factories.py`)
- Language Pipeline → Lookup Data: uses lookup data (evidence: `spacy/language.py`)
- Language Pipeline → Scoring: uses scorer (evidence: `spacy/language.py`)
- Language Pipeline → Registrations: uses registrations (evidence: `spacy/__init__.py`)
- Language Pipeline → Tagging and Parsing: runs model pipeline
- Language Pipeline → Text Classification: runs classifier
- Language Pipeline → Lemmatization: runs lemmatizer
- Training CLI → Data Conversion: converts training data
- Training CLI → Model Initialization: initializes pipeline
- Model Initialization → Language Pipeline: configures pipeline (evidence: `spacy/training/initialize.py`)
- Training CLI → Training Loop: starts training
- Training Loop → Language Pipeline: updates components (evidence: `spacy/training/loop.py`)
- Project Workflows → Training CLI: orchestrates workflows
- Training CLI → Model Packaging: packages trained model
- Landing Page → Website Layout: renders in layout (evidence: `website/pages/index.tsx`)
- Website Layout → Site Links: uses links (evidence: `website/src/templates/index.js`)
- Website Layout → Universe Catalog: renders universe pages (evidence: `website/src/templates/index.js`)
