Module 8 · Information Systems · Lesson 11 · Week 9

Instruction session · Thursday, December 10, 2026 · one hour of demonstration, one hour of application in the groups

DataApp Technical Infographics

The DataApp of the TCGplayer prices already runs by itself. In this session it gains the layer that people look at: a Streamlit app, inside the views layer of the package, that explains how the DataApp works and lets its users explore the gold layer with charts chosen for each question.

Chart selectionStreamlitTechnical infographicDrill-downAccessibilityEthics of the chart

Project ritual

Daily · 15 minutes

Each group reports the progress of its deliverables, the work planned for this session and the blockers that require a decision.

15:00
What I didWhat I will doBlockersProgress
Agenda · two hours
One hour building the app, one hour in the DataApp of the group

In the first hour the professor builds the app live with a coding agent, in four steps, over a copy of the package of Lesson 7, and compares each step with the reference package 0.5.0. In the second hour each group adds the same kind of app to the DataApp of the partner.

0:20 · step 01Queries and metadataAgent: views/dashboard.pyA view layer that can be tested; lineage from the catalogue
0:30 · step 02Technical infographicAgent: views/app.py, themeThe execution model of Streamlit; the DAG and the lineage
0:40 · step 03Ranking and drill-downAgent: second tabThe explorer of Lesson 6 with clicks on the bars
0:50 · step 04Time and accessibilityAgent: third tab, testsHighlight and context; UTC; alt text and table view
1:00 · groupsThe app of the partnerEach groupTwo analytical views and one tab that explains the DataApp
Where the work happensOn the computer, in a terminal and in the browser: pip install -e '.[dev,app]', tcg-dataapp run, tcg-dataapp app and pytest. The reference package is in lab/lesson-11/tcg_dataapp/ of the module.
0:05 · Chart selection
The job of the data chooses the chart

A chart is chosen by the question it must answer, not by the variety of the library. Each question of the DataApp has one job, and each job has a form that the eye reads with the least effort.

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 between captures?line, one series highlightedseven coloured lines with 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 headline numberhow many prices does the fact hold?a number with its label, no charta gauge
how the system workswhat runs, in which order, from where to where?a graph of tasks and a graph of lineagea diagram drawn by hand that drifts from the code
0:10 · Principles
What the eye reads first, and what the chart must not do

Position on a common scale is read more precisely than length, length more than angle and area, and all of them more than colour. A chart therefore places the message in position or length and uses colour only to point at it.

Highlight and context

One accent colour

The series that carries the message is drawn in the accent; every other series stays grey, as context. Seven sets do not need seven colours, which no reader with colour blindness separates.

Direct labels

Text where the eye already is

The value at the end of the bar and the name at the end of the line replace the legend, which forces the eye to travel and back. The grid and the axes stay pale.

The sentence first

Storytelling

Each view opens with the sentence that states the conclusion, with the number that matters, and the chart supports that sentence. A chart without a sentence leaves the conclusion to chance.

Never in this DataAppTwo y axes on the same chart, a bar axis that does not start at zero, a rainbow palette, 3D and a period cut to make a trend look stronger. Each of them changes the conclusion that a reader draws from the same data.

Step 01 · 0:20 · Queries

A view layer that can be tested

Before any chart, the queries of the app live in one module without Streamlit, over a read-only connection. Two small changes below the views give the infographic its metadata.

Files

views/dashboard.py, pipeline.py (ops.pipeline_tasks), processors/gold.py (comment of the frozen tables), tests/test_dashboard.py.

Review before moving on
  • Does the connection of the app refuse a DROP VIEW?
  • Does the lineage have 13 objects and 20 edges on the real warehouse?
  • Does a dimension outside the list raise ValueError, and a typed value stay a parameter?
