liveBook · Manning

Chapter 3: Taking an app from concept to code

What you will learn in chapter 3 of Build Python Web Apps with Streamlit

This chapter introduces planning and design as essential work and previews an end-to-end process for turning an app concept into Streamlit code.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This chapter introduces planning and design as essential work and previews an end-to-end process for turning an app concept into Streamlit code.

Key terms: planning, design, end-to-end experience, real-world app development, app concept, requirements, user experience, code organization, logic, Streamlit widgets

3.1 Concept to code: A six-step process

This section introduces a scalable six-step workflow for turning an app idea into working code without jumping straight into implementation.

Key terms: state the concept, define the requirements, visualize the user experience, brainstorm implementation, write code, iterate, concept, requirements, scope, what the app will do

3.2 Stating our concept: A unit converter

This section states the unit-converter app’s concise concept and explains why a clear, revisable concept guides development and communication.

Key terms: concept, Streamlit app, units of measurement, stating the concept, core, one-line description

3.3 Defining the requirements

This section turns the unit-converter concept into stakeholder-focused, technology-agnostic requirements that guide its design and implementation.

Key terms: requirements, stakeholders, implementation language, numeric quantity, from-unit, to-unit, imperial, metric, developer, maintainer

3.3.1 Defining what the app won’t do

This section defines the unit converter’s out-of-scope features and explains how explicit scope supports prioritization, future phasing, and stakeholder discussion.

Key terms: requirements, scope, out of scope, stakeholders, usage tracking, logging, visualizations, constant conversion factor, currencies, exchange rate

3.4 Visualizing the user experience

This section introduces designing an app by working backward from the intended user experience before implementing it.

Key terms: user experience, working backwards, end-product quality, user needs, user preferences, usability problems, components, design, hardest part of the problem

3.4.1 Creating a mock

This subsection creates a preliminary user-interface mock-up for the unit converter and uses it to prioritize the desired user experience before implementation details.

Key terms: mock-up, UI, unit category selector, select box, Convert button, drop-down menus, user experience, UI design, Streamlit, implementation

3.5 Brainstorming the implementation

This section begins implementation planning by identifying the app’s frontend and backend and how information moves between them.

Key terms: brainstorming the implementation, flow of thinking, solution, frontend, backend, inputs, outputs, UI, Streamlit elements, unit conversion

3.5.1 Converting units

This section derives a scalable method for converting between units by storing each unit’s factor to a shared standard unit.

Key terms: conversion factor, reverse conversion factor, X-to-Y conversion factor, standard unit, standard intermediate unit, X-to-S conversion factor, Y-to-S conversion factor, conversion factors

3.5.2 Tracking units and conversion factors

This section explains how to make the unit converter easy to maintain by centralizing unit definitions and conversion factors in one configuration file.

Key terms: non-user requirement, maintenance, adding new units, master list, configuration file, quantities, units, conversion factors, hard-coded, UI code

3.5.3 Mapping the flow of logic

This section maps how configuration, frontend controls, and backend conversion logic work together in the unit converter app.

Key terms: configuration file, quantity-selector radio buttons, From Unit, To Unit, drop down menus, Convert button, frontend, backend, conversion factors, two-step conversion

3.6 Writing code

This section introduces the implementation sequence for the unit converter: build a dummy Streamlit frontend, implement a contract-driven backend, and connect the two.

Key terms: dummy frontend, backend, logic flow, frontend, wiring up, Streamlit widgets, UI, contract, API, backend calls

3.6.1 Implementing the frontend

This section builds the Unit Converter’s nonfunctional Streamlit frontend incrementally, capturing user choices and arranging them to match the UI mock.

Key terms: frontend.py, streamlit run, Rerun, Always Rerun, hardcoding, backend, st.radio, st.text_input, float, st.selectbox

3.6.2 Implementing the backend

This section models unit-conversion configuration with dataclasses and implements a separated backend API for listing quantities and units and converting values.

Key terms: Unit, Quantity, unit_config, std_unit, value_in_std_units, dataclass, separation of concerns, API, frontend, backend

3.6.3 Wiring up the frontend and backend

This section connects the Unit Converter frontend to backend functions so widget choices are dynamic, conversion runs on demand, and results appear as side-by-side metrics.

Key terms: list_quantities, list_units, quantity selector, From unit, To unit, convert_value, Result, from_value, to_value, from_unit

3.7 Iterating on the app

This section introduces post-launch iteration, using user feedback to identify and improve usability issues in a working app.

Key terms: user feedback, usability problems, blind spots, iteration

3.7.1 Rounding conversion results

This section improves the Unit Converter’s result display by formatting large numbers and making result rounding an optional user-controlled feature.

Key terms: format_value, decimal_places, is_rounded, round, format, from_display, st.number_input, value, min_value, step

3.7.2 Getting rid of the button

This subsection simplifies the unit converter by removing its Convert button so results update immediately as inputs change, reinforcing the value of iterative user-experience refinement.

Key terms: Convert button, st.button, frontend.py, conversion, inputs, decimal places, rounded output, requirements, user experience, stakeholders

3.8 Summary

This summary recaps a six-step process for turning a Streamlit app concept into a working, iteratively improved app, along with key design and UI-building practices.

Where this is used later

Concepts explained in this chapter

← Chapter 2: Getting started with Streamlit Chapter 4: Streamlit’s execution model →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.