Module 8 · Information Systems · Lesson 11 · Week 9

DataApp Technical Infographics

Reference material for the session in which the professor adds to the DataApp of the TCGplayer prices, live and with a coding agent, a Streamlit app in the views layer: a technical infographic generated from the catalogue and the run log, a ranking with drill-down checked against the cube, and prices over time, with charts chosen for each question and reviewed for accessibility and ethics. In the second hour each group adds the same kind of app to the DataApp of the partner.

About this session

DataApp Technical Infographics · 10/12/2026 · Prof. Afonso

Learning objective

By the end of the session, students should be able to choose the chart that fits each question of the DataApp, build a Streamlit app in its views layer with a technical infographic generated from metadata and analytical views with drill-down over the gold layer, and review the app for accessibility, time zones and the ethics of the chart, first with the TCGplayer prices and then with the partner data.

Session strategy

Demonstration followed by application. In the first hour the professor builds the app live with a coding agent in four CREATE prompts (queries and metadata, technical infographic, ranking with drill-down, time and accessibility) over the package of Lesson 7, comparing each step with the reference package 0.5.0. In the second hour each group adds a Streamlit app to the DataApp of the partner with prompt 05.

Session structure

  1. Daily — 15 min
  2. Chart selection and principles of perception — 10 min
  3. Step 01 · Queries of the view layer and metadata — 10 min
  4. Step 02 · Streamlit and the technical infographic — 10 min
  5. Step 03 · Ranking and drill-down checked against the cube — 10 min
  6. Step 04 · Prices over time, UTC, accessibility and ethics — 10 min
  7. Groups · Streamlit app for the DataApp of the partner — 60 min
  8. Self-study and next steps
Part IFoundations

1. How to read this material

This material accompanies Lesson 11, which has two hours. In the first, the professor adds to the DataApp of the TCGplayer prices, live and with a coding agent, a Streamlit app that explains how the DataApp works and lets its users explore the gold layer. In the second hour each group adds the same kind of app to the DataApp of the partner.

Part I discusses who reads a DataApp and how the question to be answered determines the form of the chart. Parts II to V follow the four steps of the session: the queries of the view layer, the technical infographic, the ranking with drill-down, and the prices over time with the review of accessibility and ethics. Part VI gathers the prompts, the tests, the reference numbers and the mistakes found in the rehearsal. Every number was measured on 08/11/2026 with the reference package 0.5.0 of lab/lesson-11/tcg_dataapp/, DuckDB 2.0.0, Streamlit 1.67.0, Altair 6.3.0 and Python 3.12. As in the previous lessons, every date of the warehouse is Unix time in seconds, in UTC.

2. Two readers of the same DataApp

A DataApp has two kinds of reader, and each needs a different kind of figure. The person who maintains it, in the group or at the partner, needs to know what runs, in which order, from which object to which, how large the model is and whether the last run worked; the figure for this reader is a technical infographic, which describes the system. The person who uses it needs the answer to a question about the business, such as which cards are worth the most or how the value of a set evolved; the figure for this reader is an analytical view, which describes the data.

The app of this lesson has one tab for the first reader and two for the second. Both kinds of figure obey the same rule: every number shown comes from the warehouse at the moment the page is opened, and none is typed by hand. A diagram drawn in a presentation tool describes the DataApp on the day it was drawn; a diagram generated from the catalogue and from the run log describes the DataApp that ran, and changes when the code changes.

TabReaderQuestionSource in the warehouse
Technical infographicwho maintains the DataAppwhat is the model, how did the last run go, what reads what?gold.*, ops.pipeline_runs, ops.pipeline_tasks, the catalogue
Ranking and drill-downwho uses the datawhich groups of cards are worth the most, and inside them which?report.mv_card_price_2026_09, report.v_card_price_latest, gold.agg_price_cube
Prices over timewho uses the datahow did a set or a card change between captures?mart_collectors.set_value, mart_collectors.card_price

3. The question chooses the chart

A chart is selected by the job that the data must do in the answer, not by the variety of forms that a library offers. Comparing magnitudes, showing a change over time, showing the share of a whole, descending a hierarchy and stating one number are different jobs, and each has a form that the eye reads with the least effort and the least error. The table below applies this rule to the questions of the DataApp.

Job of the dataQuestion in the DataAppFormAvoid
compare magnitudeswhich sets hold the most expensive cards?horizontal bars, ranked, from zeropie with seven slices; bars that start above zero
change over timehow did the value of a set evolve?line with one series highlightedseven coloured lines and a legend
part of a wholewhat share of the market is one set?one sentence, or a single stacked bardonut with labels outside it
hierarchyinside a set, which rarity, and inside it which card?bars with drill-down and roll-upa treemap read by colour
one numberhow many prices does the fact hold?the number and its labela gauge
how the system workswhat runs, in which order, from where to where?graph of tasks; graph of lineagea diagram drawn by hand

Horizontal bars are preferred for rankings because the names of sets, rarities and cards are long and fit on the left, where they are read in the same order as the bars. A pie is avoided because the comparison of angles is less precise than the comparison of lengths, and the precision drops further when the slices are many and similar.

4. What the eye reads first

