# joke2k/faker architecture

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

- Interactive diagram: https://gitdiagram.com/joke2k/faker
- Repository: https://github.com/joke2k/faker

## Overview

#### Purpose and public entry points
Faker is a Python 3.8+ library for generating synthetic, optionally localized data for tests, fixtures, seeded datasets, and anonymization. The primary API is `faker.Faker`, exported from `faker/__init__.py`; module execution (`python -m faker`) enters `faker/__main__.py` and the installed CLI is implemented in `faker/cli.py`.

#### Construction and factory resolution
`Faker` is a proxy/facade that constructs one or more locale-specific generators and exposes their provider methods. `faker/factory.py` resolves providers and locale fallbacks; `faker/config.py` holds package defaults; `faker/proxy.py` manages the single- versus multiple-locale interface and locale selection. This is the primary boundary between user configuration (locales, weighting, custom providers) and concrete generator instances.

#### Generator runtime and invocation
`faker/generator.py` owns provider registration, shared or per-instance `random.Random` state, method formatting/dispatch, seeding, and the `unique` interface. Calls such as `fake.name()` are dynamically resolved to a registered provider method, then executed against generator state. `faker/exceptions.py` defines domain failures, including uniqueness exhaustion.

#### Provider plugin model
Providers are the extensibility and data-generation layer. `faker/providers/__init__.py` defines base and dynamic provider abstractions; domain implementations reside under `faker/providers/<domain>/__init__.py`, such as `faker/providers/person/__init__.py`, `faker/providers/address/__init__.py`, and `faker/providers/internet/__init__.py`. Applications can register custom provider classes or `DynamicProvider` instances on a generator, extending the callable fake namespace without altering core dispatch.

#### Localization and dataset inheritance
Provider modules are organized by domain and locale. A locale-specific implementation, e.g. `faker/providers/person/it_IT/__init__.py`, supplies localized datasets/behavior; factory loading falls back to an applicable base/default provider when a domain lacks that locale. This filesystem/package layout is the effective localization registry and a key compatibility boundary for additions. Representative broad domains include `faker/providers/date_time/`, `faker/providers/phone_number/`, and `faker/providers/ssn/`.

#### Integrations and auxiliary interfaces
The pytest plugin provides managed `faker` fixtures, locale/seed overrides, and unique-state handling through `faker/contrib/pytest/plugin.py`. Sphinx extensions support API/provider documentation generation in `faker/sphinx/autodoc.py` and `faker/sphinx/documentor.py`. Decode support is isolated in `faker/decode/__init__.py` and `faker/decode/codes.py`.

#### Execution environment and delivery
This is a distributable Python package configured by `setup.py` and `setup.cfg`, with type metadata in `faker/py.typed` and `faker/proxy.pyi`. CI and release automation run in GitHub Actions (`.github/workflows/ci.yml`, `.github/workflows/gh-release.yml`); documentation is built with Sphinx (`docs/conf.py`) and hosted configuration is present in `readthedocs.yml`. No application server, database, or required external runtime service is indicated; external integrations are package installation, pytest, Sphinx, PyPI release, and documentation hosting.

