How gradio-app/gradio works
Gradio lets Python developers wrap functions or ML pipelines in component-based web apps, then launch them for browser use and optionally share them. The central path is app construction, server setup, browser input/API submission, function execution, and rendered output. The tree and README establish broader capabilities such as custom Blocks layouts, built-in components, queueing, sharing, and clients; sampled source confirms route handling, pipeline adaptation, and run-history storage controls. Some runtime wiring and several documented subsystems are represented only at their enclosing source paths because their implementations were not sampled.
Main entry points: routes.py FastAPI server · blocks.py Blocks and Interface · pipelines.py Pipeline adapter · block_function.py Function runner
Components 22
App authoring
- Blocks and Interface
gradio/blocks.py - UI components
gradio/components - ChatInterface
gradio/chat_interface.py - Pipeline adapter
gradio/pipelines.py - Pipeline mappings
gradio/pipelines_utils.py
App runtime
- Browser frontend
js/app/src/routes/[...catchall]/+page.server.ts - Request proxy
js/app/proxy_routes.js - FastAPI server
gradio/routes.py - Event dispatch
gradio/events.py - Queue execution
gradio/blocks.py - Function runner
gradio/block_function.py - Cache and storage
gradio/caching.py
Clients and integrations
- Public sharing service
- Python client
client/python/gradio_client/client.py - JavaScript client
client/js/src/client.ts
History and state
- History controls
js/core/src/api_docs/HistoryStorageControl.svelte - Run history API
gradio/routes.py - Run history state
gradio/routes.py
Other components
- App developer
- App user
- App function or model
- Hugging Face bucket
Connections 25
- App developer → Blocks and Interface: defines app
- App developer → UI components: selects components
- Blocks and Interface → UI components: configures UI
- App developer → ChatInterface: defines chat
- App developer → Pipeline adapter: adapts pipeline
- Pipeline adapter → Pipeline mappings: loads mappings
- Pipeline adapter → App function or model: invokes pipeline
- Blocks and Interface → FastAPI server: launches app
- App user → Browser frontend: opens app
- Browser frontend → FastAPI server: loads config
- App user → Request proxy: submits input
- Request proxy → FastAPI server: routes API
- FastAPI server → Event dispatch: dispatches event
- Event dispatch → Queue execution: enqueues work
- Queue execution → Function runner: runs event
- Function runner → App function or model: calls function
- Function runner → UI components: formats outputs
- FastAPI server → Browser frontend: returns response
- Blocks and Interface → Public sharing service: creates public link
- Python client → FastAPI server: calls endpoints
- JavaScript client → FastAPI server: calls endpoints
- History controls → JavaScript client: manages storage
- History controls → Run history API: requests history
- Run history API → Run history state: reads and writes
- JavaScript client → Hugging Face bucket: connects bucket