How dan-sones/prism works
1. This repository is a monorepo for an experimentation platform, not a single app. The core domain is feature/experiment management, event ingestion, assignment/bucketing, statistics, and analytics storage. The main runtime boundaries are Go microservices, one Java ingestion service, one Python stats service, React-based admin UIs, and shared protocol/model libraries.
2. The primary backend control plane is services/experimentation-service. It exposes HTTP APIs and gRPC servers for experiments, events catalog, metrics catalog, assignment-related operations, and experiment results. It is the central orchestrator that persists domain state in Postgres, queries analytics data from ClickHouse, and calls the stats engine for sample-size and test-result calculations.
3. services/assignment-service is the assignment/bucketing service. It owns the logic for selecting variants, caching experiment state in Redis, and reacting to cache invalidation. It also listens to Kafka and serves gRPC/HTTP endpoints so other services and SDK-facing clients can resolve assignments quickly without hitting the main experimentation database on every request.
4. services/events-service is the ingestion entry point for downstream business events. It is a Java Spring Boot service that validates event requests against the events catalog, publishes normalized events to Kafka, and uses cached catalog data plus gRPC lookups where needed. This service is the front door for event collection from applications.
5. services/clickhouse-writer is the streaming sink for analytics. It consumes Kafka events in microbatches and writes them into ClickHouse. This is the main path from raw event traffic into the analytical store used for reporting and experiment analysis.
6. services/data-cooking-service sits between raw assignment/event data and analysis-ready data. It consumes Kafka and reads from assignment/external services and ClickHouse to “cook” experiment data into a richer shape for downstream use. Its role is to enrich and reconcile data rather than to be the system of record.
7. services/stats-engine is a separate Python gRPC service for statistics. It implements sample-size calculations, z-tests, and decision logic. experimentation-service invokes it through generated gRPC clients, so statistical computation is isolated from business CRUD and API concerns.
8. The frontend/admin boundary is services/experimentation-portal. It is a Vite/React application that drives experiment, metrics, and events catalog workflows. Its API layer mirrors the backend service capabilities, and the UI is organized around routes for home, experiments, metrics catalog, and events catalog.
9. openfeature-provider-react and examples/powell-motors form the client-side runtime integration story. The provider package exposes a Prism web provider for OpenFeature-style flag/experiment resolution, and the example site demonstrates how a product frontend consumes it.
10. Shared contracts are a major architectural boundary. Protobuf definitions live in services/protos, and generated gRPC code is checked into each service. Shared Go libraries in libs/ cover DB/domain models, logging, and microbatching so that services can share consistent schemas and ingestion patterns without coupling their business logic.
11. Infrastructure is first-class in infrastructure/. Docker Compose defines local dev/test topology, Postgres migrations define the experiment catalog and assignment schemas, ClickHouse migrations define analytics storage, Kafka bootstrap scripts wire the event bus, and Terraform provisions the VM-based deployment environment. This repo is therefore built around a distributed data pipeline with transactional state in Postgres and analytical state in ClickHouse.
12. The docs site under docs/ is part of the product architecture, not just documentation. It contains OpenAPI and service reference material for the assignment and experimentation services, which reflects the public API boundaries and helps keep the service contracts explicit.
13. The main end-to-end data flow is: client/UI or SDK calls assignment/experimentation APIs → assignment is resolved and/or experiment state is updated → events are ingested through events-service → Kafka fans out to ClickHouse writer and cooking/analysis services → experimentation-service reads results and asks stats-engine for calculations → portal renders experiment health and outcomes from those APIs.
14. The repository also includes simulation and load-testing tooling. tools/experiment-simulator generates synthetic experiments/events and can push cache invalidations, while tools/gatling-load-testing and tools/bucket-finder support stress testing and assignment verification. These tools are important because they exercise the same service boundaries as production traffic.
Main entry points: assignment-service Assignment service · experimentation-service Experimentation service · infrastructure Infrastructure · clickhouse-writer ClickHouse writer
Components 19
Core services
Primary backend runtime boundaries for experimentation, assignment, ingestion, and analytics.
- Experimentation service · Central API and orchestration service for experiments, events catalog, metrics catalog, results, and assignment-related operations.
services/experimentation-service - Assignment service · Low-latency assignment resolution service with Redis-backed experiment cache and Kafka-driven invalidation.
services/assignment-service - Events service · Spring Boot entry point for validating, normalizing, and publishing business events to Kafka.
services/events-service - ClickHouse writer · Consumes Kafka microbatches and persists analytics events into ClickHouse.
services/clickhouse-writer - Data cooking · Reconciles assignment and event data into analysis-ready cooked records for downstream use.
services/data-cooking-service - Stats engine · Isolated statistics service for sample-size, z-test, and decision calculations.
services/stats-engine
Client apps
Admin UI and frontend integration packages.
- Experimentation portal · Vite/React application for managing experiments, metrics, and events catalog workflows.
services/experimentation-portal - OpenFeature provider · Prism web provider package for client-side feature and experiment resolution.
openfeature-provider-react - Example site · Sample product frontend demonstrating provider integration and experiment-driven UI behavior.
examples/powell-motors/powell-motors-website
Shared platform
Protocol definitions, reusable libraries, docs, and infrastructure.
- Protos · Shared protobuf definitions for assignment, events catalog, experimentation, and stats engine APIs.
services/protos - DB models · Shared domain and persistence models reused across services for experiments, events, and metrics.
libs/prismdbmodels - Logger · Shared logging helper used by Go services and tools.
libs/prismlogger - Microbatcher · Reusable microbatch processing primitives for Kafka-to-storage pipelines.
libs/prismmicrobatcher - Docs site · Documentation and OpenAPI reference for the public service boundaries.
docs - Infrastructure · Local and deployment infrastructure: Docker Compose, migrations, Kafka bootstrap, and Terraform.
infrastructure - Kafka bus · Event backbone used for ingestion, assignment invalidation, and analytics fan-out.
infrastructure/kafka
Tools
Simulation and load-testing utilities.
- Simulator · Generates synthetic experiments, events, and cache invalidations against service boundaries.
tools/experiment-simulator - Gatling tests · Load-testing harness for assignment and ingestion paths.
tools/gatling-load-testing - Bucket finder · Assignment verification utility that exercises the assignment service.
tools/bucket-finder
Connections 31
- Experimentation portal → Experimentation service: CRUD + results · Admin UI drives experiment, metrics, and events workflows through the control plane.
- Experimentation portal → Assignment service: resolve assignment · Portal-related flows depend on assignment resolution and bucket state.
- OpenFeature provider → Assignment service: flag resolution · Client-side provider resolves experiments and variants through assignment APIs.
- Example site → OpenFeature provider: uses provider · Example app demonstrates integration with the OpenFeature provider package.
- Experimentation service → Stats engine: grpc stats · Control plane delegates sample-size and decision calculations to the stats service.
- Experimentation service → ClickHouse writer: analytics queries · Reads analytical data from ClickHouse-backed storage for reporting and results.
- Events service → Protos: catalog contract · Uses shared events catalog gRPC definitions and generated code.
- Events service → Experimentation service: grpc lookups · Queries catalog and related domain data when validating inbound events.
- Events service → Kafka bus: publish events · Normalizes requests and pushes downstream events onto Kafka.
- Assignment service → Protos: assignment contract · Implements shared assignment gRPC/HTTP contract.
- Assignment service → Kafka bus: invalidate cache · Consumes invalidation and coordination messages from the event bus.
- ClickHouse writer → Kafka bus: consume stream · Consumes event traffic from Kafka microbatches.
- ClickHouse writer → Infrastructure: clickhouse schema · Writes into ClickHouse storage defined by repo migrations and config.
- Data cooking → Assignment service: assignment lookup · Reconciles and enriches event data with assignment state.
- Data cooking → Experimentation service: experiment lookup · Pulls experiment metadata and related domain state.
- Data cooking → ClickHouse writer: analysis input · Reads analytical event data as part of cooking and enrichment flows.
- Data cooking → Kafka bus: consume stream · Processes stream inputs from Kafka.
- Experimentation service → DB models: domain models · Shares experiment, metric, and event domain structures.
- Assignment service → DB models: domain models · Reuses assignment and experiment cache models.
- ClickHouse writer → Microbatcher: batching · Uses shared microbatching primitives for Kafka ingestion.
- Simulator → Assignment service: simulate assignment · Exercises assignment resolution and invalidation flows.
- Simulator → Events service: simulate events · Generates synthetic event traffic for ingestion paths.
- Gatling tests → Events service: load test · Stress tests the event ingestion boundary.
- Bucket finder → Assignment service: verify buckets · Checks assignment distribution and bucketing behavior.
- Docs site → Experimentation service: api docs · Documents the experimentation service HTTP/OpenAPI boundary.
- Docs site → Assignment service: api docs · Documents the assignment service contract.
- Infrastructure → Experimentation service: deploy/runtime · Defines service deployment, databases, and local topology.
- Infrastructure → Assignment service: deploy/runtime · Defines service deployment, cache, and message-bus topology.
- Infrastructure → Events service: deploy/runtime · Defines service deployment and supporting infrastructure.
- Infrastructure → ClickHouse writer: deploy/runtime · Defines analytics storage and stream-processing infrastructure.
- Infrastructure → Kafka bus: bootstrap · Creates and configures the shared stream backbone.