Skip to content

Models

Core domain models for the Imbi ecosystem.

Overview

The models module provides Pydantic models for all core domain entities (projects, organizations, teams) and the blueprint system for dynamic schema extension.

Model Categories

Domain Models

  • Organization: Top-level organizational units
  • Team: Groups within organizations
  • Environment: Deployment environments (production, staging, etc.)
  • ProjectType: Project categorization and templates
  • Project: Services and applications

Blueprint Models

  • Blueprint: Dynamic schema definitions
  • BlueprintAssignment: Blueprint-to-entity relationships

Basic Usage

from imbi_common import models, neo4j

# Create an organization
org = models.Organization(
    name="My Company",
    slug="my-company",
    description="Our organization"
)
await neo4j.create_node(org)

# Create a team linked to an organization
team = models.Team(
    name="Platform Team",
    slug="platform-team",
    description="Infrastructure and platform",
    organization=org
)
await neo4j.create_node(team)

API Reference

Base Classes

Node

Bases: BaseModel

Base model for Cypherantic nodes.

The icon attribute can either be a URL or a CSS class name

Domain Models

Organization

Bases: Node

Team

Bases: Node

Environment

Bases: Node

ProjectType

Bases: Node

Project

Bases: Node

Blueprint Models

Blueprint

Bases: BaseModel

generate_and_validate_slug

generate_and_validate_slug() -> typing.Self

Generate slug from name if not provided and validate it.

Source code in src/imbi_common/models.py
@pydantic.model_validator(mode='after')
def generate_and_validate_slug(self) -> typing.Self:
    """Generate slug from name if not provided and validate it."""
    if self.slug is None:
        self.slug = slugify.slugify(self.name)
    else:
        self.slug = self.slug.lower()

    # Validate slug format
    if not self.slug:
        raise ValueError('Slug cannot be empty')
    if not all(c.islower() or c.isdigit() or c == '-' for c in self.slug):
        raise ValueError(
            'Slug must contain only lowercase letters, '
            'numbers, and hyphens'
        )
    return self

BlueprintAssignment

Bases: BaseModel

BlueprintEdge

Bases: NamedTuple