arborist-viz/arborist_viz/models/__init__.py
russell@unturf.com 0cd96ab1d7
Initial commit: arborist VIZ — Merkle command center
Pyramid web app for inspecting arborist Merkle trees over sharded SQLite:
document roots, inclusion proofs, an interactive 3D Merkle lattice
(six.js / WebGL with graceful fallback), audit-chain linkage, and a live
SSE event stream.

Generated artifacts (env/, vendored static/six/ bundles, demo databases)
are gitignored and rebuilt via the Makefile (venv, six, init-db, serve).
2026-05-28 09:22:59 -04:00

42 lines
1.4 KiB
Python

"""SQLAlchemy models for the dashboard metadata DB.
This DB carries **only** dashboard-layer state — saved layouts, filter
presets, user prefs. arborist provenance shards stay the source of
truth and are imported read-only via ``arborist.embed`` (no SQLAlchemy
session over arborist tables, per ticket §3-corrected).
"""
from __future__ import annotations
from sqlalchemy import JSON, Column, DateTime, Integer, String, Text
from sqlalchemy.orm import declarative_base, sessionmaker
from sqlalchemy.sql import func
Base = declarative_base()
class Dashboard(Base):
__tablename__ = "dashboards"
id = Column(String(64), primary_key=True)
title = Column(String(256), nullable=False)
description = Column(Text, nullable=True)
version = Column(String(32), nullable=False, default="dashboard-v1")
config_json = Column(JSON, nullable=False)
created_at = Column(DateTime, server_default=func.now())
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
class FilterPreset(Base):
__tablename__ = "filter_presets"
id = Column(Integer, primary_key=True, autoincrement=True)
dashboard_id = Column(String(64), nullable=False, index=True)
name = Column(String(128), nullable=False)
filter_json = Column(JSON, nullable=False)
created_at = Column(DateTime, server_default=func.now())
def make_session_factory(engine) -> sessionmaker:
return sessionmaker(bind=engine, expire_on_commit=False)