Starlette
General Information
| Field | Value |
|---|---|
| Package Name | starlette |
| Manufacturer / Vendor | Encode OSS Ltd. (Tom Christie and contributors) |
| Software Category | Framework |
| Primary Documentation | Documentation, GitHub, PyPI |
| Programming Language(s) | Python |
| License | BSD 3-Clause License |
| Deployed Version(s) | >=0.49.0 (version-locked at 0.50.0) |
| Most Recent Available Version | 0.52.1 |
| Last Review Date | 2026-01-27 |
Overview
Starlette is a lightweight ASGI (Asynchronous Server Gateway Interface) framework/toolkit designed for building high-performance async web services in Python. It provides the foundational components for modern Python web applications, including routing, middleware, WebSocket support, and background tasks. Starlette is the underlying framework upon which FastAPI is built, inheriting its core ASGI capabilities and request/response handling.
Within the medical device software, Starlette provides essential low-level ASGI primitives that extend FastAPI's capabilities for cross-cutting concerns. It is integrated into the legithp-essentials shared library and the API gateway application, where it serves the following purposes:
- Correlation ID middleware: The
CorrelationIdMiddlewareinlegithp_essentials.correlationextends Starlette'sBaseHTTPMiddlewareto implement distributed request tracing. This middleware extracts or generates correlation IDs for each HTTP request, propagates them through the context to downstream microservices, and includes them in response headers for end-to-end request tracking across all AI expert services - API call recording middleware: The
CallRecorderMiddlewarein the API gateway uses Starlette's middleware infrastructure to intercept all requests and responses, capturing metadata for audit logging and compliance tracking - Application lifecycle management: The
Lifespantype from Starlette is used to define async context managers for managing application startup and shutdown sequences, including initialization of background sync managers for call record resilience
Starlette was selected because it is the native foundation of FastAPI (the device's primary web framework), provides a clean middleware API for implementing cross-cutting concerns without framework coupling, offers strong async/await support critical for high-throughput API operations, and uses a permissive BSD license compatible with commercial medical device software.
Functional Requirements
The following functional capabilities of this SOUP are relied upon by the medical device software.
| Requirement ID | Description | Source / Reference |
|---|---|---|
| FR-001 | Provide base class for implementing HTTP middleware with request/response lifecycle | starlette.middleware.base.BaseHTTPMiddleware |
| FR-002 | Define ASGI application type for middleware composition | starlette.types.ASGIApp |
| FR-003 | Define lifespan context manager type for application lifecycle hooks | starlette.types.Lifespan |
| FR-004 | Support async dispatch method for processing requests and responses | BaseHTTPMiddleware.dispatch() |
| FR-005 | Provide access to request headers, body, and client information | Request object properties |
| FR-006 | Enable response header modification for adding correlation IDs | Response.headers dictionary |
Performance Requirements
The following performance expectations are relevant to the medical device software.
| Requirement ID | Description | Acceptance Criteria |
|---|---|---|
| PR-001 | Middleware dispatch shall complete without blocking the event loop | No synchronous blocking operations in middleware chain |
| PR-002 | Middleware overhead shall not significantly impact API response latency | Middleware processing time < 5% of total request handling time |
| PR-003 | Memory usage shall remain stable during sustained request processing | No memory leaks during continuous middleware operation |
Hardware Requirements
The following hardware dependencies or constraints are imposed by this SOUP component.
| Requirement ID | Description | Notes / Limitations |
|---|---|---|
| HR-001 | x86-64 or ARM64 processor architecture | Pre-built wheels available for common platforms |
| HR-002 | Sufficient memory for async operations | Memory scales with concurrent request count |
Software Requirements
The following software dependencies and environmental assumptions are required by this SOUP component.
| Requirement ID | Description | Dependency / Version Constraints |
|---|---|---|
| SR-001 | Python runtime environment | Python >=3.10 |
| SR-002 | AnyIO for async abstraction layer | anyio >=3.6.2 (bundled dependency) |
| SR-003 | ASGI server for production deployment | uvicorn, hypercorn, or daphne |
| SR-004 | FastAPI integration for HTTP framework | FastAPI inherits Starlette's ASGI foundations |