# configcat/python-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/configcat/python-sdk
- Repository: https://github.com/configcat/python-sdk

## Overview

This is the ConfigCat Python SDK: application code creates a client, reads feature-flag values (optionally for a user), and closes the client. The client obtains configuration through a polling service, which fetches and caches configuration; the client then evaluates settings and returns values or evaluation details. The README also documents three polling modes and user targeting. Override data sources and diagnostics are represented as meaningful SDK subsystems; some implementation links are limited to the source index because their code was not excerpted.

Main entry points: [`configcatclient/configcatclient.py`](https://github.com/configcat/python-sdk/blob/master/configcatclient/configcatclient.py) (SDK client), [`configcatclient/configservice.py`](https://github.com/configcat/python-sdk/blob/master/configcatclient/configservice.py) (Polling service), [`configcatclient/configfetcher.py`](https://github.com/configcat/python-sdk/blob/master/configcatclient/configfetcher.py) (Config fetcher), [`configcatclient/rolloutevaluator.py`](https://github.com/configcat/python-sdk/blob/master/configcatclient/rolloutevaluator.py) (Rollout evaluator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client API"]
  node_client["SDK client<br/>[configcatclient.py]"]
  node_settings["Client options"]
end

subgraph group_config["Configuration lifecycle"]
  node_service["Polling service<br/>[configservice.py]"]
  node_polling["Polling modes<br/>[pollingmode.py]"]
  node_fetcher["Config fetcher<br/>[configfetcher.py]"]
  node_entry["Config entry<br/>[configentry.py]"]
  node_cache[("Config cache<br/>[configcache.py]")]
  node_config_schema["Config schema<br/>[config.py]"]
  node_overrides["Override sources"]
  node_local_dict["Dictionary source"]
  node_local_file["File source"]
end

subgraph group_evaluation["Flag evaluation"]
  node_evaluator["Rollout evaluator"]
  node_user["User attributes<br/>[user.py]"]
  node_eval_details["Evaluation details"]
  node_eval_log["Evaluation log"]
  node_context["Evaluation context"]
end

subgraph group_support["SDK options and diagnostics"]
  node_cache_api["Cache interface<br/>[interfaces.py]"]
  node_logger["Logger and hooks<br/>[logger.py]"]
  node_governance["Data governance<br/>[datagovernance.py]"]
  node_refresh["Refresh result<br/>[refreshresult.py]"]
end

node_application(("Application"))
node_cdn["ConfigCat CDN"]

node_application -->|"creates and queries"| node_client
node_application -->|"provides targeting"| node_user
node_client -->|"gets configuration"| node_service
node_client -->|"uses options"| node_settings
node_service -->|"selects polling"| node_polling
node_service -->|"requests configuration"| node_fetcher
node_fetcher -->|"fetches configuration"| node_cdn
node_service -->|"reads and writes"| node_cache
node_cache -->|"implements"| node_cache_api
node_fetcher -->|"creates entries"| node_entry
node_service -->|"loads entries"| node_entry
node_fetcher -->|"normalizes config"| node_config_schema
node_client -->|"reads settings"| node_config_schema
node_client -->|"uses overrides"| node_overrides
node_local_dict -->|"implements source"| node_overrides
node_local_file -->|"implements source"| node_overrides
node_client -->|"evaluates settings"| node_evaluator
node_evaluator -->|"uses context"| node_context
node_evaluator -->|"checks attributes"| node_user
node_client -->|"builds details"| node_eval_details
node_evaluator -->|"records reasoning"| node_eval_log
node_client -->|"reports diagnostics"| node_logger
node_fetcher -->|"selects CDN region"| node_governance
node_service -->|"returns refresh status"| node_refresh

click node_client "https://github.com/configcat/python-sdk/blob/master/configcatclient/configcatclient.py"
click node_settings "https://github.com/configcat/python-sdk/blob/master/configcatclient/configcatoptions.py"
click node_service "https://github.com/configcat/python-sdk/blob/master/configcatclient/configservice.py"
click node_polling "https://github.com/configcat/python-sdk/blob/master/configcatclient/pollingmode.py"
click node_fetcher "https://github.com/configcat/python-sdk/blob/master/configcatclient/configfetcher.py"
click node_entry "https://github.com/configcat/python-sdk/blob/master/configcatclient/configentry.py"
click node_cache "https://github.com/configcat/python-sdk/blob/master/configcatclient/configcache.py"
click node_cache_api "https://github.com/configcat/python-sdk/blob/master/configcatclient/interfaces.py"
click node_config_schema "https://github.com/configcat/python-sdk/blob/master/configcatclient/config.py"
click node_overrides "https://github.com/configcat/python-sdk/blob/master/configcatclient/overridedatasource.py"
click node_local_dict "https://github.com/configcat/python-sdk/blob/master/configcatclient/localdictionarydatasource.py"
click node_local_file "https://github.com/configcat/python-sdk/blob/master/configcatclient/localfiledatasource.py"
click node_evaluator "https://github.com/configcat/python-sdk/blob/master/configcatclient/rolloutevaluator.py"
click node_user "https://github.com/configcat/python-sdk/blob/master/configcatclient/user.py"
click node_eval_details "https://github.com/configcat/python-sdk/blob/master/configcatclient/evaluationdetails.py"
click node_eval_log "https://github.com/configcat/python-sdk/blob/master/configcatclient/evaluationlogbuilder.py"
click node_context "https://github.com/configcat/python-sdk/blob/master/configcatclient/evaluationcontext.py"
click node_logger "https://github.com/configcat/python-sdk/blob/master/configcatclient/logger.py"
click node_governance "https://github.com/configcat/python-sdk/blob/master/configcatclient/datagovernance.py"
click node_refresh "https://github.com/configcat/python-sdk/blob/master/configcatclient/refreshresult.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_client,node_settings toneBlue
class node_service,node_polling,node_fetcher,node_entry,node_cache,node_config_schema,node_overrides,node_local_dict,node_local_file toneAmber
class node_evaluator,node_user,node_eval_details,node_eval_log,node_context toneMint
class node_cache_api,node_logger,node_governance,node_refresh toneRose
class node_application,node_cdn toneIndigo
```

## Components

### Client API

- [SDK client](https://github.com/configcat/python-sdk/blob/master/configcatclient/configcatclient.py): `configcatclient/configcatclient.py`
- [Client options](https://github.com/configcat/python-sdk/blob/master/configcatclient/configcatoptions.py): `configcatclient/configcatoptions.py`

### Configuration lifecycle

- [Polling service](https://github.com/configcat/python-sdk/blob/master/configcatclient/configservice.py): `configcatclient/configservice.py`
- [Polling modes](https://github.com/configcat/python-sdk/blob/master/configcatclient/pollingmode.py): `configcatclient/pollingmode.py`
- [Config fetcher](https://github.com/configcat/python-sdk/blob/master/configcatclient/configfetcher.py): `configcatclient/configfetcher.py`
- [Config entry](https://github.com/configcat/python-sdk/blob/master/configcatclient/configentry.py): `configcatclient/configentry.py`
- [Config cache](https://github.com/configcat/python-sdk/blob/master/configcatclient/configcache.py): `configcatclient/configcache.py`
- [Config schema](https://github.com/configcat/python-sdk/blob/master/configcatclient/config.py): `configcatclient/config.py`
- [Override sources](https://github.com/configcat/python-sdk/blob/master/configcatclient/overridedatasource.py): `configcatclient/overridedatasource.py`
- [Dictionary source](https://github.com/configcat/python-sdk/blob/master/configcatclient/localdictionarydatasource.py): `configcatclient/localdictionarydatasource.py`
- [File source](https://github.com/configcat/python-sdk/blob/master/configcatclient/localfiledatasource.py): `configcatclient/localfiledatasource.py`

### Flag evaluation

- [Rollout evaluator](https://github.com/configcat/python-sdk/blob/master/configcatclient/rolloutevaluator.py): `configcatclient/rolloutevaluator.py`
- [User attributes](https://github.com/configcat/python-sdk/blob/master/configcatclient/user.py): `configcatclient/user.py`
- [Evaluation details](https://github.com/configcat/python-sdk/blob/master/configcatclient/evaluationdetails.py): `configcatclient/evaluationdetails.py`
- [Evaluation log](https://github.com/configcat/python-sdk/blob/master/configcatclient/evaluationlogbuilder.py): `configcatclient/evaluationlogbuilder.py`
- [Evaluation context](https://github.com/configcat/python-sdk/blob/master/configcatclient/evaluationcontext.py): `configcatclient/evaluationcontext.py`

### SDK options and diagnostics

- [Cache interface](https://github.com/configcat/python-sdk/blob/master/configcatclient/interfaces.py): `configcatclient/interfaces.py`
- [Logger and hooks](https://github.com/configcat/python-sdk/blob/master/configcatclient/logger.py): `configcatclient/logger.py`
- [Data governance](https://github.com/configcat/python-sdk/blob/master/configcatclient/datagovernance.py): `configcatclient/datagovernance.py`
- [Refresh result](https://github.com/configcat/python-sdk/blob/master/configcatclient/refreshresult.py): `configcatclient/refreshresult.py`

### Other components

- **Application**
- **ConfigCat CDN**

## Connections

- Application → SDK client: creates and queries (evidence: `README.md`)
- Application → User attributes: provides targeting (evidence: `README.md`)
- SDK client → Polling service: gets configuration (evidence: `configcatclient/configcatclient.py`)
- SDK client → Client options: uses options (evidence: `configcatclient/configcatclient.py`)
- Polling service → Polling modes: selects polling (evidence: `configcatclient/configservice.py`)
- Polling service → Config fetcher: requests configuration (evidence: `configcatclient/configservice.py`)
- Config fetcher → ConfigCat CDN: fetches configuration (evidence: `configcatclient/configfetcher.py`)
- Polling service → Config cache: reads and writes (evidence: `configcatclient/configservice.py`)
- Config cache → Cache interface: implements (evidence: `configcatclient/configcache.py`)
- Config fetcher → Config entry: creates entries (evidence: `configcatclient/configfetcher.py`)
- Polling service → Config entry: loads entries (evidence: `configcatclient/configservice.py`)
- Config fetcher → Config schema: normalizes config (evidence: `configcatclient/configfetcher.py`)
- SDK client → Config schema: reads settings (evidence: `configcatclient/configcatclient.py`)
- SDK client → Override sources: uses overrides (evidence: `configcatclient/configcatclient.py`)
- Dictionary source → Override sources: implements source (evidence: `configcatclient/localdictionarydatasource.py`)
- File source → Override sources: implements source (evidence: `configcatclient/localfiledatasource.py`)
- SDK client → Rollout evaluator: evaluates settings (evidence: `configcatclient/configcatclient.py`)
- Rollout evaluator → Evaluation context: uses context (evidence: `configcatclient/rolloutevaluator.py`)
- Rollout evaluator → User attributes: checks attributes (evidence: `configcatclient/rolloutevaluator.py`)
- SDK client → Evaluation details: builds details (evidence: `configcatclient/configcatclient.py`)
- Rollout evaluator → Evaluation log: records reasoning (evidence: `configcatclient/rolloutevaluator.py`)
- SDK client → Logger and hooks: reports diagnostics (evidence: `configcatclient/configcatclient.py`)
- Config fetcher → Data governance: selects CDN region (evidence: `configcatclient/configfetcher.py`)
- Polling service → Refresh result: returns refresh status (evidence: `configcatclient/configservice.py`)
