Skip to main content

Capsule Core book

License: MIT Version CI CD Python Version Download docs Ask DeepWiki PyPI

💊⚛️


Installation

Ensure you have your environment ready (recommended to use uv or pip):

pip install capsulecore-book

Usage

Here is a simple example using the standard JSONLexicon.

from cc_book_kit.capsule import JSONLexicon, 
from cc_book_kit.core import Codex, CodexPolicy

# 1. Initialize the storage (Lexicon)
repository = JSONLexicon(storage_path="my_knowledge_base.json")

# 2. Define your business policies
policy = CodexPolicy(
    title_unique=True,
    tags_lowercase=True,
    category_required=True
)

# 3. Create the Codex engine
codex = Codex(repository=repository, policy=policy)

# 4. Create entries
entry_a = codex.create_entry(
    title="Python Programming",
    content="A high-level programming language.",
    tags=["coding", "backend"],
    category="Technology"
)

entry_b = codex.create_entry(
    title="Knowledge Graphs",
    content="A way to represent interconnected data.",
    tags=["data", "graph"],
    category="Science"
)

# 5. Create a relation between them
relation = codex.create_relation(
    from_id=entry_a.id,
    to_id=entry_b.id,
    connection_type="related_to"
)

print(f"Created entry: {entry_a.title} with ID: {entry_a.id}")

Choosing a Lexicon

Depending on your performance needs, you can swap the storage engine easily:

Lexicon Best For...
JSONLexicon Portability and no extra dependencies.
UJSONLexicon Faster serialization than standard json.
ORJSONLexicon Maximum performance, native Datetime/UUID support.
PydanticLexicon Strict data validation and schema integrity.

Customizing Policies

You can adjust how the Codex behaves by modifying the CodexPolicy:

custom_policy = CodexPolicy(
    title_max_length=50,
    category_default="Uncategorized",
    tags_sort=True
)
codex = Codex(repository=repository, policy=custom_policy)

Key Features

  • Hexagonal Architecture: Decouples core logic from storage implementation.
  • Graph Structure: Manage data as a network of entries and connections.
  • Multiple Lexicons: Out-of-the-box support for standard JSON, ujson, orjson, and Pydantic validation.
  • Policy-Driven: Configurable rules for title uniqueness, tag formatting, and category management.

Metadata

Release files for cc.book-kit 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cc.book-kit 0.9.0
File Size Uploaded
cc_book_kit-0.9.0.tar.gz 27.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cc.book-kit 0.9.0
File Interpreter ABI Platform
cc_book_kit-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 46.5 kB

Release files / cc_book_kit-0.9.0.tar.gz

Download URL cc_book_kit-0.9.0.tar.gz
Size 27.9 kB
Tags Source
SHA-256 checksum
How to use checksums
829d36dbeb75395d777538ba60fec845fd64836641c1794a69bc3264b6d32514
BLAKE2b-256 checksum
How to use checksums
c11d16a503ecc670b18aa7eca433869fb75dc95a9c360f4cf39b0dba2c458817
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / cc_book_kit-0.9.0-py3-none-any.whl

Download URL cc_book_kit-0.9.0-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7f39af0577fa83fcb8cf620919ce30fcb671f8b56e83bbab440c92a7f0990f0
BLAKE2b-256 checksum
How to use checksums
ea6aa15cdbaa207e623985cdc516ec3ea87e8c4c897fe5afbdee9e157f40875b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.8.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page