design_data_modellisted
Install: claude install-skill feralbureau/luminy
# design_data_model
Domain modeling is the act of translating business concepts into a structured representation in code. A good domain model makes the code read like the business; a bad one creates an impedance mismatch where understanding the code requires translating it back to business terms.
## Domain-Driven Design Vocabulary
### Entity
A thing that has identity and continuity. It's tracked through changes by its identity (usually an ID).
An entity is the same entity even if its attributes change — a `User` remains the same `User` even after changing their email address.
```python
@dataclass
class Order:
id: int # identity — this is what makes it an Order
user_id: int
status: OrderStatus
items: list[OrderItem]
total: Decimal
```
### Value Object
A thing defined entirely by its attributes. Two value objects with the same attributes are identical — they have no identity.
Prefer immutable value objects. Good candidates: Money, Address, DateRange, Coordinates, Email.
```python
@dataclass(frozen=True) # immutable — can't change an address, replace it
class Address:
street: str
city: str
country: str
postal_code: str
# Two addresses with same fields ARE the same — no ID needed
a1 = Address("Main St", "London", "UK", "SW1A 1AA")
a2 = Address("Main St", "London", "UK", "SW1A 1AA")
assert a1 == a2 # True
@dataclass(frozen=True)
class Money:
amount: Decimal
currency: str # "GBP", "USD", etc.
def __add