Health Universe
  • Core Concepts
    • Overview of Health Universe
    • How Health Universe Works
  • Building Apps in Health Universe
    • Getting started with Health Universe
      • Create a Health Universe Account
      • Create a Github Account
      • Link your Github Account to your Health Universe Account
    • Creating a Workspace
    • Developing your Health Universe App
      • Streamlit vs FastAPI
      • Working in Streamlit
        • Typical Project Setup
        • Your First Health Universe App
        • Streamlit Best Practices
      • Working in FastAPI
        • Typical Project Setup
        • Your First Health Universe App
        • Navigator FastAPI best practices
    • Deploying your app to Health Universe
      • Deploying to Health Universe
      • Secret Management
      • Connecting to an LLM
      • Connecting to an external data source
  • Testing your app
  • Re-deploying your app
  • Document your app
  • Deleting your App on Health Universe
  • Additional resources
    • Data Formats, Standards & Privacy
    • External Tools and Libraries
Powered by GitBook
On this page

Was this helpful?

  1. Building Apps in Health Universe
  2. Developing your Health Universe App
  3. Working in Streamlit

Streamlit Best Practices

PreviousYour First Health Universe AppNextWorking in FastAPI

Last updated 22 days ago

Was this helpful?

Streamlit is an excellent tool for rapidly prototyping healthcare and data-driven applications. It automatically generates a user-friendly interface from your Python code, allowing you to focus on functionality and logic without needing to manually design front-end elements. This makes Streamlit a great starting point when developing apps for Health Universe.

Many developers choose to start with Streamlit when building a new app because:

  • It allows for fast iteration: You can immediately visualize how inputs, outputs, and layout affect the user experience.

  • You can debug and refine your logic more easily in a visual context.

  • It supports integration with healthcare data formats like FHIR, CCDA, and CSV using native Python libraries.

Once the app’s behavior and interface are solid, developers then are able to easily migrate the codebase to FastAPI for production use with Navigator, where performance, modularity, and robust API control are priorities.

Here are some best practices to keep in mind when using Streamlit for your initial app development:

1. Organize Your Code Clearly

  • Use functions or modular components to keep the code clean and readable.

  • Separate function logic from UI logic where possible.

2. Minimize Reruns

  • Use Streamlit’s @st.cache_data, @st.cache_resource, or st.session_state to store data or avoid expensive re-computations on every input change.

  • Learn more:

3. Use Layout Features Thoughtfully

  • Leverage columns (st.columns()), expanders (st.expander()), and sidebar components (st.sidebar) for better organization.

  • Use st.markdown with custom HTML/CSS for layout tweaks when needed.

4. Make It User-Friendly

  • Add clear labels, tooltips (help=...), and default values.

  • Handle errors gracefully with st.error() or try/except blocks around sensitive logic.

5. Test with Real Data

  • Test with a variety of realistic files (e.g., FHIR JSON, CCDAs) early on to uncover edge cases and formatting issues.

Helpful Links

📚

🧪

💬

🎨

Streamlit Caching Guide
Streamlit Documentation
Cheat Sheet for Streamlit
Streamlit Community Forum
Streamlit Layout & Theming Guide