In this lesson
A dashboard that leads to an action.
A good dashboard is not the one with the most charts. It is the one that leads someone to act. Here you build a dashboard with Streamlit, a Python library that turns a script into a web page. AI helps in three places, but the decision stays with a person.
- Give each chart a question and an action
- Understand how Streamlit uses cache and state
- Publish behind a login, without exposing data
Question, action and comparison
Every element on the dashboard has to answer a question and trigger an action. If it triggers nothing, it leaves the screen. "How many items have been waiting for a person for more than 24 hours?" triggers "reassign someone". "How many emails came in this week?" on its own triggers nothing.
Every number needs a comparison: the previous period, a target or the median of the last few weeks. A number on its own is decoration.
Streamlit: the script runs again
On every click on a filter, the whole script runs again, from top to bottom. So whatever is expensive to compute needs a cache, a memory kept between runs. Every cache should have an expiry time, the ttl. Without it, an old query can stay on the screen for hours.
What each person chose, such as the period, lives in st.session_state. Each tab has its own session. The common mistake is to keep the choice in a global variable: it is shared by everyone, and one person's screen changes another's.
Read-only data
The dashboard reads the queue and never writes to it. In SQLite, open the database with an address that ends in mode=ro. Any attempt to write fails, and a bug in the dashboard cannot corrupt the queue. The query brings only the columns the screen uses: the email text, with personal data, never even reaches the dashboard.
The queue saves the time in UTC, and the dashboard shows Brasília time, Brazil's official time. If you do not convert before grouping, the items from 9:00 p.m. to 11:59 p.m. fall on the next day.
AI in three places
The AI never adds, counts or decides on its own. The code calculates what is exact.
- The columns: category and confidence were saved by the triage. The dashboard only aggregates.
- The explanation: the code calculates the totals, and the AI writes a short text from them. The code checks whether each number mentioned exists in the input. No made-up causes: when it does not know, the AI asks questions.
- The alert: a simple rule compares each day with the median of the previous 28. If the deviation goes above three, the day is flagged, and the person decides whether it is an incident or bad data.
What the pros know
Logging in is not the same as having permission. The Streamlit documentation says that OpenID Connect supports authentication, but not authorization. In other words: the Google account proves who the person is, but what decides who can see the dashboard is your list of allowed emails. People who publish dashboards for real build all four layers: a server listening only on the local address, a proxy with HTTPS in front, a login and an allowlist. Skipping the last one leaves the data open to anyone with an account.
LGPD: show only the aggregate
A dashboard with data from customer emails handles personal data under the LGPD, Brazil's data protection law, even without a name. A line such as "refund of 1,200 reais on October 14" can identify someone. Show counts, rates and medians. The detail per item stays only with whoever handles the case.
Careful
The secrets file, with the API key and the login secret, never goes into the repository. Put it in .gitignore. If a secret leaked, replace it right away.
Practice · 5 min
- List the elements on your dashboard and write the question and the action for each one. Delete the ones left without an action.
- Write the title of each chart as a question and read it out loud to someone from outside.
- Pick one number and define its comparison.
Summary
- With no question and no action, the chart goes.
- Cache with an expiry time; choices in the session, never in a global variable.
- The dashboard only reads, and shows the aggregate.
- The login shows who the person is; the allowlist says who gets in.
Sources
Read on October 30, 2026.
- Streamlit. Authentication and personalization: OIDC and authorization.
- Streamlit. Caching overview: data cache and ttl.
- Streamlit. Session State.
Lesson quiz
Three situations to apply what you learned.
Isaque Victor free courses