How pratikscfr/coldum works
1. Overall shape
- Coldum is a Python 3.12, HTTP-based Kafka-inspired log system. The runtime is a single broker process exposed through a versioned REST API under /v1, with a client SDK calling that API directly rather than using a Kafka wire protocol.
2. Broker entrypoint and API surface
- src/coldum/broker/app.py is the main broker application.
- The broker is split into route modules by concern: topics, produce, fetch, groups, cluster, health, metrics, and internal.
- This makes the API layer the top boundary: request/response schemas live alongside each router, while shared types sit in broker/schemas.py and broker/common.py.
3. Topic and partition storage
- The core persistence layer is in src/coldum/storage/.
- topic_store.py manages topic-level metadata and partition layout, while partition_log.py and record.py handle the append-only log and individual record encoding.
- Architecturally, this is the durable “data plane” for produced messages and fetched offsets.
4. Produce and fetch flow
- POST /v1/produce appends records into the partition log for a chosen topic/partition.
- POST /v1/fetch reads from partition logs using logical offsets and supports streaming-style consumption semantics, including long polling as covered by the tests.
- This is the main read/write path through the system: producer writes to storage, consumer fetches from storage.
5. Consumer group coordination
- src/coldum/broker/groups/ implements group membership, subscription, heartbeat, commit, assignment, and lag endpoints.
- The coordination flow is: consumers subscribe, send heartbeats to stay active, receive partition assignments, and commit offsets back to the broker.
- metadata/group_assignor.py is the likely placement for assignment logic that maps partitions to members.
6. Metadata and cluster state
- src/coldum/metadata/ holds persistent coordination state and cluster metadata.
- sqlite_store.py indicates SQLite-backed metadata persistence, so the broker keeps cluster/group state locally without an external coordination service.
- cluster.py and the broker’s /v1/cluster/metadata endpoint suggest a cluster view is exposed for node/leader awareness, even though the repo currently documents single-broker operation.
7. Broker service boundaries
- src/coldum/broker/services.py and workers.py likely provide the orchestration layer between HTTP handlers, storage, and metadata.
- This is the internal service boundary where cross-cutting broker logic lives: validating requests, coordinating storage writes, updating offsets, and running background work.
8. Client SDK
- src/coldum/client/ contains both sync and async producer/consumer wrappers.
- The async consumer exposes a streaming API that fetches assigned partitions concurrently and keeps membership alive with a background heartbeat task.
- This SDK is part of the architecture because it defines the intended client interaction pattern with the broker’s HTTP endpoints.
9. Operational endpoints
- health and metrics are separate broker subsystems, indicating explicit operational observability.
- internal suggests non-public admin or implementation endpoints that are separated from the public topic/produce/fetch/group API.
10. Reliability and semantics
- The README states at-least-once delivery, int64 logical offsets, and 7-day default retention.
- These guarantees are enforced by the storage/offset/commit model rather than by an external streaming platform.
- The architecture should therefore show commits and offsets as first-class coordination data, not just message metadata.
11. Deployment and local persistence
- The repo supports local containerized execution via Docker/devcontainer and uses COLDUM_DATA_DIR for broker data, which means the broker persists state to a local filesystem-backed data directory.
- docker-compose.yml, Dockerfile, and .devcontainer/ support reproducible local and test environments, but they do not change the core runtime architecture.
12. Validation and resilience tooling
- tests/integration/ covers end-to-end broker behavior, consumer groups, lag, and long polling; tests/unit/ covers lower-level storage and codec logic.
- scripts/fault_inject.py and scripts/load_test.py indicate the architecture is exercised for resilience and throughput, which is important when diagramming the system’s operational boundaries.
Main entry points: app.py Broker app · services.py Services · router.py Groups · sqlite_store.py SQLite store
Components 20
Broker API
HTTP broker entrypoint and route surface
- Broker app · Main broker process wiring the HTTP API
src/coldum/broker/app.py - Services · Cross-cutting broker logic between handlers, storage, and metadata
src/coldum/broker/services.py - Workers · Background tasks and periodic broker work
src/coldum/broker/workers.py - Topics · Topic metadata and partition layout endpoints
src/coldum/broker/topics/router.py - Produce · Append records into partition logs
src/coldum/broker/produce/router.py - Fetch · Read records by logical offset with long polling
src/coldum/broker/fetch/router.py - Groups · Membership, heartbeats, commits, assignment, and lag
src/coldum/broker/groups/router.py - Cluster · Cluster metadata and node/leader view
src/coldum/broker/cluster/router.py
Storage
Durable topic and partition log persistence
- Topic store · Topic metadata and partition layout persistence
src/coldum/storage/topic_store.py - Partition log · Durable per-partition record log
src/coldum/storage/partition_log.py - Record codec · Record serialization and logical offset encoding
src/coldum/storage/record.py
Metadata
Cluster and consumer-group coordination state
- SQLite store · Local persistent store for cluster and group state
src/coldum/metadata/sqlite_store.py - Assignor · Maps partitions to consumer-group members
src/coldum/metadata/group_assignor.py - Cluster state · Cluster and leader metadata
src/coldum/metadata/cluster.py
Client SDK
Sync and async HTTP client wrappers
- SDK · Sync and async producer/consumer wrappers
src/coldum/client - Async consumer · Concurrent fetch loop with background heartbeats
src/coldum/client/async_consumer.py - Async producer · Async publish wrapper over the HTTP API
src/coldum/client/async_producer.py
Connections 27
- Broker app → Topics: mounts · Registers topic routes under the versioned API
- Broker app → Produce: mounts · Registers produce routes
- Broker app → Fetch: mounts · Registers fetch routes
- Broker app → Groups: mounts · Registers consumer-group routes
- Broker app → Cluster: mounts · Registers cluster metadata routes
- Broker app → Health: mounts · Registers health checks
- Broker app → Metrics: mounts · Registers metrics endpoint
- Broker app → Internal: mounts · Registers internal endpoints
- Topics → Topic store: reads/writes · Manages topic and partition metadata
- Produce → Services: delegates · Validates requests and coordinates writes
- Fetch → Services: delegates · Coordinates reads and fetch semantics
- Groups → Services: delegates · Coordinates group membership and commits
- Services → Partition log: appends/reads · Main message data path through partition logs
- Services → Topic store: resolves · Looks up topics, partitions, and layouts
- Services → SQLite store: persists · Stores consumer-group and cluster coordination state
- Groups → Assignor: assigns · Computes partition ownership for members
- Cluster → Cluster state: exposes · Serves cluster and leader view
- Cluster state → SQLite store: loads/saves · Cluster metadata is persisted locally
- Assignor → SQLite store: uses · Reads group state needed for assignment
- Partition log → Record codec: encodes · Stores and decodes records with logical offsets
- SDK → Async consumer: includes · Async consumer is part of the SDK surface
- SDK → Async producer: includes · Async producer is part of the SDK surface
- Async producer → Produce: calls · Publishes records over HTTP
- Async consumer → Fetch: calls · Consumes records from fetch endpoints
- Async consumer → Groups: heartbeats/commits · Keeps membership active and commits offsets
- Workers → SQLite store: background sync · Runs recurring coordination or maintenance work
- Workers → Partition log: maintenance · May support retention or log-related background work