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.3.tar.gz (42.2 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.3-cp311-cp311-win_amd64.whl (351.1 kB view details)

Uploaded CPython 3.11Windows x86-64

configuration_core-0.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

configuration_core-0.2.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (2.3 MB view details)

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

configuration_core-0.2.3-cp311-cp311-macosx_11_0_arm64.whl (398.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

configuration_core-0.2.3-cp311-cp311-macosx_10_9_x86_64.whl (412.6 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: configuration_core-0.2.3.tar.gz
  • Upload date:
  • Size: 42.2 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.3.tar.gz
Algorithm Hash digest
SHA256 9c1d4ed18a94f6595a93bcd5608794232bdfc26a5ae640f3d974fe2dfb6b3ef9
MD5 8aa8c71d5dee7d32fb34b953ef51b41a
BLAKE2b-256 c8459463089b28a79fae5e811d3f9859c09d0c2e324b0a2920e7ca172447e6aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for configuration_core-0.2.3.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.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for configuration_core-0.2.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4d250d51e062eb35d7246c4a2c69bc2f443147d1afab3d4ef6c18fe496b7dae4
MD5 e678329c1062d9935344f0a63164375f
BLAKE2b-256 fa015460c9a88f9d81b5ae1dfea68b38a8eb1cd88c2489157c44f868d17591b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for configuration_core-0.2.3-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.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for configuration_core-0.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 52ff71a0f863090bfbe1d087f054c55ef7ab1d6525f280157b83621dd3cb33d0
MD5 76996a8a307ed0022b9178620722f0be
BLAKE2b-256 704ec073ea66d4f9437f42010a401537de08a2e0febc6d52b1c4858124d6d20e

See more details on using hashes here.

Provenance

The following attestation bundles were made for configuration_core-0.2.3-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.3-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.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 9f85eb446d82100c50c52bf34b0ff4cf38d26c50854da5d78239e52de57fcfda
MD5 38889b4d889d4244bdf24a5afa379564
BLAKE2b-256 287d286c692ad576655c518c6b1b7c18cd385d1b1c962442de36a5c3a81490de

See more details on using hashes here.

Provenance

The following attestation bundles were made for configuration_core-0.2.3-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.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for configuration_core-0.2.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0da69a75b640688287862710caedb918d2b60cc2c7a0ab71d968193c99724b9b
MD5 d747b5f90a39f4d0aa9e0be5dec1287e
BLAKE2b-256 78e53c609bee11374043c3c2060e7354ec7312df647d684e8a392c49009e87cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for configuration_core-0.2.3-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.3-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for configuration_core-0.2.3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1829ec3b7bce1fbf8619f151300ab52f778cd23109abf0834c84c038fd04a4d1
MD5 ca508bf844d643c46532d88be855744e
BLAKE2b-256 6366d6c12ba27d4cb8bb5a0bf85851945f373762862ca5e627523c5348215e22

See more details on using hashes here.

Provenance

The following attestation bundles were made for configuration_core-0.2.3-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