platform

module
v0.22.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: Apache-2.0

README

platform

Go Reference npm License

A multi-tenant control plane for Go services, and the packages those services are built on.

The admin server is the identity provider: tenant accounts, users, roles, invitations, API tokens, OAuth sign-in, a private PKI, and a registry of service endpoints. Services validate its tokens locally, talk to each other over NATS, and share one web console and UI kit.

go get github.com/bboxsys/platform

What's inside

Area Packages What you get
Identity admin, admin/client, user, oidctoken The admin server and its store; Auth middleware that validates tokens with no call back to the admin
Service base server, config, logger, supervisor HTTPS server with TLS, Let's Encrypt and CORS; configuration loading; structured logging; process composition
Messaging messenger, controller, natsapi NATS client, an embedded NATS server, and the HTTP API bridged over NATS with the same routes and permissions
Jobs job, worker, queue Background jobs over NATS: dispatch, queue-group workers, and a relay service with history
AI assistant ai/... Agent loop and HTTP service, Anthropic and OpenAI-compatible providers, tools from a service's OpenAPI document, retrieval, memory, MCP
Docs docsite Serve a product's documentation site behind sign-in and make it searchable by the assistant
Hosts agent, host, pki A headless host agent that registers with the admin, plus the X.509 CA that issues its certificates
Web admin/ui, ui The admin console (Vue), and @bboxsys/ui, the UI kit product consoles share

Authenticate a service

A service that only needs to check who is calling imports admin/client and nothing else:

import admin "github.com/bboxsys/platform/admin/client"

auth := admin.NewAuth(admin.AuthConfig{
    Logger:          logger,
    TrustedAccounts: trustedAccountIDs, // account public keys issued by the admin
})
router.HandleFunc("/api/v1/things", auth.Bearer(handler))

func handler(w http.ResponseWriter, r *http.Request) {
    accountID := admin.AccountIDFromContext(r.Context())
    userID := admin.UserIDFromContext(r.Context())
}

Tokens are NATS user JWTs signed by an account key. Auth verifies the signature and checks that the issuing account is trusted, so there is no shared secret and no network call per request.

Host the admin server

Run it inside your own process, or standalone as cmd/admin:

adminServer, err := admin.NewAdminServer(&server.ServerOptions{
    Component: "admin_server",
    HTTPPort:  8443,
    // TLS material, store location, SMTP and OAuth settings via Metadata
})
go adminServer.Start()

Run it locally

./run.sh                        # admin API on :8901, with an embedded NATS server and job queue
cd admin/ui && npm install && npm run dev   # admin console on http://localhost:4400
./run-agent.sh                  # optional: register and run a host agent against it

The first run seeds a test profile under ~/.config/platform-test/ with a config file, self-signed certificates and a development CA.

Documentation

Guide Covers
Developer guide Every package, with integration recipes: authentication, hosting the admin, configuration, jobs, the API over NATS
AI assistant Providers, tools, retrieval, memory, MCP, and hosting an assistant in a service
Documentation sites Embedding a Starlight site behind sign-in
OIDC API tokens API tokens that mint and renew their bearer through OIDC
UI kit @bboxsys/ui, the Vue kit for product consoles

Development

go build ./...
go test ./admin/ ./admin/client/ ./user/ ./server/ ./config/ ./logger/ ./agent/ ./job/ ./worker/ ./queue/ ./natsapi/ ./docsite/ ./ai/...
cd ui && npm install && npm run typecheck && npm test

Requires Go 1.26 and Node.js 22. Persistence is bboxsys/store, a JSON document store on BadgerDB.

License

Apache-2.0. The source is published for the projects that build on it. It is maintained by Black Box Systems and is not seeking outside contributions.

Directories

