Write a source plugin
A source brings data in from a service or a file. You describe its tables and how to fetch them; loading, schema and picking up where the last sync stopped are handled for you.
- Make the packageA folder under plugins/sources/myapi, and a pyproject.toml whose shenas.sources entry point names your source class.
pyproject.toml [project] name = "shenas-source-myapi" dependencies = ["dlt[duckdb]>=1.24.0", "shenas-source-core"] [project.entry-points."shenas.sources"] myapi = "shenas_sources.myapi.source:MyApiSource"
- Describe your tablesOne class per table, extending EventTable, with its columns and units. Its extract method yields rows from your client; schema and incremental loading are handled for you.
tables.py from shenas_sources.core.table import EventTable, Field from typing import Annotated, Any, Iterator class Activities(EventTable): class _Meta: name = "activities" display_name = "Activities" pk = ("id",) id: Annotated[str, Field(db_type="VARCHAR")] = "" name: Annotated[str, Field(db_type="VARCHAR")] = "" duration_s: Annotated[int, Field(db_type="INTEGER", unit="s")] = 0 time_at: Annotated[str, Field(db_type="TIMESTAMP")] = "" @classmethod def extract(cls, client: Any, **ctx) -> Iterator[dict]: yield from client.get_activities() - Write the sourceTwo methods: build_client makes the client from your stored settings, and resources returns the tables.
source.py from shenas_sources.core.source import Source class MyApiSource(Source): name = "myapi" display_name = "My API" primary_table = "activities" def build_client(self): return MyApiClient(self.get_config_value("api_key")) def resources(self, client): from .tables import TABLES return [t.to_resource(client) for t in TABLES] - Install and syncuv sync installs it alongside the rest; the first sync pulls a batch into your local database, ready for transforms and screens.
sync.sh mkdir -p plugins/sources/myapi/shenas_sources/myapi cd plugins/sources/myapi uv sync # installs your plugin as a workspace member shenasctl source myapi sync
Other kinds
TransformsTurn what came in into shared measures, or write a kind of your own.SQL, geofence, geocode, regex extract, LLM categorize
SurfacesScreens: charts, tables, timelines, anything visual.Lit web components, Arrow IPC
DatasetsThe shared tables transforms write into, such as daily HRV, transactions or events.Python dataclasses
FrontendThe shell around everything is a plugin too: write your own or extend the default.
ThemeStyles everything at once: a stylesheet and a small class.CSS custom properties
AnalysisWays of testing a hypothesis: the operations it may use and how it chooses them.operation vocabulary, recipe strategy