Cleveland and McGill (1984) measured how precisely people compare quantities encoded in different ways, and found an order that still guides the design of charts: position on a common scale is read most precisely, followed by length, then angle and slope, then area, and colour last. A chart therefore places the quantity that carries the message in position or length, and reserves colour for pointing at what matters.

Three practices follow from this order and are applied throughout the app. The first is highlight and context: the series that carries the message is drawn in the accent colour of the palette, #2f8f78, and every other series stays grey, as context, so seven sets never require seven colours that a reader with colour blindness could not separate. The second is direct labelling: the value is written at the end of each bar and the name at the end of the highlighted line, which removes the legend and the travel of the eye between the legend and the mark. The third is a recessive frame: the grid and the axes are pale, because they help to read the marks and should not compete with them, in the sense in which Tufte (1983) asks for the ink of a chart to be spent on data.

The same principles explain what the app never does. A chart with two y axes lets the author choose the scales so that two series cross where it is convenient; a bar axis that does not start at zero exaggerates differences; a rainbow palette suggests an order that does not exist; 3D adds area and angle where only length was needed. Each of these choices changes the conclusion that a reader draws from the same data, which is the subject of section 16.

Part IIThe queries

5. A view layer that can be tested

The first step writes no chart. The queries of the app live in views/dashboard.py, a module of pure functions that receives a DuckDB connection and returns rows, without importing Streamlit. The separation has the same justification as the layers of Lesson 7: the queries can be tested alone, over the fake warehouse of the tests, in a fraction of a second, and the app is left with the drawing, which is harder to test and changes more often.

The connection of the app is opened with read_only=True. The view layer reads gold, the marts, the reports and the run log, and it is not able to change them: a DROP VIEW sent through this connection fails, and a test proves it. The explorer receives from the app the dimensions, the measure and the values chosen by the user, and the module accepts only dimensions and measures from fixed lists and passes every value as a parameter of the query, so that a set called x' OR '1'='1 returns no rows instead of every row.

views/dashboard.py · explore
def explore(con, source: str, dims: list[str], measure: str, filters: dict | None = None,
            suffix: str | None = None, limit: int = 15) -> dict:
    """Ranked groups of the explorer, with the SQL that produced them.

    The dimensions and the measure come from fixed lists and the filter values
    are parameters, so a value chosen in the app never becomes SQL.
    """
    if source not in SOURCES:
        raise ValueError(f"unknown source {source!r}")
    if measure not in MEASURES:
        raise ValueError(f"unknown measure {measure!r}")
    filters = filters or {}
    for d in list(dims) + list(filters):
        if d not in DIMENSIONS:
            raise ValueError(f"unknown dimension {d!r}")
    if source == "frozen" and not re.fullmatch(r"\d{4}_\d{2}", suffix or ""):
        raise ValueError("a frozen source needs a suffix YYYY_MM")
    table = SOURCES[source].format(suffix=suffix)
    label, expression = MEASURES[measure]
    group = ", ".join(dims)
    where = " AND ".join(f"{d} = ?" for d in filters) or "true"
    select = f"{group}, " if dims else ""
    sql = (f"SELECT {select}{expression} AS value\nFROM {table}\nWHERE market_price IS NOT NULL AND {where}\n"
           + (f"GROUP BY {group}\n" if dims else "") + f"ORDER BY value DESC\nLIMIT {int(limit)}")
    rows = _rows(con, sql, list(filters.values()))
    captured_at = con.execute(f"SELECT max(captured_at) FROM {table}").fetchall()[0][0]
    return {"sql": sql, "params": list(filters.values()), "rows": rows, "label": label,
            "captured_at": captured_at, "table": table}

6. The infographic is drawn from metadata

The technical infographic draws two graphs, and both are generated from information that the warehouse already holds or that the pipeline records. The lineage of the warehouse comes from the catalogue of DuckDB: duckdb_views() returns the SQL of every view, and searching it for the names of the other objects gives the edges, so that gold.fact_price is found to read db_ingestion, gold.dim_set and gold.dim_product. A table created by CREATE TABLE AS, however, keeps only its columns and forgets the query that created it. For the frozen reports, freeze_month now writes the source in the comment of the table, which duckdb_tables() returns.

The graph of the pipeline comes from the run log. Drawing it by importing pipeline.py would make the view layer depend on the module that sits above all layers, which inverts the direction that Lesson 7 established. The runner therefore records the graph of each run in a new table, ops.pipeline_tasks, next to ops.pipeline_runs, and the app reads both. On the warehouse of the rehearsal the lineage has 13 objects and 20 edges, and the graph of the last run has 12 tasks.

