The only tool you need to know what is happening and how to fix it.
Go alertingexception-trackerissue-trackinglogsmetricsmonitoringobservability-platformopen-telemetryotelsession-replaytelemetrytraces
<mxfile host="app.diagrams.net" version="29.3.6">
<diagram name="Page-1" id="db-architecture-1">
<mxGraphModel dx="815" dy="558" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1500" pageHeight="1050" math="0" shadow="0" adaptiveColors="auto">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="consumers" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="<b>Controllers, services, workers</b><br><i>import the facade packages only: transactional.UserRepository, telemetry.SpanRepository, never a backend package directly</i>" vertex="1">
<mxGeometry height="70" width="1180" x="200" y="40" as="geometry" />
</mxCell>
<mxCell id="lmain" parent="1" style="swimlane;whiteSpace=wrap;html=1;collapsible=0;startSize=28;" value="Main DB: db.DB (relational / config)" vertex="1">
<mxGeometry height="330" width="600" x="80" y="170" as="geometry" />
</mxCell>
<mxCell id="lfac" parent="lmain" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;" value="<b>repositories/transactional facade</b><br><i>transactional_sqlite.go (default) | transactional_pg.go (-tags transactional_pg)</i>" vertex="1">
<mxGeometry height="60" width="560" x="20" y="40" as="geometry" />
</mxCell>
<mxCell id="lchar" parent="lmain" style="rounded=0;whiteSpace=wrap;html=1;fontSize=11;align=left;spacingLeft=8;spacingRight=8;" value="<b>Transactions required:</b> middleware.Transactional / db.ExecuteTransaction (*sql.Tx)<br><i>users, organizations, projects, invitations, widgets, metric_registry, notification config, personal_access_tokens, refresh_tokens, device_authorizations</i><br><i>pg/ and sqlite/ are dialect-neutral twins, parity_test.go enforces byte-for-byte equality</i>" vertex="1">
<mxGeometry height="105" width="560" x="20" y="115" as="geometry" />
</mxCell>
<mxCell id="limp1" parent="lmain" style="rounded=0;whiteSpace=wrap;html=1;" value="<b>sqlite/</b>" vertex="1">
<mxGeometry height="55" width="170" x="20" y="240" as="geometry" />
</mxCell>
<mxCell id="limp2" parent="lmain" style="rounded=0;whiteSpace=wrap;html=1;" value="<b>pg/</b>" vertex="1">
<mxGeometry height="55" width="170" x="210" y="240" as="geometry" />
</mxCell>
<mxCell id="limp3" parent="lmain" style="rounded=0;whiteSpace=wrap;html=1;fontSize=11;" value="<b>shared/</b><br><i>token hashing,<br>facade structs</i>" vertex="1">
<mxGeometry height="55" width="180" x="400" y="240" as="geometry" />
</mxCell>
<mxCell id="rtel" parent="1" style="swimlane;whiteSpace=wrap;html=1;collapsible=0;startSize=28;" value="Telemetry DB: db.TelemetryDB (append-only telemetry)" vertex="1">
<mxGeometry height="330" width="680" x="740" y="170" as="geometry" />
</mxCell>
<mxCell id="rfac" parent="rtel" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;" value="<b>repositories/telemetry facade</b><br><i>telemetry_sqlite.go (default) | telemetry_duckdb.go (-tags telemetry_duckdb) | telemetry_ch.go (-tags telemetry_ch)</i>" vertex="1">
<mxGeometry height="60" width="640" x="20" y="40" as="geometry" />
</mxCell>
<mxCell id="rchar" parent="rtel" style="rounded=0;whiteSpace=wrap;html=1;fontSize=11;align=left;spacingLeft=8;spacingRight=8;" value="<b>No transactions:</b> batch InsertAsync only (ClickHouse PrepareBatch / DuckDB Appender / direct lit inserts)<br><i>endpoints, tasks, ai_traces, spans, exception_stack_traces, metric_points, log_records, sessions, session_recordings, profiles, fired_notifications, archived_exceptions, slow_endpoints</i>" vertex="1">
<mxGeometry height="105" width="640" x="20" y="115" as="geometry" />
</mxCell>
<mxCell id="rimp1" parent="rtel" style="rounded=0;whiteSpace=wrap;html=1;" value="<b>sqlite/</b>" vertex="1">
<mxGeometry height="55" width="115" x="20" y="240" as="geometry" />
</mxCell>
<mxCell id="rimp2" parent="rtel" style="rounded=0;whiteSpace=wrap;html=1;" value="<b>duckdb/</b>" vertex="1">
<mxGeometry height="55" width="115" x="150" y="240" as="geometry" />
</mxCell>
<mxCell id="rimp3" parent="rtel" style="rounded=0;whiteSpace=wrap;html=1;" value="<b>clickhouse/</b>" vertex="1">
<mxGeometry height="55" width="120" x="280" y="240" as="geometry" />
</mxCell>
<mxCell id="rimp4" parent="rtel" style="rounded=0;whiteSpace=wrap;html=1;fontSize=10;" value="<b>sqlitetypes/</b><br><i>scan types for<br>sqlite + duckdb</i>" vertex="1">
<mxGeometry height="55" width="115" x="415" y="240" as="geometry" />
</mxCell>
<mxCell id="rimp5" parent="rtel" style="rounded=0;whiteSpace=wrap;html=1;fontSize=10;" value="<b>shared/</b><br><i>helpers for all<br>backends</i>" vertex="1">
<mxGeometry height="55" width="115" x="545" y="240" as="geometry" />
</mxCell>
<mxCell id="engsm" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="<b>SQLite (main)</b><br><i>SQLITE_PATH, default ./traceway.db<br>no credentials, single file</i>" vertex="1">
<mxGeometry height="90" width="280" x="80" y="560" as="geometry" />
</mxCell>
<mxCell id="engpg" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="<b>PostgreSQL (main)</b><br><i>POSTGRES_HOST / PORT / DATABASE /<br>USERNAME / PASSWORD / SSLMODE</i>" vertex="1">
<mxGeometry height="90" width="290" x="390" y="560" as="geometry" />
</mxCell>
<mxCell id="engst" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="<b>SQLite (telemetry)</b><br><i>traceway_telemetry.db,<br>derived from SQLITE_PATH</i>" vertex="1">
<mxGeometry height="90" width="215" x="740" y="560" as="geometry" />
</mxCell>
<mxCell id="engdd" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fontSize=11;" value="<b>DuckDB (telemetry)</b><br><i>traceway_telemetry.duckdb<br>DUCKDB_MEMORY_LIMIT / THREADS /<br>CHECKPOINT_THRESHOLD<br>CGO required, glibc only</i>" vertex="1">
<mxGeometry height="100" width="225" x="975" y="560" as="geometry" />
</mxCell>
<mxCell id="engch" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="<b>ClickHouse (telemetry)</b><br><i>CLICKHOUSE_SERVER / DATABASE /<br>USERNAME / PASSWORD / TLS</i>" vertex="1">
<mxGeometry height="90" width="200" x="1220" y="560" as="geometry" />
</mxCell>
<mxCell id="combos" parent="1" style="rounded=0;whiteSpace=wrap;html=1;align=left;spacingLeft=10;spacingRight=10;fontSize=11;" value="<b>Supported build combinations (2 build-tag axes: relational store + telemetry store)</b><br><br>1. <b>no tags</b>: SQLite + SQLite (zero-config self-hosted default)<br>2. <b>-tags telemetry_duckdb</b>: SQLite main + DuckDB telemetry (columnar reads, Dockerfile.duckdb, Debian image)<br>3. <b>-tags &quot;transactional_pg telemetry_ch&quot;</b>: PostgreSQL + ClickHouse (cloud / high volume)<br><br><i>Any other combination fails to compile: guard files in backend/app/db/ (guard_pg_without_ch.go, guard_ch_without_pg.go, guard_ch_and_duckdb.go, guard_stale_*.go)</i>" vertex="1">
<mxGeometry height="190" width="600" x="80" y="710" as="geometry" />
</mxCell>
<mxCell id="tree" parent="1" style="rounded=0;whiteSpace=wrap;html=1;align=left;spacingLeft=12;spacingRight=8;fontSize=11;fontFamily=Courier New;" value="<b>Folder structure: backend/app/</b><br><br>db/ &nbsp;.................. connections + build-tag guard files<br>migrations/<br>&nbsp;&nbsp;pg/ (transactional_pg) &nbsp;&nbsp;ch/ (telemetry_ch)<br>&nbsp;&nbsp;sqlite/ + sqlite_telemetry/ (default)<br>&nbsp;&nbsp;duckdb_telemetry/ (telemetry_duckdb)<br>repositories/<br>&nbsp;&nbsp;transactional/ ..... facade: transactional_{sqlite,pg}.go<br>&nbsp;&nbsp;&nbsp;&nbsp;pg/ &nbsp;sqlite/ &nbsp;shared/<br>&nbsp;&nbsp;telemetry/ ......... facade: telemetry_{sqlite,duckdb,ch}.go<br>&nbsp;&nbsp;&nbsp;&nbsp;clickhouse/ &nbsp;duckdb/ &nbsp;sqlite/ &nbsp;shared/ &nbsp;sqlitetypes/" vertex="1">
<mxGeometry height="230" width="680" x="740" y="710" as="geometry" />
</mxCell>
<mxCell id="ec1" edge="1" parent="1" source="consumers" target="lfac" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0.25;exitY=1;exitDx=0;exitDy=0;entryX=0.15;entryY=0;entryDx=0;entryDy=0;">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="ec1l" connectable="0" parent="ec1" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" value="transactions (*sql.Tx)" vertex="1">
<mxGeometry relative="1" x="0" y="0" as="geometry">
<mxPoint x="-75" y="0" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="ec2" edge="1" parent="1" source="consumers" target="rfac" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0.75;exitY=1;exitDx=0;exitDy=0;entryX=0.85;entryY=0;entryDx=0;entryDy=0;">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="ec2l" connectable="0" parent="ec2" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" value="batch InsertAsync + reads" vertex="1">
<mxGeometry relative="1" x="0" y="0" as="geometry">
<mxPoint x="85" y="0" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="ee1" edge="1" parent="1" source="limp1" target="engsm" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="ee2" edge="1" parent="1" source="limp2" target="engpg" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="ee3" edge="1" parent="1" source="rimp1" target="engst" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="ee4" edge="1" parent="1" source="rimp2" target="engdd" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.4;entryY=0;entryDx=0;entryDy=0;">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="947" y="520" />
<mxPoint x="1065" y="520" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="ee5" edge="1" parent="1" source="rimp3" target="engch" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="1080" y="535" />
<mxPoint x="1320" y="535" />
</Array>
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>