Main entry points: [`faker/factory.py`](https://github.com/joke2k/faker/blob/master/faker/factory.py) (Factory resolution), [`faker/generator.py`](https://github.com/joke2k/faker/blob/master/faker/generator.py) (Generator), [`faker/__init__.py`](https://github.com/joke2k/faker/blob/master/faker/__init__.py) (Faker API), [`faker/providers/person/__init__.py`](https://github.com/joke2k/faker/blob/master/faker/providers/person/__init__.py) (Domain providers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public interfaces"]
  node_api["Faker API<br/>Python facade<br/>[__init__.py]"]
  node_module_entry["Module entry<br/>Python module<br/>[__main__.py]"]
  node_cli["CLI<br/>command interface<br/>[cli.py]"]
end

subgraph group_runtime["Core runtime"]
  node_proxy["Locale proxy<br/>runtime facade<br/>[proxy.py]"]
  node_factory["Factory resolution<br/>provider loader<br/>[factory.py]"]
  node_config["Package defaults<br/>configuration<br/>[config.py]"]
  node_generator["Generator<br/>generation runtime<br/>[generator.py]"]
  node_exceptions["Domain exceptions<br/>[exceptions.py]"]
end

subgraph group_providers["Providers and localization"]
  node_provider_base["Provider abstractions<br/>plugin base<br/>[__init__.py]"]
  node_domains["Domain providers<br/>provider packages<br/>[__init__.py]"]
  node_localized_person["Localized provider<br/>locale dataset<br/>[__init__.py]"]
end

subgraph group_integrations["Integrations"]
  node_pytest["pytest plugin<br/>test integration<br/>[plugin.py]"]
  node_sphinx_autodoc["Sphinx autodoc<br/>documentation extension<br/>[autodoc.py]"]
  node_sphinx_documentor["Provider documentor<br/>documentation extension<br/>[documentor.py]"]
  node_decode["Decode support<br/>auxiliary API<br/>[__init__.py]"]
end

subgraph group_delivery["Packaging and delivery"]
  node_packaging["Package distribution<br/>Python packaging<br/>[setup.py]"]
  node_docs["Sphinx docs build<br/>documentation build<br/>[conf.py]"]
  node_ci["CI<br/>GitHub Actions workflow<br/>[ci.yml]"]
  node_release["Release automation<br/>GitHub Actions workflow<br/>[gh-release.yml]"]
end

node_api -->|"constructs"| node_proxy
node_module_entry -->|"runs"| node_cli
node_proxy -->|"requests locale generators"| node_factory
node_proxy -->|"routes calls"| node_generator
node_factory -->|"uses defaults"| node_config
node_factory -->|"builds"| node_generator
node_factory -->|"loads providers"| node_domains
node_factory -->|"selects locale or fallback"| node_localized_person
node_generator -->|"registers plugins"| node_provider_base
node_provider_base -->|"implemented by"| node_domains
node_localized_person -->|"specializes"| node_domains
node_generator -->|"raises"| node_exceptions
node_pytest -->|"provides fixture for"| node_api
node_sphinx_autodoc -.->|"documents"| node_api
node_sphinx_documentor -.->|"documents"| node_domains
node_docs -->|"loads"| node_sphinx_autodoc
node_docs -->|"loads"| node_sphinx_documentor
node_packaging -->|"distributes"| node_api
node_ci -->|"validates"| node_packaging
node_release -->|"publishes"| node_packaging

click node_api "https://github.com/joke2k/faker/blob/master/faker/__init__.py"
click node_module_entry "https://github.com/joke2k/faker/blob/master/faker/__main__.py"
click node_cli "https://github.com/joke2k/faker/blob/master/faker/cli.py"
click node_proxy "https://github.com/joke2k/faker/blob/master/faker/proxy.py"
click node_factory "https://github.com/joke2k/faker/blob/master/faker/factory.py"
click node_config "https://github.com/joke2k/faker/blob/master/faker/config.py"
click node_generator "https://github.com/joke2k/faker/blob/master/faker/generator.py"
click node_exceptions "https://github.com/joke2k/faker/blob/master/faker/exceptions.py"
click node_provider_base "https://github.com/joke2k/faker/blob/master/faker/providers/__init__.py"
click node_domains "https://github.com/joke2k/faker/blob/master/faker/providers/person/__init__.py"
click node_localized_person "https://github.com/joke2k/faker/blob/master/faker/providers/person/it_IT/__init__.py"
click node_pytest "https://github.com/joke2k/faker/blob/master/faker/contrib/pytest/plugin.py"
click node_sphinx_autodoc "https://github.com/joke2k/faker/blob/master/faker/sphinx/autodoc.py"
click node_sphinx_documentor "https://github.com/joke2k/faker/blob/master/faker/sphinx/documentor.py"
click node_decode "https://github.com/joke2k/faker/blob/master/faker/decode/__init__.py"
click node_packaging "https://github.com/joke2k/faker/blob/master/setup.py"
click node_docs "https://github.com/joke2k/faker/blob/master/docs/conf.py"
click node_ci "https://github.com/joke2k/faker/blob/master/.github/workflows/ci.yml"
click node_release "https://github.com/joke2k/faker/blob/master/.github/workflows/gh-release.yml"

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_module_entry,node_cli toneBlue
class node_proxy,node_factory,node_config,node_generator,node_exceptions toneAmber
class node_provider_base,node_domains,node_localized_person toneMint
class node_pytest,node_sphinx_autodoc,node_sphinx_documentor,node_decode toneRose
class node_packaging,node_docs,node_ci,node_release toneIndigo
```

## Components

### Public interfaces

- [Faker API](https://github.com/joke2k/faker/blob/master/faker/__init__.py): Python facade · Primary library entry point. · `faker/__init__.py`
- [Module entry](https://github.com/joke2k/faker/blob/master/faker/__main__.py): Python module · `faker/__main__.py`
- [CLI](https://github.com/joke2k/faker/blob/master/faker/cli.py): command interface · `faker/cli.py`

### Core runtime

- [Locale proxy](https://github.com/joke2k/faker/blob/master/faker/proxy.py): runtime facade · Selects and exposes one or more locale generators. · `faker/proxy.py`
- [Factory resolution](https://github.com/joke2k/faker/blob/master/faker/factory.py): provider loader · Resolves providers and locale fallbacks. · `faker/factory.py`
- [Package defaults](https://github.com/joke2k/faker/blob/master/faker/config.py): configuration · `faker/config.py`
- [Generator](https://github.com/joke2k/faker/blob/master/faker/generator.py): generation runtime · Registers providers, dispatches calls, and owns random and unique state. · `faker/generator.py`
- [Domain exceptions](https://github.com/joke2k/faker/blob/master/faker/exceptions.py): exceptions · Includes uniqueness exhaustion failures. · `faker/exceptions.py`

### Providers and localization

- [Provider abstractions](https://github.com/joke2k/faker/blob/master/faker/providers/__init__.py): plugin base · Base and dynamic provider classes. · `faker/providers/__init__.py`
- [Domain providers](https://github.com/joke2k/faker/blob/master/faker/providers/person/__init__.py): provider packages · Person, address, internet, date/time, phone, and SSN domains. · `faker/providers/person/__init__.py`
- [Localized provider](https://github.com/joke2k/faker/blob/master/faker/providers/person/it_IT/__init__.py): locale dataset · Representative Italian person implementation. · `faker/providers/person/it_IT/__init__.py`

### Integrations

- [pytest plugin](https://github.com/joke2k/faker/blob/master/faker/contrib/pytest/plugin.py): test integration · Managed faker fixtures with locale, seed, and unique handling. · `faker/contrib/pytest/plugin.py`
- [Sphinx autodoc](https://github.com/joke2k/faker/blob/master/faker/sphinx/autodoc.py): documentation extension · `faker/sphinx/autodoc.py`
- [Provider documentor](https://github.com/joke2k/faker/blob/master/faker/sphinx/documentor.py): documentation extension · `faker/sphinx/documentor.py`
- [Decode support](https://github.com/joke2k/faker/blob/master/faker/decode/__init__.py): auxiliary API · `faker/decode/__init__.py`

### Packaging and delivery

- [Package distribution](https://github.com/joke2k/faker/blob/master/setup.py): Python packaging · `setup.py`
- [Sphinx docs build](https://github.com/joke2k/faker/blob/master/docs/conf.py): documentation build · `docs/conf.py`
- [CI](https://github.com/joke2k/faker/blob/master/.github/workflows/ci.yml): GitHub Actions workflow · `.github/workflows/ci.yml`
- [Release automation](https://github.com/joke2k/faker/blob/master/.github/workflows/gh-release.yml): GitHub Actions workflow · `.github/workflows/gh-release.yml`

## Connections

- Faker API → Locale proxy: constructs
- Module entry → CLI: runs
- Locale proxy → Factory resolution: requests locale generators
- Locale proxy → Generator: routes calls
- Factory resolution → Package defaults: uses defaults
- Factory resolution → Generator: builds
- Factory resolution → Domain providers: loads providers
- Factory resolution → Localized provider: selects locale or fallback
- Generator → Provider abstractions: registers plugins
- Provider abstractions → Domain providers: implemented by
- Localized provider → Domain providers: specializes
- Generator → Domain exceptions: raises
- pytest plugin → Faker API: provides fixture for
- Sphinx autodoc → Faker API: documents
- Provider documentor → Domain providers: documents
- Sphinx docs build → Sphinx autodoc: loads
- Sphinx docs build → Provider documentor: loads
- Package distribution → Faker API: distributes
- CI → Package distribution: validates
- Release automation → Package distribution: publishes