processors/gold.py · the comment of a frozen table
run(con, f"COMMENT ON TABLE report.{name} IS 'frozen from {source}, last capture of {month}'")
views/dashboard.py · lineage
def lineage(con) -> dict:
    """Objects of the warehouse, their rows and the objects each one reads.

    The edges of a view come from its own SQL in the catalogue (duckdb_views); a
    frozen table keeps its source in a comment, written by freeze_month.
    """
    views = _rows(con, "SELECT schema_name, view_name AS name, sql FROM duckdb_views() "
                       "WHERE schema_name IN ('gold', 'mart_collectors', 'report')")
    tables = _rows(con, "SELECT schema_name, table_name AS name, comment FROM duckdb_tables() "
                        "WHERE schema_name IN ('main', 'report') ORDER BY schema_name, table_name")
    names = ["db_ingestion"] + [f"{v['schema_name']}.{v['name']}" for v in views] + \
            [f"{t['schema_name']}.{t['name']}" for t in tables if t["schema_name"] == "report"]
    edges = []
    for v in views:
        target = f"{v['schema_name']}.{v['name']}"
        for source in names:
            if source != target and re.search(rf"(?<![\w.]){re.escape(source)}(?!\w)", v["sql"]):
                edges.append((source, target))
    for t in tables:
        match = re.search(r"frozen from ([\w.]+)", t["comment"] or "")
        if match:
            edges.append((match.group(1), f"{t['schema_name']}.{t['name']}"))
    nodes = []
    for name in names:
        rows = con.execute(f"SELECT count(*) FROM {name}").fetchall()[0][0]
        kind = "table" if name == "db_ingestion" or name.startswith("report.mv_") else "view"
        layer = "etls" if name == "db_ingestion" else ("views" if name.startswith("report.") else "processors")
        nodes.append({"name": name, "rows": rows, "kind": kind, "layer": layer})
    return {"nodes": nodes, "edges": sorted(set(edges))}
Part IIIStreamlit and the infographic

7. The execution model of Streamlit

A Streamlit app is a Python script that runs from top to bottom each time the user changes a widget. The model is simple to write, because the page is a sequence of calls such as st.metric and st.altair_chart, and it has two consequences that shape the code. What must survive between runs, such as the path of a drill-down, is kept in st.session_state; and what is expensive to create, such as the connection to the warehouse, is created once with st.cache_resource and reused by every run and every user.

PieceIn tcg-dataappWhy
st.cache_resourcethe read-only connection to DuckDBone connection for every run and every user
st.session_statethe path of the drill-downthe click survives the rerun that it causes
st.tabsinfographic, ranking, prices over timeone question per tab
st.metricsets, cards, prices, captures, cellsa headline number needs no chart
st.graphviz_chartthe DAG and the lineage, from DOT textthe graph is generated and drawn in the browser
st.altair_chartthe bars and the lines, with alt=full control of marks, scales and selection

The app is started by a new command of the package, tcg-dataapp app, which runs python -m streamlit run on the file views/app.py of the installed package. Streamlit and Altair are an optional extra (pip install -e '.[app]'), so the pipeline still installs and runs on a machine that never shows the app, such as the server that runs it every day.

8. The theme of the design system

The theme of a Streamlit app is configuration, not code. The file .streamlit/config.toml, read from the folder where the app is started, sets the colours, the fonts and the radius of every component, and the reference package applies the palette and the typography of the Inteli design system: the accent #2f8f78, the ink #2e2640 for text, the greys #e6eaeb and #caced6 for backgrounds and borders, Inter for text and JetBrains Mono for code. The same colours are repeated as constants at the top of views/app.py, because the marks of Altair are drawn by the code of the app and not by the theme.

.streamlit/config.toml (the URLs of the fonts shortened)
# Theme of the Streamlit app in the palette of the Inteli design system.
# Streamlit reads this file from the folder where the app is started,
# so run `tcg-dataapp app` from the folder of the project.

[theme]
base = "light"
primaryColor = "#2f8f78"
backgroundColor = "#ffffff"
secondaryBackgroundColor = "#e6eaeb"
textColor = "#2e2640"
linkColor = "#2e2640"
borderColor = "#caced6"
showWidgetBorder = true
baseRadius = "0.25rem"
font = "Inter:https://fonts.googleapis.com/..."
codeFont = "'JetBrains Mono':https://fonts.googleapis.com/..."
chartCategoricalColors = ["#2f8f78", "#2e2640", "#b2b6bf"]

[server]
runOnSave = false

[browser]
gatherUsageStats = false

9. The technical infographic

The first tab answers the questions of whoever maintains the DataApp. Five metrics state the size of the model; one line states the result of the last run; the graph of the pipeline shows the twelve tasks with their dependencies, with the status and the seconds written inside each box; the graph of the lineage groups the thirteen objects of the warehouse in three clusters (ETLs, Processors and Views), with the rows and the kind of each object, tables drawn as cylinders and views as boxes. Each figure has an alternative text and a table view below it.

Number on the warehouse of the rehearsalValue
sets · cards · prices of the fact7 · 1,273 · 5,951
captures · cells of the cube5 · 524
last run12 of 12 tasks ok, 0 failed attempts, 25 s
lineage13 objects and 20 edges; db_ingestion with 7,448 records
frozen report of September1,226 rows; its source, mart_collectors.card_price, read from the comment

The status of a task is written as text (ok, FAILED, skipped) and the border of the box only repeats it. A reader who does not distinguish the accent from the ink, or who prints the page in grey, still reads the status. The seconds come from Unix times recorded in whole seconds, so a task that took less than one second is written as < 1 s.

