The Config Secret 🎭¶

Plot Twist: Config is Just Flow!¶

class Config(Flow):
    """
    Surprise! Config is nothing more than a derived class of our underlying Flow class
    with a single `pass` statement. That's it. That's literally the entire implementation. 🤯
    """
    pass

Surprise! That’s it. That’s literally the entire Config implementation. Just a pass statement. 🤯

Config is a friendly alias for our underlying Flow state management engine. We’ve been playing the long game here - introducing vein to the world as a configuration management library, when it’s actually a full-featured state management system in disguise!

The Origin Story: From Pain to Revelation¶

  1. Born from Real Pain: This genuinely started as just a configuration management library. After manually writing the same boilerplate code over and over - fetching from AWS Secrets Manager, implementing caching, adding exponential backoff, redeploying entire Lambda functions just to change an environment variable - I had a thought: “What if I just had config.xyz where xyz is always lazy evaluated to an actual function which fetches the data?” And thus vein was born (originally called fastcfg!).

  2. The Accidental Discovery: As I built out features like live reloading, validation, and event handling, I had a startling realization - I wasn’t building a config library anymore. The abstraction I’d created was actually a full state management system! The patterns were identical to Redux, MobX, and Zustand, but for Python, with better performance, and with an API that felt natural.

  3. The Great Renaming: Once I saw what vein had become, I renamed Config to Flow throughout the entire codebase. But then I realized something beautiful - by keeping Config as an alias, users get the best of both worlds. They solve their immediate configuration needs without a huge learning curve (what the heck is “Flow”?!) while unknowingly adopting a state management system that can grow with them.

The Technical Reality¶

Under the hood, every Config instance is actually a full Flow object with all its power:

  • Real-time Updates: Changes propagate instantly across your application

  • Event System: React to state changes with callbacks

  • Validation: Built-in validation with custom policies

  • Nested State: Infinitely nestable state trees

  • Type Preservation: Values maintain their types transparently

  • Performance: Highly performant with live updates, unlike traditional static config libraries

By inheriting from Flow, Config gets all of this for free. The pass statement isn’t laziness - it’s elegance. Why reimplement what’s already perfect?

Backwards Compatibility Promise¶

Config will ALWAYS remain backwards compatible in future versions. As we unveil more of Flow’s capabilities and vein evolves into a general-purpose state management library, every line of code written with Config will continue to work exactly as expected.

This isn’t just a technical decision - it’s a trust contract with our users. You can adopt vein for configuration today and naturally grow into its full capabilities tomorrow.

The Journey Ahead¶

Today, you’re using Config for configuration management. Tomorrow, you might realize you’re already using a state management system that rivals Redux, MobX, or Zustand - but for Python, with excellent performance, and with an API so clean you didn’t even notice the power you were wielding.

Welcome to vein. Come for the configuration, stay for the Flow. 🩸⚡️

Example:
>>> from vein import Config
>>> # You think you're just doing configuration...
>>> config = Config()
>>> config.api_key = "secret"
>>> config.database.host = "localhost"
>>> # But you're actually using a full state management system!
>>> config.on_change("api_key", lambda e: print(f"API key changed!"))
>>> config.api_key = "new-secret"  # Triggers the callback
>>> # Config === Flow. It's that simple.
>>> isinstance(config, Flow)  # True