Skip to main content

Shared config loader, env resolver, and generic CRUD API factory for Analytic AI services.

Project description

configflow

Shared config loader, environment variable resolver, and generic CRUD API factory for Analytic AI services.

What it does

  • File-based config loading – load JSON config files with automatic ${ENV_VAR} placeholder resolution
  • ClickHouse-backed config store – versioned config management with live updates (no redeployment needed)
  • Generic CRUD API factory – create full REST APIs for any ClickHouse table in one function call
  • Config Management API – standardized config endpoints with versioning and reload support
  • Environment variable resolution – supports ${VAR} and ${VAR:default} patterns
  • ClickHouse table utilities – create tables with MergeTree engines, materialized views, projections

Installation

Basic Installation (Config Loading Only)

pip install configuration-core

With API Support (FastAPI + Pydantic)

pip install configuration-core[api]

With Everything (API + Cython Protection)

pip install configuration-core[all]

Quick Start

File-based Config Loading

from pathlib import Path
from configflow import load_config_from_path

# Load JSON config with automatic ${ENV_VAR} resolution
config = load_config_from_path(Path("config/config.json"))
print(config["database"]["host"])  # Resolved from environment

ClickHouse-backed Config Store

from configflow import ConfigStore, load_config_from_path

# Load initial config from file (once at startup)
cfg = load_config_from_path(Path("config/config.json"))

# Create versioned config store backed by ClickHouse
store = ConfigStore(
    initial_config=cfg,
    clickhouse_params=cfg["clickhouse"],
    config_name="my_service_config",
    environment="production",
)

# Get live config from database (cached after first call)
live_config = store.get_config()

# Update config at runtime (no redeployment needed)
store.patch_config({"threshold": 0.95})

# Reload from database
fresh_config = store.get_config(refresh=True)

Generic CRUD API (NEW in v0.2.0)

from fastapi import FastAPI
from configflow import create_crud_router
from clickhouse_core import ClickHouseConfig, get_client

app = FastAPI()

# Create full CRUD API for any ClickHouse table
crud_router = create_crud_router(
    table_name="users",
    clickhouse_client=get_client(ClickHouseConfig.from_env()),
    primary_key="user_id",
)

app.include_router(crud_router, prefix="/api/users", tags=["Users"])

# Now you have:
# GET /api/users?limit=10&offset=0
# GET /api/users/{user_id}
# POST /api/users
# PUT /api/users/{user_id}
# DELETE /api/users/{user_id}

Config Management API (NEW in v0.2.0)

from fastapi import FastAPI
from configflow import create_config_router, ConfigStore

app = FastAPI()

store = ConfigStore(
    initial_config=cfg,
    clickhouse_params=cfg["clickhouse"],
    config_name="service_config",
)

# Add standardized config endpoints
config_router = create_config_router(store)
app.include_router(config_router, prefix="/api/config", tags=["Config"])

# Provides:
# GET /api/config - Get current config
# PATCH /api/config - Partial update
# PUT /api/config - Full replace
# POST /api/config/reload - Reload from database

Dependencies

  • clickhouse-core (≥0.2.4) – shared ClickHouse connectivity library
  • fastapi (≥0.100.0) – optional, for API features
  • pydantic (≥2.0.0) – optional, for API features

Configuration

Environment variables for ClickHouse connection (inherited from clickhouse-core):

  • CLICKHOUSE_HOST
  • CLICKHOUSE_PORT
  • CLICKHOUSE_DATABASE
  • CLICKHOUSE_USERNAME
  • CLICKHOUSE_PASSWORD
  • CLICKHOUSE_PROTOCOL (tcp|http)
  • CLICKHOUSE_SECURE (true/false)

Documentation

For detailed usage, API reference, and advanced features, see:

Key Features

Recommended Usage Pattern

Use load_config_from_path only once at service startup to read connection parameters.
After that, always use ConfigStore.get_config() to get live config from the database.

Why?

JSON file ConfigStore (DB)
When to use Startup only All runtime reads
Supports live updates ❌ No – requires redeploy ✅ Yes – patch at runtime
Versioned history ❌ No ✅ Yes – full version history
Shared across pods ❌ No – each pod reads its own file ✅ Yes – all pods share one DB