views/app.py · the graph of the pipeline
def dot_pipeline(tasks: list[dict]) -> str:
    """The DAG of the last run, with the status written in each node and not only coloured."""
    lines = ['digraph { rankdir=LR; bgcolor="transparent";',
             f'node [shape=box, style="rounded,filled", fillcolor="white", color="{CONTEXT}", '
             f'fontname="Inter", fontsize=11, fontcolor="{INK}"]; edge [color="{TEXT}", arrowsize=0.6];']
    for t in tasks:
        mark = {"success": "ok", "failed": "FAILED", "skipped": "skipped"}.get(t["status"], t["status"] or "-")
        border = ACCENT if t["status"] == "success" else INK
        lines.append(f'"{t["task"]}" [label="{t["task"]}\\n{mark} · {seconds(t["seconds"])}", color="{border}", penwidth=1.4];')
        for d in t["depends_on"]:
            lines.append(f'"{d}" -> "{t["task"]}";')
    return "\n".join(lines + ["}"])
Part IVRanking and drill-down

10. The explorer of Lesson 6 in the app

The second tab repeats, in Streamlit, the explorer of the lab of Lesson 6. The user chooses the source (the report frozen in September or the live view of the last capture), the measure (highest price, average price, market value or number of prices) and the dimensions of the grouping (set, rarity, card and variant), and the app draws the groups as horizontal bars ranked from the largest value, with the value written at the end of each bar. A click on a bar keeps its values as filters and descends one level of the hierarchy set › rarity › card; a row of buttons rolls back up.

Every view that does not use the card is checked against the cube of Lesson 6. A grouping rolls up the dimensions that it does not use, and grouping(set_name, rarity, variant) encodes them as bits worth 4, 2 and 1; grouping by set therefore reads the cells with grouping_id 2 + 1 = 3, and grouping by set and rarity, the cells with grouping_id 1. The app reports in one sentence whether the bars agree with those cells, and shows the SQL of the view with its parameters.

views/dashboard.py · cube_check
def cube_check(con, result: dict, dims: list[str], measure: str, filters: dict | None = None) -> dict | None:
    """Reads the same groups from gold.agg_price_cube and says whether they agree.

    The cube has no card, so the check exists only when neither the grouping
    nor the filters use it.
    """
    filters = filters or {}
    used = set(dims) | set(filters)
    if "card" in used:
        return None
    grouping_id = sum(bit for d, bit in CUBE_BITS.items() if d not in used)
    where = " AND ".join([f"{d} = ?" for d in filters] + ["grouping_id = ?", "date_unix = ?"])
    cube = _rows(con, f"SELECT {', '.join(dims) + ', ' if dims else ''}{CUBE_MEASURES[measure]} AS value "
                      f"FROM gold.agg_price_cube WHERE {where}",
                 list(filters.values()) + [grouping_id, result["captured_at"]])
    key = lambda r: tuple(r[d] for d in dims)  # noqa: E731
    cube_by_key = {key(r): round(float(r["value"]), 2) for r in cube}
    agree = all(abs(cube_by_key.get(key(r), float("nan")) - round(float(r["value"]), 2)) < 0.01
                for r in result["rows"])
    return {"grouping_id": grouping_id, "cells": len(cube), "agree": agree}

11. A click that changes the state of the app

Since version 1.35, st.altair_chart returns the selection of the user when it is called with on_select="rerun" and the chart declares a selection parameter. The click arrives, however, in the run in which the checkboxes of the grouping were already drawn, and Streamlit does not allow the state of a widget to change after the widget exists in the run. The app therefore stores the click as a pending change, calls st.rerun(), and applies the change at the top of the tab, before the widgets are created.

A second detail prevents a loop. The chart of the new level would start with the selection of the previous one, which would fire the drill-down again; the key of the chart includes the depth of the path, so each level is a new chart without a selection.

views/app.py · the pending change
    if "pending" in state:  # a click or a roll-up of the previous run, applied before the widgets exist
        state.path, dims_next = state.pop("pending")
        for d in db.DIMENSIONS:
            state[f"dim_{d}"] = d in dims_next
    for d in db.DIMENSIONS:
        state.setdefault(f"dim_{d}", d == "set_name")

12. From the set to the rarity

LevelGroupsFirst bars (highest market price, US$)Check with the cube
frozen report of September, by set5ME: Ascended Heroes 1,049.08; ME: 30th Celebration 1,000.00; ME05: Pitch Black 198.62; ME04: Chaos Rising 180.57; ME03: Perfect Order 128.25grouping_id 3, 5 cells, agree
click on ME: Ascended Heroes, by rarity9Special Illustration Rare 1,049.08; Mega Hyper Rare 386.71; Illustration Rare 72.07; Mega Attack Rare 55.34grouping_id 1, 9 cells, agree
click on Special Illustration Rare, by card15 of 22 (the limit of the view)Pikachu ex - 276/217 1,049.08; Mega Gengar ex - 284/217 950.04none: the cube has no card

The first card of the last level is the same Pikachu ex 276/217 that Lessons 6 and 7 froze in September at US$ 1,049.08. The agreement between the bars and the cube at every level shows that the app reads the model and does not recompute it in its own way.

Part VTime, accessibility and ethics

13. Time zones and Unix time

