Datastores

Smartizy keeps analytics data in ClickHouse and configuration in PostgreSQL. Both run as their own Compose stacks and bootstrap on first start, so once they are up the app stacks fill in the rest.

Bring these two up before the ingest receiver and admin console. They are intentionally minimal: each boots one server, creates one database, and does nothing else.

ClickHouse #

The docker/clickhouse stack runs the official ClickHouse server. On the first start, and only the first while the data volume is still empty, it runs the repo-root rum_schema.sql mounted into the entrypoint init directory. That bootstrap creates the rum database, the wide events table, and the rollup materialized views the dashboards read.

docker/clickhouse/.env bash
# docker/clickhouse/.env
CLICKHOUSE_IMAGE_TAG=25.3
CLICKHOUSE_HTTP_PORT=8123       # the port the ingest receiver connects to
CLICKHOUSE_NATIVE_PORT=9000     # clickhouse-client and BI tools
CLICKHOUSE_DB=rum
CLICKHOUSE_USER=ambilobe
CLICKHOUSE_PASSWORD=CHANGEME    # required, compose aborts if unset

PostgreSQL #

The docker/pg stack runs the official PostgreSQL server. On the first start it runs initdb and creates an empty rum_config database and the ambilobe role. That is all it does. Unlike ClickHouse, there is no schema file to mount.

The rum_config schema is owned by EF Core migrations. The ingest receiver and the admin console apply every pending migration to this database on their own startup (RumConfigDbMigrator), so the first app deploy fills in the tables. See Configuration for the AutoMigrate flags that control this.

docker/pg/.env bash
# docker/pg/.env
POSTGRES_IMAGE_TAG=17
POSTGRES_PORT=5432
POSTGRES_DB=rum_config
POSTGRES_USER=ambilobe
POSTGRES_PASSWORD=CHANGEME      # required, compose aborts if unset

Local development defaults #

Local development expects each datastore at its default port and database:

  • ClickHouse on the HTTP port 8123, database rum.
  • PostgreSQL on port 5432, database rum_config.

Both are configurable through the connection strings the app stacks read. The ingest receiver and admin console reach the datastores by service name on the shared ambilobe network, hosts clickhouse and postgres.

Keep credentials in sync #

The database, user, and password set on each datastore must match the connection strings the app stacks use. Keep CLICKHOUSE_DB / CLICKHOUSE_USER / CLICKHOUSE_PASSWORD in line with the ingest receiver's INGEST_CLICKHOUSE_CONNECTIONSTRING, and POSTGRES_DB / POSTGRES_USER / POSTGRES_PASSWORD in line with both INGEST_CONFIGDB_CONNECTIONSTRING and ADMIN_CONFIGDB_CONNECTIONSTRING.