Capsule Core book
💊⚛️
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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cc_book_kit-0.9.0.tar.gz
(27.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cc_book_kit-0.9.0.tar.gz.
File metadata
- Download URL: cc_book_kit-0.9.0.tar.gz
- Upload date:
- Size: 27.9 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
829d36dbeb75395d777538ba60fec845fd64836641c1794a69bc3264b6d32514
|
|
| MD5 |
d3d60bbdf706850e6a8cbff8c4d41322
|
|
| BLAKE2b-256 |
c11d16a503ecc670b18aa7eca433869fb75dc95a9c360f4cf39b0dba2c458817
|
File details
Details for the file cc_book_kit-0.9.0-py3-none-any.whl.
File metadata
- Download URL: cc_book_kit-0.9.0-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7f39af0577fa83fcb8cf620919ce30fcb671f8b56e83bbab440c92a7f0990f0
|
|
| MD5 |
0b825af523c79f40f1ca6c14f78aa2b4
|
|
| BLAKE2b-256 |
ea6aa15cdbaa207e623985cdc516ec3ea87e8c4c897fe5afbdee9e157f40875b
|