# shivtejpatil2807/streamlit-cookbook architecture

> Architecture diagram of the GitHub repository shivtejpatil2807/streamlit-cookbook, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shivtejpatil2807/streamlit-cookbook
- Repository: https://github.com/shivtejpatil2807/streamlit-cookbook

## Overview

#### Purpose and Entrypoints
This repository contains two independent Streamlit applications: a multipage Streamlit cookbook and a standalone number-guessing game. Run the cookbook with `streamlit run Home.py`; run the game with `streamlit run game.py`. Both execute in Streamlit’s Python runtime and render directly in the browser.

Paths: `Home.py`, `game.py`, `requirements.txt`

#### Cookbook Shell and Navigation
`Home.py` is the cookbook landing page and topic index. Streamlit automatically discovers Python files in `pages/` and exposes them as ordered sidebar navigation entries; numeric filename prefixes define their order. There is no separate router or frontend layer.

Paths: `Home.py`, `pages/01_Text_and_Markdown.py`, `pages/13_Navigation.py`

#### Topic-Page Demonstration Model
Each topic page is a self-contained executable lesson: it presents Streamlit API usage, displays the associated code, and renders its live output. Pages are intentionally isolated so learners can run and inspect one capability at a time rather than sharing a domain model.

Paths: `pages/02_Input_Widgets.py`, `pages/04_Data_Display.py`, `pages/05_Charts.py`

#### Interaction and Rerun Boundary
Streamlit widgets drive control flow by returning current values during a full top-to-bottom rerun of the active script. Input, layouts, file/media handling, status feedback, and forms are demonstrated as direct Streamlit calls rather than through a client-side application layer.

Paths: `pages/03_Layouts.py`, `pages/06_File_Handling.py`, `pages/08_Status_and_Messages.py`

#### Stateful and Deferred-Execution Patterns
The cookbook explicitly covers Streamlit mechanisms that cross rerun boundaries: `st.session_state` retains per-session values, forms batch input until submit, and cache decorators avoid repeated data/resource initialization. Authentication is presented through Streamlit/session-state patterns.

Paths: `pages/09_Session_State.py`, `pages/10_Forms.py`, `pages/11_Caching.py`

#### Chat and Authentication Examples
Later tutorial stages cover conversational UI primitives and login behavior. These are examples within the cookbook, not evidence of a shared authentication service or backend identity provider.

Paths: `pages/12_Chat_Elements.py`, `pages/14_Authentication.py`

#### Guess Game Flow
`game.py` is a separate interactive, multi-stage game. A player supplies a username, then progresses through random-number guessing and randomized pattern challenges. Session state maintains game progress across Streamlit reruns; completion reaches success, while failed stages reach game-over/restart paths. Game logic has dedicated test coverage.

Paths: `game.py`, `tests/test_game_logic.py`

#### Infrastructure and External Services
The material runtime is Python plus Streamlit, with dependencies declared in `requirements.txt`. Local hosting is Streamlit’s development server (normally port 8501). The README links deployed instances on Streamlit Community Cloud; no database, persistence layer, API service, or external authentication provider is represented in the file tree.

Paths: `requirements.txt`, `.devcontainer/devcontainer.json`

