A full-stack python reactive web components framework
Project description
Basis: Full-Stack Reactive Python Framework
Basis is an experimental full-stack web framework for building interactive, stateful web applications entirely in Python. It runs FastAPI on the server for initial Server-Side Rendering (SSR) and PyScript in the browser for Client-Side Hydration (CSH), providing a reactive, component-based developer experience with no JavaScript.
Quickstart
1. Installation
Install the framework alongside FastAPI and Uvicorn:
pip install fastapi uvicorn basis-framework
2. Create a minimal Basis App (app.py)
from basis.shared.component import Basis, Component
app = Basis()
@app.entrypoint
class HelloBasis(Component):
"""
<div><input bind="{name}" placeholder="Type your name..." />Hello {name}!</div>
"""
name = "World"
3. Run the Development Server
uvicorn app:app --reload
Navigate to http://localhost:8000 to interact with the application.
Core Philosophy
- Python Everywhere — Write backend services, business logic, component templates, and client-side reactive state in pure Python.
- Native Custom Elements — Components map to standard hyphenated HTML custom tags, keeping styling and markup aligned with web standards.
- Fine-Grained Reactivity — No Virtual DOM. Basis uses a Directed Acyclic Graph (DAG) to track dependencies and update only the targeted DOM nodes when state changes.
- Isomorphic Hydration — Server renders fully-formed, SEO-friendly HTML, which the client hydrates in-place without flashes of unstyled content or layout shifts.
Key Features
1. DAG-Based Reactivity
Basis manages state propagation using a Directed Acyclic Graph (DAG) with three node types:
StateNode: The root state sources (raw component attributes).ComputedNode: Derived values that cache results and recalculate only when their upstream dependencies change.EffectNode: Leaves of the graph representing DOM updates (bindings) that react to state or computed mutations.
2. Computed Properties
Use the @computed decorator to define derived state. Basis parses the function's Abstract Syntax Tree (AST) to automatically detect dependency attributes:
@computed
def full_name(self):
return f"{self.first_name} {self.last_name}"
3. Smart Keyed Reconciliation
The SmartKeyedLoopBinding uses a Longest Increasing Subsequence (LIS) algorithm to dynamically reorder and update DOM list items in-place. This preserves browser input focus, scroll position, and CSS animations during list sorting or updates.
4. Cross-Boundary References
The template braces syntax supports special prefixes to bind reactive state across boundaries:
$store_name.field: Subscribes directly to a shared, globalStoreinstance.#component_id.field: Subscribes to the attribute of another component in the DOM by its HTMLid.
<p>Store Value: {$session.count}</p>
<child-comp id="child"></child-comp>
<p>Child status: {#child.status}</p>
Codebase Structure
The framework codebase is structured as follows:
basis/src/basis/shared/dag.py— The reactive dependency graph engine.basis/src/basis/shared/bindings.py— DOM bindings (Text, Attribute, Loops, Slots).basis/src/basis/shared/base_component.py— Base component lifecycle, state mapping, and setup.basis/src/basis/client/— Browser-side component mounting and PyScript entrypoint.basis/src/basis/server/— FastAPI application wrapper, static file servers, and RPC router.
Documentation
For a comprehensive guide, architecture diagrams, and detailed API breakdowns of stores, bindings, and hydration, browse the files in the docs/ directory starting with docs/index.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file basis_framework-0.1.0.tar.gz.
File metadata
- Download URL: basis_framework-0.1.0.tar.gz
- Upload date:
- Size: 7.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
638a39de2501fa90ddf2833cc50f1f64862653c7c704b6ff515ac25899d60993
|
|
| MD5 |
c4d30a6899e9f7f32eef4d874c880171
|
|
| BLAKE2b-256 |
4e5ac84c76b10c943aae8fce21eab740a89d6a3f5be8df0c3e70c58badd00411
|
Provenance
The following attestation bundles were made for basis_framework-0.1.0.tar.gz:
Publisher:
publish.yml on bassio/basis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
basis_framework-0.1.0.tar.gz -
Subject digest:
638a39de2501fa90ddf2833cc50f1f64862653c7c704b6ff515ac25899d60993 - Sigstore transparency entry: 1707373765
- Sigstore integration time:
-
Permalink:
bassio/basis@eccd02df3149690bd95c8b0a32b4c5effeb5fdc9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bassio
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eccd02df3149690bd95c8b0a32b4c5effeb5fdc9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file basis_framework-0.1.0-py3-none-any.whl.
File metadata
- Download URL: basis_framework-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f24c48fadaca3c7c49273ea2cc7712aa9ad84caf887e34984e326b56c737e83
|
|
| MD5 |
0bc310ea520c1b3a28902c8c9c547fb6
|
|
| BLAKE2b-256 |
78064403cd0a875dc395761ef54f631e881492e5d7e5e21b68f62f1802e84b85
|
Provenance
The following attestation bundles were made for basis_framework-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on bassio/basis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
basis_framework-0.1.0-py3-none-any.whl -
Subject digest:
8f24c48fadaca3c7c49273ea2cc7712aa9ad84caf887e34984e326b56c737e83 - Sigstore transparency entry: 1707373796
- Sigstore integration time:
-
Permalink:
bassio/basis@eccd02df3149690bd95c8b0a32b4c5effeb5fdc9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bassio
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eccd02df3149690bd95c8b0a32b4c5effeb5fdc9 -
Trigger Event:
release
-
Statement type: