NotiFi
NotiFi is a multi-tenant platform for resource-based, traceable communication. The first product, Visitor Incident Management, manages visitor presence and SMS-based emergency dispatches.
Current status
Section titled “Current status”Foundation and architecture decisions. No production service is deployed.
Repository structure
Section titled “Repository structure”docs/architecture.md— boundaries between product, Core and channels.docs/core/— developer guide, implemented interfaces and proposed designs.docs/visitor-incident-drafts.md— current Visitor draft backend contract.docs/adr/— short, immutable architectural decision records.- Future application code will live in
apps/and deployment material ininfra/.
Working agreement
Section titled “Working agreement”mainmust always be understandable and runnable.- No secrets, credentials, exports or production data are committed.
- Deployments are manual and documented initially; CI/CD will be added once the delivery path is stable enough to automate.
Local development
Section titled “Local development”- Copy
.env.exampleto.envand replace the development database password. - Set distinct random hexadecimal passwords for both
NOTIFI_APP_PASSWORDandNOTIFI_MIGRATOR_PASSWORDin.env(for example, generate each withopenssl rand -hex 32). - Run the database setup below, then
docker compose up --build. - Visit
http://127.0.0.1:3001/upfor the Rails health endpoint.
PostgreSQL and Redis are internal Docker services and have no host ports. The
web process is bound to loopback only; it is not publicly reachable. Stop the
local stack with docker compose down. Use docker compose down -v only when
you intentionally want to discard local NotiFi database and Redis data.
The development css service rebuilds Tailwind when source files change. The
fictional design preview at /design-preview is available without signing in
only in development; it does not expose product data.
Database setup, for a new installation or the existing development database:
docker compose up -d postgresset -a; . ./.env; set +adocker compose exec -T -e NOTIFI_APP_PASSWORD -e NOTIFI_MIGRATOR_PASSWORD postgres \ sh -c 'psql -X -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB" -v app_password="$NOTIFI_APP_PASSWORD" -v migrator_password="$NOTIFI_MIGRATOR_PASSWORD"' \ < infra/docker/postgres/provision.sql./bin/dev-migrateRun ./bin/dev-migrate whenever the development schema changes. It uses the
migration role and restarts any running web and worker processes, including
after a failed migration, so they do not retain an outdated schema cache. It
does not start services that were stopped. The web and worker services connect
as notifi_app, not as the migration role. This command is for the local
development Compose stack, not production or test databases.
To verify RLS on an initialized database, run:
docker compose exec -T postgres sh -c 'psql -X -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB"' < infra/docker/postgres/verify_rls.sqldocker compose run --rm --no-deps web bin/rails runner script/verify_tenant_context.rbThe verification uses a transaction that is rolled back. RLS is a database boundary; authentication and tenant authorization still need implementation before tenant data can be exposed to users.
Provisioning reserves the notifi_dispatch schema for future frozen dispatch
data. It preserves current application grants on public, but does not grant
app writes or sequence access in the reserved schema; rerunning provisioning
revokes those direct grants and rejects unsafe effective or default privileges.
It does not create dispatch tables or enable delivery. Run
tests/dispatch_schema_privileges_test.sh to exercise provisioning in an
isolated disposable PostgreSQL container. SQL schema restore for the reserved schema runs atomically and leaves routine
execution fail-closed; tests/dispatch_schema_roundtrip_test.sh verifies it.
Before adding dispatch functions, design explicit grant reconciliation after
restore, migration ownership and retention access. Provisioning revokes default
PUBLIC EXECUTE for new functions created by notifi_migrator in all schemas;
future callable functions require explicit reviewed grants. Provisioning only protects the
reserved schema; it does not make arbitrary SQL under the app role tenant-safe.
Rails tests require TEST_DATABASE_URL pointing to a dedicated database whose
name ends in _test. Prepare its schema with the migration role and give the
runtime role access to the application tables, sequences and Rails metadata before
running the tests as the runtime role. Never point this variable at development
or production data.
To check the development migration wrapper without changing a database, run
tests/dev_migrate_test.sh.
The inactive development discovery role is provisioned separately as a PostgreSQL administrator, then verified with:
docker compose exec -T postgres sh -c 'psql -X -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB"' < infra/docker/postgres/provision_discovery_role.sqldocker compose exec -T postgres sh -c 'psql -X -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB"' < infra/docker/postgres/verify_discovery_role.sqlThis NOLOGIN role has no application table access and is not assigned to any
worker. See docs/core/tenant-work-discovery-design.md before enabling any
future discovery capability.