The warehouse keeps every date as Unix time in UTC, as decided in Lesson 6, and the app converts it to a calendar day only when it draws it. The conversion must also be done in UTC. A browser formats a date in the time zone of the computer unless the chart says otherwise, and in São Paulo, three hours behind UTC, the capture at 00:00 UTC of 01/09/2026 would be drawn at 21:00 of 31/08/2026, in the wrong month. The app converts with pd.to_datetime(unit="s", utc=True), declares the scale of the axis as utc and shows the Unix time in the tooltip.

Unix timeUTCSão Paulo (UTC−3)
177232320001/03/2026 00:0028/02/2026 21:00
178822080001/09/2026 00:0031/08/2026 21:00
179400960007/11/2026 00:0006/11/2026 21:00

14. Storytelling: the sentence before the chart

Knaflic (2015) proposes that a chart for communication starts from the sentence it must support, and not from the data available. The app opens with one sentence built from the warehouse: on 07/11/2026 the most valuable card is Mew - R/RGB, of ME: 30th Celebration, in Holofoil, at US$ 4,492.45, and that set holds 65.3% of the market value of the seven sets. Each view repeats the practice in smaller scale, with a caption that states the conclusion of the chart, such as the first and the last value of the highlighted series.

The tab of prices over time applies highlight and context. By default it highlights the series with the largest value, which on the warehouse of the rehearsal is ME: 30th Celebration, whose market value went from US$ 1,349.93 on 01/09/2026 to US$ 12,403.41 on 07/11/2026; the other six sets remain as thin grey lines. The user can highlight another series, or switch to the five most valuable cards of one set, where the same rule applies.

15. Accessibility of the app

CriterionReferenceIn the app
meaning never in colour aloneWCAG 2.2, 1.4.1 Use of Colorstatus written in the box; names at the end of the line; one accent
alternative textWCAG 2.2, 1.1.1 Non-text Contentalt= on every Altair and Graphviz chart, with the main number
the data behind the figureWCAG 2.2, 1.1.1a "Table view" under every figure
contrast of textWCAG 2.2, 1.4.3 Contrast (Minimum), 4.5:1text in #2e2640 on white, 14.6:1
one conclusion per viewplain languagea sentence with the number above or below the chart
readable without hoverpointer not requiredvalues written on the bars; tooltip only adds detail

The criteria are applied in the step 04 prompt as a review of the three tabs, after the charts exist, because an agent that writes a chart rarely adds the alternative text and the table view on its own.

16. Ethics of the chart

A chart can be accurate in every number and still lead to a wrong conclusion, through the choice of the scale, of the period or of what is compared (Cairo, 2019). The app adopts five rules. Every bar starts at zero, so the length of a bar is proportional to its value. The source and the date of the capture are written under each chart. Every capture of the warehouse is drawn, and no period is cut to make a trend look stronger. The check with the cube and the SQL of each view are visible, so a reader can verify how the number was obtained.

The fifth rule concerns interpretation. ME: 30th Celebration was released on 16/09/2026, and its first capture, on 01/09/2026, holds prices from before the release; the jump of its market value to 07/11/2026 reflects the launch and the arrival of its cards in the market, not the appreciation of the same cards. The sentence of a view must say what the data supports, and the comparison of appreciation in Lesson 6 required at least two captures of the same card for this reason.

Part VIThe lab

17. The lab in four steps

StepPromptBuildsChecks
0101_queries_and_metadata.mdviews/dashboard.py, ops.pipeline_tasks, comment of the frozen tables, tests/test_dashboard.py13 objects and 20 edges; the explorer agrees with the cube; a typed value never becomes SQL
0202_infographic.mdviews/app.py (first tab), tcg-dataapp app, .streamlit/config.toml7 sets, 1,273 cards, 5,951 prices, 5 captures, 524 cells, 12 of 12 tasks ok
0303_ranking_and_drilldown.mdsecond tabME: Ascended Heroes first at US$ 1,049.08; a click opens 9 rarities
0404_time_and_accessibility.mdthird tab, accessibility pass, tests/test_app.pydates in UTC; alt text and table view on every figure; 22 tests pass
prepare the lab
git clone --depth 1 https://github.com/afonsolelis/aulas.git
cp -r aulas/pages/module-8-sistemas-informacao/lab/lesson-7/tcg_dataapp ~/lesson_11_app && cd ~/lesson_11_app
python3 -m venv .venv && source .venv/bin/activate
pip install -e '.[dev]' streamlit altair
tcg-dataapp run             # the warehouse that the app reads
claude                      # or the coding agent of your choice

18. The prompts of the session

prompts/01_queries_and_metadata.md
[C] Character
You are a data engineer who maintains tcg-dataapp, the Python package of
Lesson 7, with its three layers (views, processors, etls), its pipeline of
twelve tasks and its DuckDB warehouse. You know that a chart is only as
honest as the query behind it.