Prompt 01 · CREATE
[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.
Step 01 · Theory
The infographic is drawn from metadata, not by hand

A diagram drawn by hand describes the system on the day it was drawn. A diagram generated from the catalogue and the run log describes the system that ran, and changes when the code changes.

The catalogue

duckdb_views()

The SQL of every view is in the catalogue. Searching it for the names of the other objects gives the edges of the lineage: gold.fact_price reads db_ingestion, gold.dim_set and gold.dim_product.

The comment

A table forgets its query

A table made by CREATE TABLE AS keeps only its columns. freeze_month writes its source in the comment, and the lineage reads it from duckdb_tables().

The run log

ops.pipeline_tasks

The runner records the graph of each run next to ops.pipeline_runs, so the app draws the DAG without importing the pipeline, which would break the direction of the layers.

Safe by constructionThe dimensions and the measures of the explorer come from fixed lists, and the values chosen by the user are parameters of the query. A set called x' OR '1'='1 returns no rows, and a test proves it.

Step 02 · 0:30 · Infographic

The app and its technical infographic

The second step creates the app, its command and its theme, and the first tab: the size of the model, the last run, the DAG of the run and the lineage of the warehouse, each with a table view.

Files

views/app.py, cli.py (tcg-dataapp app), .streamlit/config.toml, pyproject.toml (extra app).

Review before moving on
  • Does tcg-dataapp app open on port 8501, read-only?
  • Do the metrics show 7 sets, 1,273 cards, 5,951 prices, 5 captures and 524 cells?
  • Is the status of each task written inside its box?
Prompt 02 · CREATE
[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.
Step 02 · Theory
Streamlit runs the whole script at every click

A Streamlit app is a Python script that runs from top to bottom each time the user changes a widget. What must survive between runs is kept in st.session_state, and what is expensive is cached.

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, drawn in the browser
.streamlit/config.tomlthe palette and the fonts of the design systemthe theme is configuration, not code
.streamlit/config.toml
[theme]
base = "light"
primaryColor = "#2f8f78"
backgroundColor = "#ffffff"
secondaryBackgroundColor = "#e6eaeb"
textColor = "#2e2640"
borderColor = "#caced6"
baseRadius = "0.25rem"
font = "Inter:https://fonts..."
codeFont = "'JetBrains Mono':..."

[browser]
gatherUsageStats = false
Step 02 · Result
What the first tab shows about the DataApp

The tab answers the questions of whoever maintains the DataApp: how large the model is, whether the last run worked, what runs in which order and which object reads which. Every number comes from the warehouse of the rehearsal, on 08/11/2026.

7sets
1,273cards
5,951prices in the fact
5captures
524cells of the cube
The DAG of the last run

Twelve boxes, from extract_sets to write_report, each one with its status and its seconds written inside, for instance extract_products · ok · 7 s. The run took 25 seconds, and 12 of 12 tasks ended ok.

The lineage of the warehouse

Thirteen objects in three clusters (ETLs, Processors, Views) and twenty edges. The landing table holds 7,448 records, the fact 5,951 rows and the frozen report of September 1,226; tables are cylinders, views are boxes.

Step 03 · 0:40 · Drill-down

The explorer of Lesson 6, now in the app

The second tab ranks the groups of the frozen report or of the live view, lets a click on a bar descend the hierarchy set › rarity › card, and checks every view against the cube.

Files

views/app.py (tab "Ranking and drill-down").

Review before moving on
  • Is the September ranking by set led by ME: Ascended Heroes at US$ 1,049.08?
  • Does a click on the bar open its 9 rarities, and does "All sets" roll back?
  • Does the check say that the bars agree with gold.agg_price_cube?
Prompt 03 · CREATE
[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.
Step 03 · Theory
A click that changes the state of the app

The selection of a bar arrives after the checkboxes were drawn, and a widget cannot change once it exists in the run. The click is therefore stored as a pending change, the script runs again, and the change is applied at the top, before the widgets.

views/app.py · the drill-down
if "pending" in state:                 # applied before the widgets
    state.path, dims_next = state.pop("pending")
    for d in DIMENSIONS:
        state[f"dim_{d}"] = d in dims_next
...
event = st.altair_chart(chart, on_select="rerun",
                        key=f"bars_..._{len(state.path)}")
picked = event.selection.get("pick")
if picked:                             # one level down
    state.pending = (state.path + [("set_name", ...)], ["rarity"])
    st.rerun()
The key of the chart

The depth of the path is part of the key, so the chart of the new level starts without the selection of the previous one, which would otherwise fire again.

The check with the cube

Grouping by set rolls up rarity and variant, so the cube answers at grouping_id 2 + 1 = 3. The cube has no card, and a view by card has no check.

Step 03 · Result
From the set to the rarity in one click

The frozen report of September, highest market price. The first level ranks the five sets that had prices on that capture; a click on ME: Ascended Heroes groups its cards by rarity, and both levels agree with the cube.

report.mv_card_price_2026_09 · by set · grouping_id 3, 5 cells, agree
ME: Ascended Heroes1,049.08
ME: 30th Celebration1,000.00
ME05: Pitch Black198.62
ME04: Chaos Rising180.57
ME03: Perfect Order128.25
Set: ME: Ascended Heroes · by rarity · grouping_id 1, 9 cells, agree
Special Illustration Rare1,049.08
Mega Hyper Rare386.71
Illustration Rare72.07
Mega Attack Rare55.34
Double Rare6.61
Ultra Rare6.45
Rare3.92
Uncommon1.53
Common1.06
The same number as Lessons 6 and 7The Special Illustration Rare at US$ 1,049.08 is the Pikachu ex 276/217, frozen in September. The bars above were drawn from the output of the app, in the same ink and accent that the app uses.

Step 04 · 0:50 · Time and accessibility

Prices over time, and a review for every reader

The last tab draws the prices over the captures with one series highlighted, converts the Unix time to a calendar day in UTC, and the step ends with an accessibility pass on the three tabs and a test of the whole app.

Files

views/app.py (tab "Prices over time"), tests/test_app.py.

Review before moving on
  • Is a capture at 1788220800 drawn on 01/09/2026, not on 31/08?
  • Does every chart have an alt text, a table view and a sentence?
  • Do the 22 tests pass, the test of the app included?
Prompt 04 · CREATE
[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.
Step 04 · Theory
The time zone moves a capture to the day before

The warehouse keeps every date as Unix time in UTC. A browser in São Paulo formats a date in local time unless told otherwise, and 00:00 UTC becomes 21:00 of the previous day, so the September capture would be drawn in August.

the conversion happens only when drawing
hist["day"] = pd.to_datetime(hist["captured_at"],
                             unit="s", utc=True)
x = alt.X("day:T", title="Capture (UTC)",
          scale=alt.Scale(type="utc"),
          axis=alt.Axis(format="%d/%m/%Y"))
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
The highlighted seriesME: 30th Celebration went from US$ 1,349.93 to US$ 12,403.41 of market value between 01/09/2026 and 07/11/2026, and on the last capture it holds 65.3% of the value of the seven sets. The other six sets stay as grey lines.
Step 04 · Accessibility and ethics
A chart that every reader can read, and that does not mislead

Accessibility asks whether a person who cannot see a colour, uses a screen reader or reads on a small screen gets the same conclusion. Ethics asks whether the conclusion is the one the data supports.

AccessibilityIn the app
meaning never in colour alonestatus written in the box; names at the end of the line
alternative textalt= on every Altair and Graphviz chart
the data behind the charta "Table view" under every figure
contrasttext in #2e2640 on white, 14.6:1
one conclusion per viewa sentence with the number above the chart
EthicsIn the app
the scale starts at zeroevery bar chart
source and date declaredtable and capture in UTC under each chart
the period is not chosen to persuadeevery capture is drawn
a set released on 16/09/2026its jump is the launch, not appreciation
the check is visiblethe agreement with the cube and the SQL
Step 04 · Tests
Testing an app without opening a browser

The queries are tested alone, over the fake warehouse of Lesson 7, and the whole app runs inside AppTest, which executes the script as Streamlit would and exposes its widgets. The 22 tests take about ten seconds.

TestWhat it proves
test_the_connection_of_the_app_cannot_writethe view layer is read-only
test_lineage_reads_the_catalogue_and_the_comment_of_the_frozen_tablethe infographic comes from metadata
test_explorer_drills_down_and_agrees_with_the_cubethe bars and the cube give the same numbers
test_explorer_refuses_anything_outside_its_lists (4 cases)no dimension or measure 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, shows the metrics and reruns on a click
the 9 tests of Lesson 7the pipeline still works
1:00 · Second hour · groups
An app for the DataApp of the partner

Each group adds a Streamlit app to the DataApp of the partner, in the views layer and in the same pattern, with prompt 05: the queries tested alone, a tab that explains the DataApp and two analytical views that answer questions of the partner.

What to build
  • a module of query functions over a read-only connection
  • a tab with the size of the model, the last run and the lineage
  • two views opened by a sentence, one of them with drill-down
  • the theme of the Inteli palette and dates in UTC
What to review before showing
  • one y axis, one accent colour, bars from zero
  • alt text, table view and SQL under every chart
  • credentials of ClickHouse only in environment variables
  • tests of the queries, and one AppTest
Next sessionLesson 12 estimates how much this DataApp, its pipeline and its app would cost to run in the cloud, and compares the configurations that would serve the partner.
Self-study
Self-study for this session

Readings and videos assigned on Adalove for this week, on chart types and on building data apps in Streamlit, with the reading material of the session.

Reading material

Lesson 11 material

Chart selection, the execution model of Streamlit, the technical infographic, drill-down, time zones, accessibility and ethics, with the numbers of the rehearsal.

this module· 45 min

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