Environment Variable Resolution

  • Supports ${VAR} and ${VAR:default} patterns in JSON config files
  • Variables are resolved at config read time
  • DB stores raw placeholders; resolution happens on each get_config() call
  • Same config works across all environments (dev/staging/prod)

Generic CRUD API Factory

  • Generate full REST APIs for any ClickHouse table
  • Automatic query building with filters, pagination, sorting
  • Type-safe Pydantic models generated from table schema
  • Customizable routes and permissions

License

See LICENSE file for details.

Author

sreeyenan (sreeyenanek@gmail.com)

Version

Current version: 0.2.2

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

configuration_core-0.2.2.tar.gz (41.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

configuration_core-0.2.2-cp311-cp311-win_amd64.whl (335.7 kB view details)

Uploaded CPython 3.11Windows x86-64

configuration_core-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

configuration_core-0.2.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ i686manylinux: glibc 2.5+ i686

configuration_core-0.2.2-cp311-cp311-macosx_11_0_arm64.whl (379.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

configuration_core-0.2.2-cp311-cp311-macosx_10_9_x86_64.whl (391.2 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

Details for the file configuration_core-0.2.2.tar.gz.

File metadata

  • Download URL: configuration_core-0.2.2.tar.gz
  • Upload date:
  • Size: 41.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for configuration_core-0.2.2.tar.gz
Algorithm Hash digest
SHA256 f8110cfbbc963b483ee5d98f5d3d517a5ef56541c10c76ed6f4cebf702c08b94
MD5 d17e11f55508947d39d5383983ddd95c
BLAKE2b-256 7662afaf366c1af4079ff5751e9223c6ce1cf5b72693ea4e98bb6a4d7d97c5c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for configuration_core-0.2.2.tar.gz:

Publisher: publish.yml on sreeyenan/configflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file configuration_core-0.2.2-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for configuration_core-0.2.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 639ae6eb7bf6fd2dc8a4741f62228fc8e001cb9f2221cd4236cc5b89762bbe2a
MD5 caddaa79b53c9a5b2296c3c8627e8b19
BLAKE2b-256 2842caeb59c91f4c4d0300b4eca6141ffec354c770d68d062b4a4a724a0b00c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for configuration_core-0.2.2-cp311-cp311-win_amd64.whl:

Publisher: publish.yml on sreeyenan/configflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file configuration_core-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for configuration_core-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0658bcc753e03e642f7fea08269099b56b6c774b1008ce4e06a45684f8f06f6b
MD5 a2b7b4558a13e29317df42e80a286af3
BLAKE2b-256 926f0647d86c33fcba702eb550474fce58458073d1ab6a25c11ff7526a1eb7ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for configuration_core-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on sreeyenan/configflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file configuration_core-0.2.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for configuration_core-0.2.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 a93f3a83f461418ccf9265cad5194da673dcb2c809858b8c8be19d3eca049295
MD5 723bdb940cfeca09ba71a2ecee02be11
BLAKE2b-256 84f11f18ccdc086189d706461f07ce941b8b95f0f1710073b879242ae2eeddea

See more details on using hashes here.

Provenance

The following attestation bundles were made for configuration_core-0.2.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl:

Publisher: publish.yml on sreeyenan/configflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file configuration_core-0.2.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for configuration_core-0.2.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f951f04738e199332e270094b801ad38580b2f1e9809da0d139594008df3ea47
MD5 7fd2c2ef6f17d6a489fb3635a5eb19f3
BLAKE2b-256 bba74b0749b4224479d2b59a772a12cfae35c8e3220ac88c70d126891d59b855

See more details on using hashes here.

Provenance

The following attestation bundles were made for configuration_core-0.2.2-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on sreeyenan/configflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file configuration_core-0.2.2-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for configuration_core-0.2.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0cec02325c034f9726fcaf51667141a954c411c7de1b149beb33f50b7ffd1b96
MD5 3e1ea4dfa579709975f876b13f8f70e9
BLAKE2b-256 60d8469c46fdadf3f66db202a1b2a5043078dbde9f7cca4a3dd10dd243af5ac9

See more details on using hashes here.

Provenance

The following attestation bundles were made for configuration_core-0.2.2-cp311-cp311-macosx_10_9_x86_64.whl:

Publisher: publish.yml on sreeyenan/configflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page