v1.7.5Data EngineBSD-2-Clause

Define your data schema once in pure C and get instant full-text search, filtering, sorting, pagination, and row validation without SQL overhead. Canonical header is <hyle/hyle.h>.

GitHub
git clone https://github.com/tty-pt/libhyle

hyle logo

libhyle

npm C99 BSD-2-Clause No UI / transport deps Data Kernel

Define your data schema once in pure C and get instant full-text search, filtering, sorting, pagination, and row validation without SQL overhead. Canonical header is <hyle/hyle.h>.

1. Quickstart

Register a typed data schema, insert records, and run a paginated full-text search query in under 20 lines:

#include <stdio.h>
#include <hyle/registry.h>
#include <hyle/query.h>
#include <hyle/field.h>

static const hyle_field_t song_fields[] = {
    { .name = "title", .type = HYLE_FIELD_STRING, .writable = 1, .required = 1, .searchable = 1 },
    { .name = "year",  .type = HYLE_FIELD_INT,    .writable = 1, .searchable = 1 },
};

int main(void) {
    // 1. Register data source with schema
    hyle_registry_register("song", song_fields, 2, 0, 0, NULL);

    // 2. Insert record
    const char *names[] = { "title", "year" };
    const char *values[] = { "Ain't Talkin' 'Bout Love", "1978" };
    hyle_registry_put("song", "song_1", names, values, 2);

    // 3. Query: full-text search across string fields, paginated
    hyle_query_t q = { .q = "Love", .per_page = 10 };
    hyle_row_set_t rs;
    size_t total = 0;
    if (hyle_registry_query("song", &q, &rs, &total) == 0) {
        printf("Matched %zu song(s)\n", total);
        hyle_row_set_free(&rs);
    }
    return 0;
}

Compile and link:

cc catalog_demo.c $(pkg-config --cflags --libs hyle) -o catalog_demo

2. Core API Reference

FunctionSignatureDescription
hyle_registry_registerint hyle_registry_register(name, fields, n, ...)Register source and allocate row/field stores
hyle_registry_putint hyle_registry_put(source, id, names, vals, n)Insert or update a structured row
hyle_registry_queryint hyle_registry_query(source, q, rs, &total)Run filter โ†’ sort โ†’ paginate query
hyle_parse_queryint hyle_parse_query(&q, query_str)Parse URL-encoded query string directly
hyle_purify_rowint hyle_purify_row(source, names, vals, n, errs)Enforce schema validation (types, regex, ranges)
hyle_val_to_jsonchar *hyle_val_to_json(hyle_val_t val)Serialize 16-byte tagged values to JSON

3. Field Types & Schema Attributes

Field TypeEnum ValueDescription
StringHYLE_FIELD_STRINGUTF-8 text string; tokenized for FTS when searchable = 1
IntegerHYLE_FIELD_INT64-bit signed integer; supports numeric range filters
FloatHYLE_FIELD_FLOAT64-bit IEEE double; supports numeric range filters
BooleanHYLE_FIELD_BOOLSingle-byte flag (0 or 1)
ReferenceHYLE_FIELD_REFForeign key referencing another dataset's primary key
BlobHYLE_FIELD_BLOBRaw opaque binary data with length prefix

Attributes: .required = 1 (must be present on write), .writable = 1 (editable by user), .searchable = 1 (lexically indexed for q= queries), .search_weight = N (optional custom field relevance multiplier for search ranking; primary display fields title, name, id automatically receive boosted precision tiers).

Design System Styles: htdocs/hyle.css provides canonical stylesheet rules for Hyle data tables, filters, forms, and pickers.


4. Query String Grammar (hyle_parse_query)

libhyle parses URL query strings directly into typed query structs:

ParameterExampleBehavior
q?q=loveLexical full-text search across all searchable string fields
filter_<field>?filter_year=1978Exact-match equality filter on a specific field
sort?sort=yearSchema field name to order results by
order?order=descOrdering direction: asc or desc (default: asc)
page / per_page?page=2&per_page=201-based page number and page size

5. Installation & Build

Prebuilt Packages

Prebuilt packages are distributed on tty.pt for Linux (APT / Alpine / Arch / Fedora-RHEL), macOS (Homebrew), Windows (winget / MSYS2), and OpenBSD, and mobile static sysroots for Android (https://tty.pt/android/ โ€” arm64-v8a, armeabi-v7a, x86_64) and iOS (https://tty.pt/ios/ โ€” libhyle.xcframework). Follow the installation instructions and use libhyle as the package name.

Build from Source

Building from source requires libstele (for <ttypt/iso_json.h> JSON value parsing and the shared ttypt/include.mk build rules), libcorm, and liblemma:

make                  # builds lib/libhyle.so and lib/libhyle.a
make test             # run unit, query, and validation tests
sudo make install     # install headers, library, hyle.css, and hyle.pc to system

6. JavaScript & WebAssembly Bindings (@tty-pt/hyle)

Official Node.js and Browser WebAssembly bindings are colocated in npm/:

  • TypeScript-First Schemas: Author schemas in natural TypeScript with defineSchema without touching C, executing through the C99 hyle_purify_row engine under the hood.
  • Framework-Agnostic Reactive Form Controller: Instant keystroke validation with dirty/validity state tracking for vanilla DOM, React, Svelte, or Vue.
  • CLI Codegen (hyle-to-ts): Automatically generate exact TypeScript interfaces from shared JSON/C schemas.
  • C Development Headers: Install via npm install @tty-pt/hyle (from npm or https://tty.pt/npm/) and consume headers from node_modules/@tty-pt/hyle/include.

๐Ÿ‘‰ For complete TypeScript usage, reactive form guides, and API reference, see npm/README.md.

License

BSD 2-Clause License. Copyright (c) 2025, tty-pt. See LICENSE.

Maintained by:tty-pt