Main entry points: [`pages/13_Navigation.py`](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/13_Navigation.py) (Page discovery), [`game.py`](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/game.py) (Guess game), [`Home.py`](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/Home.py) (Cookbook home), [`pages/02_Input_Widgets.py`](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/02_Input_Widgets.py) (Input widgets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cookbook["Cookbook tutorial"]
  node_cookbook_home["Cookbook home<br/>Streamlit entrypoint<br/>[Home.py]"]
  node_auto_navigation["Page discovery<br/>Streamlit navigation<br/>[13_Navigation.py]"]
  node_text_lesson["Text and Markdown<br/>lesson page"]
  node_input_lesson["Input widgets<br/>lesson page"]
  node_layout_lesson["Layouts<br/>lesson page<br/>[03_Layouts.py]"]
  node_data_lesson["Data display<br/>lesson page<br/>[04_Data_Display.py]"]
  node_charts_lesson["Charts<br/>lesson page<br/>[05_Charts.py]"]
  node_file_lesson["File and media handling<br/>lesson page"]
  node_status_lesson["Status and messages<br/>lesson page"]
  node_state_patterns["Stateful patterns<br/>lesson pages"]
  node_chat_lesson["Chat elements<br/>lesson page"]
  node_auth_lesson["Authentication example<br/>lesson page"]
end

subgraph group_game["Guessing game"]
  node_game_entry["Guess game<br/>Streamlit entrypoint<br/>[game.py]"]
  node_game_session["Game session state<br/>Streamlit session state<br/>[game.py]"]
  node_game_stages["Random challenge stages<br/>game flow<br/>[game.py]"]
end

node_requirements["Dependencies<br/>Python packages<br/>[requirements.txt]"]
node_streamlit{{"Streamlit runtime<br/>Python UI runtime"}}

node_requirements -->|"installs"| node_streamlit
node_streamlit -->|"runs"| node_cookbook_home
node_streamlit -->|"runs"| node_game_entry
node_cookbook_home -->|"uses"| node_auto_navigation
node_auto_navigation -->|"discovers"| node_text_lesson
node_auto_navigation -->|"discovers"| node_input_lesson
node_auto_navigation -->|"discovers"| node_layout_lesson
node_auto_navigation -->|"discovers"| node_data_lesson
node_auto_navigation -->|"discovers"| node_charts_lesson
node_auto_navigation -->|"discovers"| node_file_lesson
node_auto_navigation -->|"discovers"| node_status_lesson
node_auto_navigation -->|"discovers"| node_state_patterns
node_auto_navigation -->|"discovers"| node_chat_lesson
node_auto_navigation -->|"discovers"| node_auth_lesson
node_input_lesson -.->|"widget reruns"| node_streamlit
node_state_patterns -.->|"uses session and cache"| node_streamlit
node_game_entry -->|"maintains"| node_game_session
node_game_session -->|"drives progress"| node_game_stages
node_game_stages -.->|"reruns for next state"| node_game_entry

click node_requirements "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/requirements.txt"
click node_cookbook_home "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/Home.py"
click node_auto_navigation "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/13_Navigation.py"
click node_text_lesson "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/01_Text_and_Markdown.py"
click node_input_lesson "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/02_Input_Widgets.py"
click node_layout_lesson "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/03_Layouts.py"
click node_data_lesson "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/04_Data_Display.py"
click node_charts_lesson "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/05_Charts.py"
click node_file_lesson "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/06_File_Handling.py"
click node_status_lesson "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/08_Status_and_Messages.py"
click node_state_patterns "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/09_Session_State.py"
click node_chat_lesson "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/12_Chat_Elements.py"
click node_auth_lesson "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/14_Authentication.py"
click node_game_entry "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/game.py"
click node_game_session "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/game.py"
click node_game_stages "https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/game.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cookbook_home,node_auto_navigation,node_text_lesson,node_input_lesson,node_layout_lesson,node_data_lesson,node_charts_lesson,node_file_lesson,node_status_lesson,node_state_patterns,node_chat_lesson,node_auth_lesson toneBlue
class node_game_entry,node_game_session,node_game_stages toneAmber
class node_requirements,node_streamlit toneNeutral
```

## Components

### Cookbook tutorial

Multipage Streamlit lessons.

- [Cookbook home](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/Home.py): Streamlit entrypoint · Landing page and topic index. · `Home.py`
- [Page discovery](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/13_Navigation.py): Streamlit navigation · Discovers ordered scripts in pages/. · `pages/13_Navigation.py`
- [Text and Markdown](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/01_Text_and_Markdown.py): lesson page · `pages/01_Text_and_Markdown.py`
- [Input widgets](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/02_Input_Widgets.py): lesson page · Widgets return current values during each rerun. · `pages/02_Input_Widgets.py`
- [Layouts](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/03_Layouts.py): lesson page · `pages/03_Layouts.py`
- [Data display](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/04_Data_Display.py): lesson page · `pages/04_Data_Display.py`
- [Charts](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/05_Charts.py): lesson page · `pages/05_Charts.py`
- [File and media handling](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/06_File_Handling.py): lesson page · `pages/06_File_Handling.py`
- [Status and messages](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/08_Status_and_Messages.py): lesson page · `pages/08_Status_and_Messages.py`
- [Stateful patterns](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/09_Session_State.py): lesson pages · Session state, forms, and caching cross rerun boundaries. · `pages/09_Session_State.py`
- [Chat elements](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/12_Chat_Elements.py): lesson page · `pages/12_Chat_Elements.py`
- [Authentication example](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/pages/14_Authentication.py): lesson page · Demonstrates login behavior with Streamlit session-state patterns. · `pages/14_Authentication.py`

### Guessing game

Standalone stateful Streamlit app.

- [Guess game](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/game.py): Streamlit entrypoint · Standalone multi-stage interactive game. · `game.py`
- [Game session state](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/game.py): Streamlit session state · Retains username, progress, and restart state across reruns. · `game.py`
- [Random challenge stages](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/game.py): game flow · Number guessing and pattern challenges lead to success or restart. · `game.py`

### Other components

- [Dependencies](https://github.com/shivtejpatil2807/streamlit-cookbook/blob/main/requirements.txt): Python packages · Declares the Python and Streamlit runtime dependencies. · `requirements.txt`
- **Streamlit runtime**: Python UI runtime · Serves apps and reruns the active script on interaction.

## Connections

- Dependencies → Streamlit runtime: installs
- Streamlit runtime → Cookbook home: runs
- Streamlit runtime → Guess game: runs
- Cookbook home → Page discovery: uses
- Page discovery → Text and Markdown: discovers
- Page discovery → Input widgets: discovers
- Page discovery → Layouts: discovers
- Page discovery → Data display: discovers
- Page discovery → Charts: discovers
- Page discovery → File and media handling: discovers
- Page discovery → Status and messages: discovers
- Page discovery → Stateful patterns: discovers
- Page discovery → Chat elements: discovers
- Page discovery → Authentication example: discovers
- Input widgets → Streamlit runtime: widget reruns
- Stateful patterns → Streamlit runtime: uses session and cache
- Guess game → Game session state: maintains
- Game session state → Random challenge stages: drives progress
- Random challenge stages → Guess game: reruns for next state
