# greencoda/confiq architecture

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

- Interactive diagram: https://gitdiagram.com/greencoda/confiq
- Repository: https://github.com/greencoda/confiq

## Overview

confiq is a Go configuration library: callers load one or more structured sources into a ConfigSet, optionally prefixing or layering values, then decode them into tagged Go values. The README documents JSON, TOML, YAML and environment input, selector paths, defaults/required/strict behavior, custom decoders, and common and primitive types. The graph shows the observed load-and-decode flow and its internal decoder layers; source-specific loader-to-ConfigSet wiring is documented in the README and examples. Other edges are limited to explicit calls visible in excerpts or SOURCE INDEX references.

Main entry points: [`configSet.go`](https://github.com/greencoda/confiq/blob/master/configSet.go) (ConfigSet), [`decode.go`](https://github.com/greencoda/confiq/blob/master/decode.go) (Reflective decoding), [`loaders/json/json.go`](https://github.com/greencoda/confiq/blob/master/loaders/json/json.go) (JSON loader), [`loaders/toml/toml.go`](https://github.com/greencoda/confiq/blob/master/loaders/toml/toml.go) (TOML loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Input loaders"]
  node_json["JSON loader<br/>[json.go]"]
  node_toml["TOML loader<br/>[toml.go]"]
  node_yaml["YAML loader<br/>[yaml.go]"]
  node_env["Env loader<br/>[env.go]"]
end

subgraph group_core["Configuration core"]
  node_configset["ConfigSet<br/>[configSet.go]"]
  node_loader["Value loader<br/>[loader.go]"]
  node_valuecontainer["Container interface<br/>[valueContainer.go]"]
  node_options["Load/decode options<br/>[options.go]"]
end

subgraph group_decoding["Decode engine"]
  node_selector["Path segments<br/>[segment.go]"]
  node_decode["Reflective decoding<br/>[decode.go]"]
  node_primitives["Primitive decoders"]
  node_common["Common decoders<br/>[commonDecoders.go]"]
end

node_caller(("Go caller"))
node_target["Tagged Go target"]

node_caller -->|"creates input"| node_json
node_caller -->|"creates input"| node_toml
node_caller -->|"creates input"| node_yaml
node_caller -->|"creates input"| node_env
node_caller -->|"creates and loads"| node_configset
node_json -->|"supplies values"| node_configset
node_toml -->|"supplies values"| node_configset
node_yaml -->|"supplies values"| node_configset
node_env -->|"supplies values"| node_configset
node_configset -->|"accepts container"| node_valuecontainer
node_configset -->|"applies values"| node_loader
node_caller -->|"configures prefixes"| node_options
node_configset -->|"decodes target"| node_decode
node_decode -->|"populates fields"| node_target
node_decode -->|"resolves paths"| node_selector
node_decode -->|"decodes primitives"| node_primitives
node_decode -->|"supports common types"| node_common
node_caller -->|"provides tagged type"| node_target

click node_json "https://github.com/greencoda/confiq/blob/master/loaders/json/json.go"
click node_toml "https://github.com/greencoda/confiq/blob/master/loaders/toml/toml.go"
click node_yaml "https://github.com/greencoda/confiq/blob/master/loaders/yaml/yaml.go"
click node_env "https://github.com/greencoda/confiq/blob/master/loaders/env/env.go"
click node_configset "https://github.com/greencoda/confiq/blob/master/configSet.go"
click node_loader "https://github.com/greencoda/confiq/blob/master/loader.go"
click node_valuecontainer "https://github.com/greencoda/confiq/blob/master/valueContainer.go"
click node_options "https://github.com/greencoda/confiq/blob/master/options.go"
click node_selector "https://github.com/greencoda/confiq/blob/master/segment.go"
click node_decode "https://github.com/greencoda/confiq/blob/master/decode.go"
click node_primitives "https://github.com/greencoda/confiq/blob/master/primitiveDecoders.go"
click node_common "https://github.com/greencoda/confiq/blob/master/commonDecoders.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_json,node_toml,node_yaml,node_env toneBlue
class node_configset,node_loader,node_valuecontainer,node_options toneAmber
class node_selector,node_decode,node_primitives,node_common toneMint
class node_caller,node_target toneIndigo
```

## Components

### Input loaders

- [JSON loader](https://github.com/greencoda/confiq/blob/master/loaders/json/json.go): `loaders/json/json.go`
- [TOML loader](https://github.com/greencoda/confiq/blob/master/loaders/toml/toml.go): `loaders/toml/toml.go`
- [YAML loader](https://github.com/greencoda/confiq/blob/master/loaders/yaml/yaml.go): `loaders/yaml/yaml.go`
- [Env loader](https://github.com/greencoda/confiq/blob/master/loaders/env/env.go): `loaders/env/env.go`

### Configuration core

- [ConfigSet](https://github.com/greencoda/confiq/blob/master/configSet.go): `configSet.go`
- [Value loader](https://github.com/greencoda/confiq/blob/master/loader.go): `loader.go`
- [Container interface](https://github.com/greencoda/confiq/blob/master/valueContainer.go): `valueContainer.go`
- [Load/decode options](https://github.com/greencoda/confiq/blob/master/options.go): `options.go`

### Decode engine

- [Path segments](https://github.com/greencoda/confiq/blob/master/segment.go): `segment.go`
- [Reflective decoding](https://github.com/greencoda/confiq/blob/master/decode.go): `decode.go`
- [Primitive decoders](https://github.com/greencoda/confiq/blob/master/primitiveDecoders.go): `primitiveDecoders.go`
- [Common decoders](https://github.com/greencoda/confiq/blob/master/commonDecoders.go): `commonDecoders.go`

### Other components

- **Go caller**
- **Tagged Go target**

## Connections

- Go caller → JSON loader: creates input
- Go caller → TOML loader: creates input
- Go caller → YAML loader: creates input
- Go caller → Env loader: creates input
- Go caller → ConfigSet: creates and loads
- JSON loader → ConfigSet: supplies values (evidence: `README.md`)
- TOML loader → ConfigSet: supplies values (evidence: `README.md`)
- YAML loader → ConfigSet: supplies values (evidence: `README.md`)
- Env loader → ConfigSet: supplies values (evidence: `README.md`)
- ConfigSet → Container interface: accepts container
- ConfigSet → Value loader: applies values (evidence: `loader.go`)
- Go caller → Load/decode options: configures prefixes
- ConfigSet → Reflective decoding: decodes target (evidence: `decode.go`)
- Reflective decoding → Tagged Go target: populates fields (evidence: `README.md`)
- Reflective decoding → Path segments: resolves paths (evidence: `decode.go`)
- Reflective decoding → Primitive decoders: decodes primitives (evidence: `decode.go`)
- Reflective decoding → Common decoders: supports common types (evidence: `README.md`)
- Go caller → Tagged Go target: provides tagged type
