FlowODM Documentation
FlowODM is a lightweight ODM (Object-Document Mapper) for Apache Kafka with Avro schema support. It provides a Pydantic-based interface for working with Kafka messages and Avro schemas.
Note
Apache Kafka is a registered trademark of the Apache Software Foundation.
Features
Pydantic v2 Integration: Define message models with full type safety and validation
Sync and Async Support: Both synchronous and asynchronous APIs for produce/consume
Schema Registry Integration: Automatic schema registration and validation
Consumer Loop Patterns: Ready-to-use patterns for building Kafka microservices
Predefined Settings Profiles: Optimized configurations for different use cases
Quick Example
from datetime import datetime
from flowodm import FlowBaseModel, connect
# Connect to Kafka
connect(
bootstrap_servers="localhost:9092",
schema_registry_url="http://localhost:8081"
)
# Define a model
class UserEvent(FlowBaseModel):
class Settings:
topic = "user-events"
consumer_group = "my-service"
user_id: str
action: str
timestamp: datetime
# Produce messages
event = UserEvent(user_id="123", action="login", timestamp=datetime.now())
event.produce()
# Consume messages
for event in UserEvent.consume_iter():
print(f"User {event.user_id} performed {event.action}")
Contents
User Guide
API Reference
Project Info