[R] Request
Prepare the view layer for a Streamlit app, without Streamlit yet.
1. views/dashboard.py, a module of pure functions over a read-only
   connection (connect(db_path) opens it with read_only=True):
   - overview(con): sets, cards, prices of the fact, captures, cells of the
     cube, first and last capture, and the last run of ops.pipeline_runs
     (tasks ok, tasks, failed attempts, start and end).
   - headline(con): the most valuable card of report.v_card_price_latest
     and the share of the largest set in report.v_set_value_latest.
   - task_graph(con): the tasks of the last run with their dependencies,
     final status, attempts and seconds.
   - lineage(con): every object of db_ingestion, gold, mart_collectors and
     report, its rows, its kind (table or view) and its layer, and the
     edges source -> target found in the SQL of each view (duckdb_views()).
   - explore(con, source, dims, measure, filters, suffix): ranked groups
     of the frozen report report.mv_card_price_<suffix> or of the live view
     report.v_card_price_latest, returning the rows and the SQL.
   - cube_check(con, result, dims, measure, filters): the same groups read
     from gold.agg_price_cube at the right grouping_id, and whether they
     agree; None when the card is used, because the cube has no card.
   - price_history(con, level, highlight): market value of each set on
     every capture, or the five most valuable cards of one set.
2. Two small changes below the views, so the app can draw from metadata:
   - pipeline.py keeps the graph of each run in ops.pipeline_tasks
     (run_id, task, depends_on VARCHAR[]);
   - freeze_month writes COMMENT ON TABLE report.mv_... IS 'frozen from
     <source>, last capture of <month>', because a table does not remember
     the query that created it.
3. tests/test_dashboard.py over the FakeClient of conftest.py.

Facts measured on 08/11/2026 (confirm before use):
- tcg-dataapp run: 12 tasks ok in about 25 s; 7 sets, 1,273 cards,
  5,951 prices, 5 captures, 524 cells of the cube.
- The lineage has 13 objects and 20 edges; the frozen report of September
  has 1,226 rows.

[E] Example
cube_check for dims = ["set_name"]: grouping_id = 2 + 1 = 3 (rarity and
variant rolled up), 7 cells on the last capture, agree = True.

[A] Adjustments
- dims and measure come from fixed lists (DIMENSIONS, MEASURES); anything
  else raises ValueError. Filter values are parameters (?), never SQL.
- Dates stay in Unix time in this module; nothing is converted here.
- The views never read db_ingestion, except to count it in the lineage.

[T] Type of output
The files, the output of pytest and, on the real warehouse, the result of
overview, lineage (number of nodes and edges) and one cube_check.

[E] Extras
Show the plan before editing. Stop at the end.
prompts/02_infographic.md
[C] Character
You are the same engineer, now also responsible for how the DataApp
explains itself. The audience is technical: the group, the professor and
the partner who will maintain the pipeline.

[R] Request
Create the Streamlit app and its first tab, the technical infographic.
1. views/app.py, started by a new command tcg-dataapp app [--port]
   [--headless], which runs `python -m streamlit run` on the file of the
   package. Streamlit and Altair go in an optional extra
   (pip install -e '.[app]').
2. .streamlit/config.toml with the theme of the Inteli design system:
   primaryColor #2f8f78, textColor #2e2640, secondaryBackgroundColor
   #e6eaeb, borderColor #caced6, Inter and JetBrains Mono, radius
   0.25rem, gatherUsageStats false.
3. At the top, a title, the version, the warehouse, the period of the
   captures in UTC and one sentence built from headline(con).
4. Tab "Technical infographic":
   - five st.metric: sets, cards, prices of the fact, captures, cells;
   - one line on the last run (tasks ok, failed attempts, seconds);
   - the DAG of the last run with st.graphviz_chart, the status and the
     seconds written inside each box;
   - the lineage grouped in three clusters (ETLs, Processors, Views), each
     node with its rows and kind, tables drawn as cylinders;
   - a "Table view" expander under each figure, and an alt text on each.

Facts measured on 08/11/2026 (confirm before use):
- Streamlit 1.67.0, Altair 6.3.0, DuckDB 2.0.0, Python 3.12.
- On the warehouse of the rehearsal the infographic shows 7 sets, 1,273
  cards, 5,951 prices, 5 captures, 524 cells and 12 of 12 tasks ok.

[E] Example
"extract_products\nok · 7 s" inside the box of the task, with the border
in #2f8f78 when ok and in #2e2640 otherwise, so the status never depends
on the colour alone.

[A] Adjustments
- The app opens the warehouse read-only and only through views/dashboard.py.
- No KPI in colour, no gauge, no 3D: numbers in text, figures in the ink
  and the greys of the palette, one accent.
- When the warehouse does not exist, the app says to run tcg-dataapp run
  and stops.

[T] Type of output
The files and a screenshot of the first tab, with the command used.

[E] Extras
Show the plan before editing. Stop at the end.
prompts/03_ranking_and_drilldown.md
[C] Character
You are the same engineer. The second tab repeats, in Streamlit, the
explorer of the lab of Lesson 6: ranked bars over the frozen report or the
live view, with drill-down and roll-up on the hierarchy set › rarity ›
card.

[R] Request
Tab "Ranking and drill-down" in views/app.py:
1. Controls in one row: source (frozen report of the last frozen month or
   live view), measure (highest price, average price, market value,
   number of prices) and four checkboxes to group by set, rarity, card and
   variant.
2. Horizontal bars ranked from the largest value, in #2f8f78, with the
   value written at the end of each bar and a tooltip; height of the
   chart proportional to the number of groups.
3. Drill-down: a click on a bar (st.altair_chart with on_select="rerun"
   and a point selection) keeps the values of the clicked bar as filters
   and moves the grouping one level down the hierarchy. A row of buttons
   (All sets, Set: ..., Rarity: ...) rolls up.
