Skip to content

Add Litestar adapter #6

@fsecada01

Description

@fsecada01

Overview

Add a first-class Litestar adapter to component-framework, giving Litestar users the same ergonomics as the existing FastAPI and Django adapters.

Background

FastAPI and Django adapters ship today. Flask (#5) and Litestar (this issue) were identified as gap in #4 during the 0.3.0 dependency refactor.

Required Components

1. Optional Extras Group

Add a [litestar] optional extras group in pyproject.toml:

[project.optional-dependencies]
litestar = ["litestar>=2.0"]

2. Adapter Module (adapters/litestar.py)

  • LitestarRenderer subclass of Renderer using Litestar's template engine
  • HTTP endpoint handler (mirrors adapters/fastapi.py structure)
  • ImportError guard at module top using _require_extra("litestar", "litestar")

3. Optional WebSocket Handler (adapters/litestar_websocket.py)

  • Async WebSocket consumer following the FastAPI WebSocket adapter pattern
  • ImportError guard advertising [litestar] extra

4. Test File (tests/test_litestar_adapter.py)

  • pytest.importorskip("litestar", ...) skip guard
  • Adapter-level tests mirroring test_fastapi_adapter.py

5. Documentation

  • Add Litestar to the Adapter Support table in README.md
  • Add install instructions: pip install "component-framework[litestar]"
  • Add example in examples/litestar_example.py

Constitution Adapter Contract

Per the project constitution (Adapter Contract principle), this adapter must:

  • Live entirely in adapters/ — zero changes to core/
  • Ship with its own optional extras group
  • Have ImportError guards with actionable messages
  • Be covered by its own CI isolation matrix row

Reference

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions