Application Architecture
Unified C11 Application Harness (<bark/app_main.h>)
Include <bark/bark.h> and <bark/app_main.h> once in your entry file and wire your lifecycle hooks with BARK_APP_DEFINE():
#include <bark/bark.h>
#include <bark/app_main.h>
static int on_init(bark_app_ctx_t *ctx) {
/* Initialize state, view, and networking using ctx->origin and ctx->ticket */
return 0;
}
static void on_ticket(bark_app_ctx_t *ctx, const char *ticket, size_t len) {
/* Attach the active X-Bark-Ticket to backend API requests */
}
static const bark_app_hooks_t g_hooks = {
.default_origin = "https://api.example.com",
.clear_color = 0x111318u,
.fps = 60u,
.init = on_init,
.on_ticket = on_ticket,
};
BARK_APP_DEFINE(g_hooks)
The exact same translation unit compiles into:
- A protected native desktop package (
make all) - A protected browser WebAssembly package (
make all)
Split Capability Slices
Applications that separate a public login gate from authenticated workspace features can declare a split slice in Makefile:
BARK_APP_NAME := myapp
BARK_APP_ID := 7001
BARK_SPLIT_SLICE := 7010:myapp_workspace:lib7:921
BARK_GATE_SRCS := core/runtime.c ui/gate.cx
BARK_SPLIT_SHARED_SRCS := core/shared.c
include ttypt/bark.mk
Register the split slice ID (7010) alongside your primary app_id (7001) in /bark/portal. Before login, only the minimal Tier-0 gate shell is decrypted. After your backend mints a user token with BARK_CAP_LIB_7, call bark_app_upgrade(ctx, token) to fetch and unlock the authenticated slice live without restarting the app. On logout, call bark_app_logout(ctx) to clear credentials and revert to the Tier-0 gate.
Zero-Boilerplate Browser Shell
Serve a minimal HTML shell from your own domain (Cloudflare Pages, S3, Nginx, etc.):
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>My App</title>
</head>
<body>
<div id="bud-root"></div>
<script type="module"
src="https://tty.pt/bark/runtime/boot.js"
data-config="/api/bark-config"
data-title="My App"></script>
</body>
</html>
The Bark browser runtime fetches /api/bark-config from your backend, negotiates the lease directly with https://tty.pt/bark/lease, verifies your publisher signature, decrypts the WebAssembly package in memory, and forwards signed session tickets into your application.