Skip to main content

A composable dependency container with passive UI and service facets.

Project description

facetkit

A composable Python container for application state and passive registries — CLI commands, TUI screens, GUI widgets, web routes, and background services.

facetkit separates three pieces:

Piece Role
Container Application root — config, facet & component binding
Facet Passive registry for a surface area (commands, routes, widgets, …)
Component Plugin that connects to one or several facets in on_bind and cleans up in on_unbind
Container
├── config
├── components
└── facets
    ├── cli      → commands
    ├── tui      → screens, keybindings
    ├── gui      → widgets, menus, toolbars, layouts
    ├── web      → routes, middleware, error handlers
    └── service  → tasks, providers

Requirements

Installation

pip install facetkit

For local development:

git clone https://github.com/Dev-DanielR/py_facetkit.git
cd facetkit
pip install -e ".[dev]"

Quick start

from facetkit import Container, CliFacet, WebFacet

app = Container({"app": {"name": "demo"}})

app.bind_facet("cli", CliFacet())
app.bind_facet("web", WebFacet())

def hello():
    """Say hello."""
    return "Hello!"

app.facets["cli"].add_command("hello", hello)
app.facets["web"].add_route("hello", "/hello", lambda: {"message": "Hello!"}, methods=["GET"])

Register directly on facets (as above) or through components. Your dispatch layer reads the registries and wires them to argparse, FastAPI, Textual, Qt, or whatever you use.

Documentation

  • Container — config, lifecycle, introspection
  • Facets — facet types, registries, binding
  • Components — on_bind/on_unbind, dependencies
  • Examples — composed app with logger and status components

Development

pip install -e ".[dev]"
pytest

See CHANGELOG.md for release notes. Pre-1.0 (0.4.0) — public APIs may change between minor releases.

License

MIT — see LICENSE.

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

facetkit-0.4.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

facetkit-0.4.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file facetkit-0.4.0.tar.gz.

File metadata

  • Download URL: facetkit-0.4.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for facetkit-0.4.0.tar.gz
Algorithm Hash digest
SHA256 2101791aa38900a26daec6b3a40c18ac3d65cc72c939000d002bc9fe8c6815a2
MD5 c1822f32ffe85fdacfea3483b8a44ed3
BLAKE2b-256 41e73851158c07599fb7d5a7743fd765bf2390299eab7b9c3083ce7373a5e4ff

See more details on using hashes here.

File details

Details for the file facetkit-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: facetkit-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for facetkit-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 554c0d7dc76b94b37bc3b9d54886d97e27f49bda3c3af5b5e23a178256f75517
MD5 9fc5e9cb4e85e24d1cd7dedac52899f4
BLAKE2b-256 ffdc17120969a3b51c2f25848d5a4d812eff6be26f344cab37309e924741fbf6

See more details on using hashes here.

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