# lag-and-adoption: Replication Freshness & Feature-Adoption Dashboard

## PURPOSE
Two of the most quotable facts in this interview are numbers. First: Artie keeps
Postgres-to-warehouse replication at "sub-minute" freshness, and "if data is late,
it's simply just wrong." Second: the history-table feature shipped against every
customer's advice, and "six months later, 40% of our customers turned it on."
`lag-and-adoption` is a Streamlit + Plotly dashboard that plots both on one screen:
replication lag against the sub-minute SLO band, and the slow adoption curve of a
feature customers initially rejected.

## WHY THIS MATTERS
These two charts teach the video's two central lessons visually. The lag chart shows
why real-time streaming systems are "unforgiving" — how a single breach window breaks
fraud detection or an AI agent's context. The adoption chart shows the flip side of
"talk to your customers": conviction can be right even when feedback is silent, but
you only learn that by measuring usage after launch.

## HOW TO BUILD
1. Generate two deterministic datasets with Pandas: a time series of per-table lag
   samples (with one injected breach window) and a 180-day feature-adoption series
   climbing to 40%.
2. Draw the lag chart as a line with a shaded SLO band at 60 seconds and a red marker
   on breaches.
3. Draw the adoption chart as a cumulative percentage area rising to 40% by day 180.
4. Add sidebar filters (table, date range, SLO seconds) that re-render both charts.

```python
import streamlit as st, plotly.express as px

st.title("Replication Freshness & Feature Adoption")
fig = px.line(lag_df, x="ts", y="lag_seconds", color="table")
fig.add_hline(y=slo_seconds, line_dash="dash", annotation_text="sub-minute SLO")
st.plotly_chart(fig, use_container_width=True)
```

## WHEN TO USE IN PRODUCTION
Use it as the operations dashboard for a replication product: freshness SLOs next to
feature-adoption and usage metrics, so eng and product share one screen. It is right
for leadership reviews, incident postmortems and feature-launch tracking. Do NOT use
it as the alerting path — dashboards are for humans; automate paging from the
freshness API instead. It is also a poor fit for sub-second, high-cardinality
streaming telemetry (use a dedicated TSDB + Grafana).

## HOW IT HELPS STUDENTS
You practise Streamlit layout, Plotly charting, Pandas time-series shaping and SLO/
adoption storytelling — turning raw product and infra metrics into a decision-ready
view. Exactly the dashboarding skill product and platform teams hire for.

## STARTER CODE
`starter/main.py` builds both deterministic datasets, renders two Plotly figures and
wires sidebar filters, with `# TODO` markers for live data sources and breach alerts.