4. Under the chart: the number of groups, the source and its capture in
   UTC, the result of cube_check in one sentence, a "Table view" expander
   and an expander with the SQL and its parameters.

Facts measured on 08/11/2026 (confirm before use):
- Frozen report 2026-09, highest price by set: ME: Ascended Heroes
  1,049.08, ME: 30th Celebration 1,000.00, ME05: Pitch Black 198.62;
  5 groups, grouping_id 3, agrees with the cube.
- Drill into ME: Ascended Heroes: 9 rarities, the first Special
  Illustration Rare at 1,049.08, grouping_id 1, 9 cells, agrees.

[E] Example
Click on "ME: Ascended Heroes" with dims = [set_name]:
path = [("set_name", "ME: Ascended Heroes")], dims = [rarity].

[A] Adjustments
- A widget state cannot change after the widget exists: store the click
  as a pending change, call st.rerun() and apply it at the top of the tab.
- The key of the chart includes the depth of the path, so the selection of
  the previous level does not fire again.
- One axis, one colour, no legend for a single series.

[T] Type of output
The changes and two screenshots: the top level and one drill-down.

[E] Extras
Show the plan before editing. Stop at the end.
prompts/04_time_and_accessibility.md
[C] Character
You are the same engineer, reviewing the app for the person who cannot
see a colour, reads with a screen reader or opens it on a Brazilian
laptop where the clock is three hours behind UTC.

[R] Request
1. Tab "Prices over time": a line chart of price_history, either the
   market value of each set or the five most valuable cards of one set.
   One series is highlighted in #2f8f78 (selectbox, the largest by
   default) with points, a tooltip and its name written at the end of the
   line; the others stay as thin lines in #caced6, as context. Below the
   chart, one sentence with the first and the last value of the
   highlighted series.
2. Dates: the warehouse keeps Unix time; the app converts it only when
   drawing, with pd.to_datetime(unit="s", utc=True), an Altair scale of
   type "utc" and the format %d/%m/%Y. The tooltip shows the Unix time too.
3. An accessibility pass on the three tabs: alt text on every chart and
   graph, a table view under every figure, the status written in text,
   no meaning carried by colour alone, contrast of the text against the
   background, and no chart with two y axes.
4. tests/test_app.py with streamlit.testing.v1.AppTest over the fake
   warehouse (skipped when Streamlit is not installed): the app renders
   without exception, the metrics show 2 sets, 3 cards, 6 prices and
   2 captures, and checking "Rarity" reruns without error.

Facts measured on 08/11/2026 (confirm before use):
- ME: 30th Celebration went from US$ 1,349.93 to US$ 12,403.41 of market
  value between 01/09/2026 and 07/11/2026; on 07/11/2026 it holds 65.3%
  of the value of the seven sets, and its Mew - R/RGB (Holofoil) is the
  most valuable card at US$ 4,492.45.
- pytest: 22 tests pass in about 10 s, without network.

[E] Example
A capture at 1788220800 is 01/09/2026 00:00 UTC; drawn in local time in
São Paulo it would read 31/08/2026 21:00 and fall on the wrong day.

[A] Adjustments
- No rainbow of seven colours for seven sets: highlight and context.
- Write the sentence before choosing the chart: the chart supports it.

[T] Type of output
The changes, a screenshot of the tab and the output of pytest.

[E] Extras
Show the plan before editing. Stop at the end.
prompts/05_group_dataapp.md
[C] Character
You are a data engineer of the group, working in the repository of the
DataApp of the partner, whose gold layer lives in the ClickHouse of the
class (shrek2) or in the warehouse of the package of the group.

[R] Request
Add to the DataApp of the group a Streamlit app in the views layer, in
the pattern of tcg-dataapp 0.5.0:
1. A module of pure query functions over a read-only connection, reading
   only the gold layer, the marts, the reports and the run log.
2. A first tab that explains the DataApp: the size of the model, the last
   run and the lineage from the landing table to the reports.
3. At least two analytical views that answer questions of the partner,
   each one opened by a sentence with the number that matters, with a
   table view, an alt text and the SQL behind it. One of them must allow
   drill-down on a hierarchy of the model.
4. The theme of the Inteli palette in .streamlit/config.toml, and dates
   shown in UTC from the Unix time.
5. Tests of the query functions without network, and one AppTest.

[E] Example
"In October the partner sold 1,240 units in São Paulo, 38% of the
month" above a ranked bar chart by city, with drill-down city › store.

[A] Adjustments
- The credentials of ClickHouse come from environment variables and never
  enter the repository.
- Every chart has one y axis, one accent colour and a written conclusion.
- No question of the partner is answered by a chart that does not show it.

[T] Type of output
The files, the command to run the app, a screenshot of each tab and the
output of the tests.

[E] Extras
Show the plan before editing. Stop at the end.

19. Testing an app without a browser

