Skip to content

Commit

Permalink
Refactor README and app.py for clarity and additional information
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuthan committed Nov 21, 2024
1 parent 428c593 commit 4b183d7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,48 +31,48 @@ This project demonstrates how to leverage the built-in power of Streamlit using

### TODO

* Docker image
* Create Docker image
* Implement BigQuery integration tests
* More visualizations for integrated public dataset
* Integration with external OAuth provider
* Add more visualizations for integrated public dataset
* Integration with external OAuth provider, see [roadmap](https://roadmap.streamlit.app/)
* Redirect to the original page after login
* Describe load balancer strategies (sticky sessions)
* Automated dependency updates with Dependabot, see [dependabot#10039](https://github.com/dependabot/dependabot-core/issues/10039)
* More sophisticated type checking, see [mypy](https://mypy.readthedocs.io/)
* Describe load balancer strategies, for example: sticky session
* Automaticall update dependencies, see [dependabot#10039](https://github.com/dependabot/dependabot-core/issues/10039)
* Add more sophisticated type checking, see [mypy](https://mypy.readthedocs.io/)

## Modules

### `example.services`

* Service layer, business logic only
* Service layer for application logic
* Tested with Pytest and mocked infrastructure layer
* Shouldn't import Streamlit API besides `@st.cache`

### `example.infrastructure`

* Infrastructure code only, no application logic
* Infrastructure code, no application logic, no user interface
* Tested in realistic environment (Cloud, Test Containers, etc.)
* Shouldn't import Streamlit API
* Acts as anti-corruption layer, for example - expose Pandas DataFrame instead of underlying database API

### `example.ui.pages`

* Application pages
* Tested with Streamlit testing framework and mocked API layer
* Application pages, no application logic
* Tested with Streamlit testing framework and mocked service layer
* Delegate shared UI components to `example.ui.components`
* Delegate logic to `example.service`
* Delegate application logic to `example.service`

### `example.ui.components`

* Shared UI components
* Tested with Streamlit testing framework with small helper function wrappers
* Encapsulates Streamlit state management
* Tested with Streamlit testing framework with small helper wrappers

### `example.utils`

* Utility functions
* Tested within Pytest without mock
* Shouldn't import Streamlit API
* Tested within Pytest, no mocking

## Local development

Expand Down
16 changes: 15 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,26 @@ def share(path: str) -> None:
if "logged_in" not in st.session_state:
st.session_state["logged_in"] = False

about = """
This project demonstrates how to leverage the built-in power of Streamlit using best software engineering practices and tools.
It provides a non-trivial Streamlit application skeleton, showcasing how to effectively utilize Streamlit's capabilities
and address its limitations.
See [README](https://github.com/mkuthan/example-streamlit/blob/main/README.md) for more details.
"""

get_help = "https://discuss.streamlit.io/t/non-trivial-application-skeleton-from-seasoned-software-data-engineer/86072"
report_bug = "https://github.com/mkuthan/example-streamlit/issues/new"

st.set_page_config(
page_title="Streamlit Non-Trivial App",
page_icon="https://streamlit.io/images/brand/streamlit-mark-color.png",
layout="wide",
initial_sidebar_state="auto",
menu_items={"Get Help": "https://streamlit.io/"},
menu_items={
"About": about,
"Get Help": get_help,
"Report a bug": report_bug,
},
)

st.logo("https://streamlit.io/images/brand/streamlit-logo-primary-colormark-darktext.png", size="large")
Expand Down

0 comments on commit 4b183d7

Please sign in to comment.