Entry

Core data structure for content management and metadata tracking.

Overview

The Entry class is a frozen dataclass designed to represent a single unit of information. It uses kw_only=True to enforce explicit naming of arguments during instantiation, ensuring code clarity and preventing positional argument errors.

@dataclass(kw_only=True, frozen=True)

Attributes

Attribute Type Default
content str Required
title Optional[str] None
tags List[str] []
category Optional[str] None
id str UUID4 String
created_at datetime now()
metadata Dict[str, Any] {}

Implementation Details

Immutability

The class is frozen. Once an instance is created, its fields cannot be modified. This makes the objects hashable and safe for use in multi-threaded environments or as dictionary keys.

Unique Identification

Each entry is automatically assigned a unique uuid4 identifier upon creation, ensuring no collisions when syncing across different databases or systems.

Flexible Metadata

The metadata field allows for total flexibility, enabling the storage of domain-specific information without modifying the core schema.

Usage Example

new_entry = Entry(
    content="Hello World",
    title="Greeting",
    tags=["intro", "test"],
    metadata={"author_id": 42}
)