TestWhat it proves
test_the_connection_of_the_app_cannot_writethe view layer is read-only
test_overview_counts_the_model_and_the_last_runthe metrics of the infographic
test_task_graph_comes_from_the_run_logthe DAG is read from ops.pipeline_tasks
test_lineage_reads_the_catalogue_and_the_comment_of_the_frozen_tablethe lineage comes from metadata
test_explorer_drills_down_and_agrees_with_the_cubethe bars and the cube give the same numbers
test_frozen_source_reads_the_month_that_was_frozenthe frozen report keeps its month
test_explorer_refuses_anything_outside_its_lists (4 cases)no dimension, measure or source outside the lists
test_a_filter_value_is_a_parameter_not_sqla typed value never becomes SQL
test_price_history_by_set_and_by_cardthe series keep Unix time
test_the_app_renders_every_tab_without_errorsthe app runs in AppTest, shows the metrics and reruns on a click
the 9 tests of Lesson 7the pipeline still works

streamlit.testing.v1.AppTest executes the script of the app as Streamlit would, over the fake warehouse of conftest.py, and exposes its widgets, so a test can check a box and run the app again without a browser. The test is skipped when Streamlit is not installed, and the 22 tests take about ten seconds.

20. Reference numbers

MeasureValue
run of the rehearsal12 tasks ok in about 25 s; 7 sets, 1,490 products (1,273 cards), 5,951 prices in 5 captures
gold layer524 cells in the cube; report.v_card_price_latest with 1,627 rows
lineage13 objects, 20 edges
frozen report of September1,226 rows; highest price by set led by ME: Ascended Heroes at US$ 1,049.08 (Pikachu ex 276/217)
last capture (07/11/2026)Mew - R/RGB (ME: 30th Celebration, Holofoil) at US$ 4,492.45; ME: 30th Celebration with 65.3% of the market value
tests22 passed in about 10 s, without network

21. Mistakes found in the rehearsal

The problems below appeared while the app was rehearsed on 08/11/2026, and the reference package and the prompts already carry the corrections.

Labels that disappear

The first version of the ranking passed the height only to the Altair chart, and Streamlit drew it with its default height; the bars became thin and Vega omitted every other label of the axis to avoid overlap, so two sets had no name. The height is now passed to st.altair_chart as well, proportional to the number of groups, with theme=None so that the configuration of the app is not replaced by the theme of Streamlit.

Deprecated parameters

Streamlit 1.67 warns that use_container_width will be removed, and agents trained on older code still write it. The app uses width="stretch".

Decimal values

DuckDB returns DECIMAL columns as Python Decimal, which Altair does not treat as numbers. The app converts them to float when it builds the data frame, and the module of queries keeps the exact values.

The direction of the layers

Asked to draw the DAG, an agent imports pipeline.build_tasks into the view layer, which makes the views depend on the module that sits above all layers. The graph of the run is recorded in ops.pipeline_tasks instead, and the views read the warehouse only.

22. The second hour

In the second hour each group adds a Streamlit app to the DataApp of the partner, with prompt 05 and in the pattern of the reference package: a module of query functions over a read-only connection, tested without network; a tab that explains the DataApp, with the size of the model, the last run and the lineage; at least two analytical views that answer questions of the partner, each opened by a sentence with the number that matters, one of them with drill-down on a hierarchy of the model; the theme of the Inteli palette; dates in UTC. The credentials of ClickHouse come from environment variables and never enter the repository.

23. Glossary

TermMeaning in this lesson
technical infographica figure that describes how the DataApp works: model, runs, lineage
analytical viewa figure that answers a question about the data
lineagethe graph of which object of the warehouse reads which
highlight and contextone series in the accent colour, the others in grey
direct labelthe value or name written next to the mark, instead of a legend
drill-down and roll-updescending and ascending a hierarchy of a dimension
grouping_idthe bits of the dimensions rolled up in a cell of the cube
rerunthe execution of the whole script of Streamlit after an interaction
alternative texta textual description of a figure, read by screen readers
AppTestthe class of Streamlit that runs an app in a test, without a browser

24. Checklist

  • The queries of the app live in a module without Streamlit, and are tested.
  • The connection of the app is read-only.
  • Dimensions and measures come from fixed lists; values are parameters.
  • The infographic is generated from the catalogue and the run log.
  • Each view opens with a sentence that states its conclusion.
  • One y axis, one accent colour, bars from zero.
  • Every figure has an alternative text and a table view.
  • Dates are converted from Unix time in UTC only when drawn.
  • The drill-down agrees with the cube.
  • The app runs in an AppTest.

25. References and self-study

  • Streamlit Part 5: Mastering Data Visualization and Chart Types (self-study 1, 40 min).
  • Streamlit Crash Course: From Zero to Data App (self-study 2, video, 40 min).
  • Create Effective UIs with Streamlit Quickly (self-study 3, 40 min).
  • CLEVELAND, W. S.; McGILL, R. Graphical perception: theory, experimentation, and application to the development of graphical methods. Journal of the American Statistical Association, v. 79, n. 387, p. 531–554, 1984.
  • TUFTE, E. R. The Visual Display of Quantitative Information. Cheshire: Graphics Press, 1983.
  • KNAFLIC, C. N. Storytelling with Data. Hoboken: Wiley, 2015.
  • CAIRO, A. How Charts Lie. New York: W. W. Norton, 2019.
  • W3C. Web Content Accessibility Guidelines (WCAG) 2.2. 2023.
  • Streamlit. Documentation of st.altair_chart, theming and AppTest, at docs.streamlit.io.