# ovh/configstore architecture

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

- Interactive diagram: https://gitdiagram.com/ovh/configstore
- Repository: https://github.com/ovh/configstore

## Overview

configstore is a Go configuration-discovery library: applications register or configure providers, retrieve a merged list of prioritized items, then look up or filter values. Built-ins cover files, file hierarchies, and environment variables; custom providers extend the same abstraction. Refreshing file providers notify watchers. The excerpts show the central store, provider implementations, item/list behavior, and filtering; the graph omits uncertain provider-factory and refresh wiring beyond explicit references.

Main entry points: [`store.go`](https://github.com/ovh/configstore/blob/master/store.go) (Configuration Store), [`providers.go`](https://github.com/ovh/configstore/blob/master/providers.go) (File Providers), [`provider_filetree.go`](https://github.com/ovh/configstore/blob/master/provider_filetree.go) (File Tree Provider), [`configstore.go`](https://github.com/ovh/configstore/blob/master/configstore.go) (Provider Factories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_api["Package API<br/>[defaultstore.go]"]
  node_factory["Provider Factories<br/>[configstore.go]"]
end

subgraph group_providers["Configuration Providers"]
  node_file["File Providers<br/>[providers.go]"]
  node_filetree["File Tree Provider"]
  node_environment["Environment Provider<br/>[providers.go]"]
  node_custom["Custom Providers<br/>[configstore.go]"]
  node_memory["In-Memory Provider<br/>[providers.go]"]
end

subgraph group_core["Store And Items"]
  node_store["Configuration Store<br/>[store.go]"]
  node_items["Configuration Items<br/>[item.go]"]
  node_itemlist["Merged Item List<br/>[list.go]"]
  node_errors["Configuration Errors<br/>[error.go]"]
end

subgraph group_filtering["Filtering"]
  node_filter["Item Filter<br/>[filter.go]"]
end

node_application(("Application"))
node_filedata["Configuration Files"]
node_environmentdata["Process Environment"]
node_watchers["Change Watchers"]

node_application -->|"configures and reads"| node_api
node_api -->|"delegates to"| node_store
node_store -->|"resolves configured factories"| node_factory
node_factory -->|"registers"| node_file
node_factory -->|"registers"| node_filetree
node_factory -->|"registers"| node_environment
node_application -->|"registers providers"| node_custom
node_store -->|"creates"| node_file
node_store -->|"creates"| node_filetree
node_store -->|"creates"| node_environment
node_file -->|"reads"| node_filedata
node_filetree -->|"traverses"| node_filedata
node_environment -->|"reads"| node_environmentdata
node_file -->|"populates"| node_memory
node_filetree -->|"populates"| node_memory
node_environment -->|"populates"| node_memory
node_store -->|"merges provider results"| node_itemlist
node_store -->|"invokes registered providers"| node_custom
node_itemlist -->|"indexes and returns"| node_items
node_itemlist -->|"reports lookup failures"| node_errors
node_api -->|"exposes notifications"| node_watchers
node_file -->|"notifies on refresh"| node_watchers
node_filetree -->|"notifies on refresh"| node_watchers
node_filter -->|"fetches item list"| node_store
node_filter -->|"transforms list"| node_itemlist
node_filter -->|"unmarshals values"| node_items

click node_api "https://github.com/ovh/configstore/blob/master/defaultstore.go"
click node_factory "https://github.com/ovh/configstore/blob/master/configstore.go"
click node_store "https://github.com/ovh/configstore/blob/master/store.go"
click node_file "https://github.com/ovh/configstore/blob/master/providers.go"
click node_filetree "https://github.com/ovh/configstore/blob/master/provider_filetree.go"
click node_environment "https://github.com/ovh/configstore/blob/master/providers.go"
click node_custom "https://github.com/ovh/configstore/blob/master/configstore.go"
click node_memory "https://github.com/ovh/configstore/blob/master/providers.go"
click node_items "https://github.com/ovh/configstore/blob/master/item.go"
click node_itemlist "https://github.com/ovh/configstore/blob/master/list.go"
click node_errors "https://github.com/ovh/configstore/blob/master/error.go"
click node_filter "https://github.com/ovh/configstore/blob/master/filter.go"

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_factory toneBlue
class node_file,node_filetree,node_environment,node_custom,node_memory toneAmber
class node_store,node_items,node_itemlist,node_errors toneMint
class node_filter toneRose
class node_application,node_filedata,node_environmentdata,node_watchers toneIndigo
```

## Components

### Public API

- [Package API](https://github.com/ovh/configstore/blob/master/defaultstore.go): `defaultstore.go`
- [Provider Factories](https://github.com/ovh/configstore/blob/master/configstore.go): `configstore.go`

### Configuration Providers

- [File Providers](https://github.com/ovh/configstore/blob/master/providers.go): `providers.go`
- [File Tree Provider](https://github.com/ovh/configstore/blob/master/provider_filetree.go): `provider_filetree.go`
- [Environment Provider](https://github.com/ovh/configstore/blob/master/providers.go): `providers.go`
- [Custom Providers](https://github.com/ovh/configstore/blob/master/configstore.go): `configstore.go`
- [In-Memory Provider](https://github.com/ovh/configstore/blob/master/providers.go): `providers.go`

### Store And Items

- [Configuration Store](https://github.com/ovh/configstore/blob/master/store.go): `store.go`
- [Configuration Items](https://github.com/ovh/configstore/blob/master/item.go): `item.go`
- [Merged Item List](https://github.com/ovh/configstore/blob/master/list.go): `list.go`
- [Configuration Errors](https://github.com/ovh/configstore/blob/master/error.go): `error.go`

### Filtering

- [Item Filter](https://github.com/ovh/configstore/blob/master/filter.go): `filter.go`

### Other components

- **Application**
- **Configuration Files**
- **Process Environment**
- **Change Watchers**

## Connections

- Application → Package API: configures and reads (evidence: `README.md`)
- Package API → Configuration Store: delegates to (evidence: `defaultstore.go`)
- Configuration Store → Provider Factories: resolves configured factories (evidence: `store.go`)
- Provider Factories → File Providers: registers (evidence: `configstore.go`)
- Provider Factories → File Tree Provider: registers (evidence: `configstore.go`)
- Provider Factories → Environment Provider: registers (evidence: `configstore.go`)
- Application → Custom Providers: registers providers (evidence: `README.md`)
- Configuration Store → File Providers: creates (evidence: `store.go`)
- Configuration Store → File Tree Provider: creates (evidence: `store.go`)
- Configuration Store → Environment Provider: creates
- File Providers → Configuration Files: reads (evidence: `providers.go`)
- File Tree Provider → Configuration Files: traverses (evidence: `provider_filetree.go`)
- Environment Provider → Process Environment: reads (evidence: `providers.go`)
- File Providers → In-Memory Provider: populates (evidence: `providers.go`)
- File Tree Provider → In-Memory Provider: populates (evidence: `provider_filetree.go`)
- Environment Provider → In-Memory Provider: populates (evidence: `providers.go`)
- Configuration Store → Merged Item List: merges provider results (evidence: `store.go`)
- Configuration Store → Custom Providers: invokes registered providers (evidence: `store.go`)
- Merged Item List → Configuration Items: indexes and returns (evidence: `list.go`)
- Merged Item List → Configuration Errors: reports lookup failures (evidence: `list.go`)
- Package API → Change Watchers: exposes notifications (evidence: `defaultstore.go`)
- File Providers → Change Watchers: notifies on refresh (evidence: `providers.go`)
- File Tree Provider → Change Watchers: notifies on refresh (evidence: `provider_filetree.go`)
- Item Filter → Configuration Store: fetches item list (evidence: `filter.go`)
- Item Filter → Merged Item List: transforms list (evidence: `filter.go`)
- Item Filter → Configuration Items: unmarshals values (evidence: `filter.go`)