Path Synopsis
Server for Admin Service
Server for Admin Service
client
Authentication and Authorization Middleware
Authentication and Authorization Middleware
email
Package email provides outbound email delivery for the admin service.
Package email provides outbound email delivery for the admin service.
Package agent is the headless host agent: a CLI that registers a workload with a central admin server and then runs on that host, applying the configuration the server handed back and restarting itself when that configuration changes on disk.
Package agent is the headless host agent: a CLI that registers a workload with a central admin server and then runs on that host, applying the configuration the server handed back and restarting itself when that configuration changes on disk.
ai
Package ai is the platform's agent loop: a model provider, a set of tools, a session of append-only messages, and the loop that runs a prompt to completion while streaming events to the caller.
Package ai is the platform's agent loop: a model provider, a set of tools, a session of append-only messages, and the loop that runs a prompt to completion while streaming events to the caller.
anthropic
Package anthropic is the ai.Provider on the official Anthropic SDK.
Package anthropic is the ai.Provider on the official Anthropic SDK.
apitool
Package apitool turns a service's OpenAPI document into ai.Tools that call the service's own http.Handler.
Package apitool turns a service's OpenAPI document into ai.Tools that call the service's own http.Handler.
docsearch
Package docsearch gives an assistant the product's documentation: the sections of a docsite.Site as two read-only tools, {prefix}docs_search and {prefix}docs_read, and the system prompt guidance that tells the model to look there first and cite what it used.
Package docsearch gives an assistant the product's documentation: the sections of a docsite.Site as two read-only tools, {prefix}docs_search and {prefix}docs_read, and the system prompt guidance that tells the model to look there first and cite what it used.
instance
Package instance hosts one AI assistant with reasonable defaults: its own store, its own retrieval index, memory, tools generated from the host's OpenAPI document, remote MCP servers, the credential test, the documents routes, the MCP endpoint, and usage reporting.
Package instance hosts one AI assistant with reasonable defaults: its own store, its own retrieval index, memory, tools generated from the host's OpenAPI document, remote MCP servers, the credential test, the documents routes, the MCP endpoint, and usage reporting.
instance/natshost
Package natshost serves an AI instance's conversation API over NATS (package natsapi) instead of a listener, for a product service whose assistant is reached through the admin console's gateway (admin.AssistantGateway) rather than by the browser directly.
Package natshost serves an AI instance's conversation API over NATS (package natsapi) instead of a listener, for a product service whose assistant is reached through the admin console's gateway (admin.AssistantGateway) rather than by the browser directly.
instance/serverhost
Package serverhost builds an AI instance for a service on package server.
Package serverhost builds an AI instance for a service on package server.
mcp
Package mcp serves ai.Tools to MCP clients over streamable HTTP and consumes remote MCP servers as ai.Tools, on the official Go MCP SDK.
Package mcp serves ai.Tools to MCP clients over streamable HTTP and consumes remote MCP servers as ai.Tools, on the official Go MCP SDK.
memory
Package memory is the assistant's persistent memory, in two layers that are both scoped by account and user.
Package memory is the assistant's persistent memory, in two layers that are both scoped by account and user.
openai
Package openai is the ai.Provider for servers that speak the OpenAI chat completions API: Ollama's /v1 endpoints, llama.cpp's llama-server, vLLM, LM Studio, and gateways in front of them.
Package openai is the ai.Provider for servers that speak the OpenAI chat completions API: Ollama's /v1 endpoints, llama.cpp's llama-server, vLLM, LM Studio, and gateways in front of them.
rag
Package rag is retrieval over an embedded vector store.
Package rag is retrieval over an embedded vector store.
usage
Package usage records what an AI instance spends and reports it to the admin server.
Package usage records what an AI instance spends and reports it to the admin server.
Package apicontract describes a query operation once, for both the OpenAPI document a client or an assistant reads and the validation the handler applies: the required inputs, the supported filters, paging and the response schema.
Package apicontract describes a query operation once, for both the OpenAPI document a client or an assistant reads and the validation the handler applies: the required inputs, the supported filters, paging and the response schema.
cmd
admin command
Command admin runs the admin service on its own, with the admin SPA embedded when built with `-tags adminui`.
Command admin runs the admin service on its own, with the admin SPA embedded when built with `-tags adminui`.
agent command
Command agent is the unbranded build of the platform host agent.
Command agent is the unbranded build of the platform host agent.
Package docsite serves a built documentation site (Astro Starlight, or any static site laid out the same way) from an fs.FS embedded in a product binary, behind the product's own sign-in, and reads the site's pages into sections the assistant can search and cite.
Package docsite serves a built documentation site (Astro Starlight, or any static site laid out the same way) from an fs.FS embedded in a product binary, behind the product's own sign-in, and reads the site's pages into sections the assistant can search and cite.
Package job defines the unit of asynchronous work that a service hands to workers over NATS, the status a worker reports back, and the subjects the exchange runs on.
Package job defines the unit of asynchronous work that a service hands to workers over NATS, the status a worker reports back, and the subjects the exchange runs on.
Package letsencrypt provides automatic TLS certificate management via Let's Encrypt using the ACME protocol.
Package letsencrypt provides automatic TLS certificate management via Let's Encrypt using the ACME protocol.
Package logentry defines the log entry model used for centralized log collection.
Package logentry defines the log entry model used for centralized log collection.
Logging package for unified JSON logging.
Logging package for unified JSON logging.
Package natsapi carries a service's HTTP API over NATS request/reply.
Package natsapi carries a service's HTTP API over NATS request/reply.
Package oidctoken mints short-lived bearer tokens from durable OAuth 2.0 and OpenID Connect client inputs.
Package oidctoken mints short-lived bearer tokens from durable OAuth 2.0 and OpenID Connect client inputs.
oidctokentest
Package oidctokentest provides a fake OpenID provider for tests of code that mints tokens with package oidctoken.
Package oidctokentest provides a fake OpenID provider for tests of code that mints tokens with package oidctoken.
Package queue is the job relay service: it records every job request and status update in a store and republishes requests to the worker queue, so that job history survives and workers never need to see job.request.*.
Package queue is the job relay service: it records every job request and status update in a store and republishes requests to the worker queue, so that job history survives and workers never need to see job.request.*.
///////////////////////////////////////////////////////////////////// David Gurley dmgurley@gmail.com May 2019
///////////////////////////////////////////////////////////////////// David Gurley dmgurley@gmail.com May 2019
Package storemetrics defines the store metrics entry model used for centralized metrics collection.
Package storemetrics defines the store metrics entry model used for centralized metrics collection.
Package worker runs job handlers wherever a worker process is listening.
Package worker runs job handlers wherever a worker process is listening.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL