Architecture

How the pieces fit together.

System Overview

Metarium AI is a three-layer system. An AI agent talks to a local management server, which signs requests and forwards them to a cloud-hosted CMS.

+------------------------------+
|  AI Agent (Cursor / Vorflux) |
|  Reads AGENTS.md, calls API  |
|  Entry point: mai.net        |
+-------------+----------------+
              | REST (localhost:8420)
              v
+------------------------------+
|  Management Server           |  <- Root of Trust
|  (FastAPI, local only)       |
|  - Key Vault (Substrate)     |
|  - Canonical JSON signing    |
|  - Admin/access orchestration|
+-------------+----------------+
              | Signed HTTPS
              v
+------------------------------+
|  Metarium CMS-AE             |  <- Cloud Data Layer
|  (Flask on App Engine)       |
|  - Google Datastore (NDB)    |
|  - Google Cloud Storage      |
|  - Signature verification    |
+------------------------------+

Management Server

The management server is a FastAPI application on localhost:8420 — the root of trust for the entire system.

Key Vault

Password-protected, thread-safe, in-memory Substrate key store.

CMS App Engine

The cloud data layer — a Flask app on Google App Engine that stores and serves content with cryptographic verification.

The CMS never holds private keys — it only verifies signatures. Clear separation between authority (local) and data (cloud).

Security Model

Localhost Binding

Server only binds to 127.0.0.1. Only local processes can communicate with it.

Encrypted Keys at Rest

PolkadotJS format with Argon2id. Useless without the password even if exposed.

Password Never Stored

Used to derive a decryption key, then immediately discarded. Never in logs, config, or env vars.

Canonical JSON Signing

Deterministic serialization ensures reproducible signatures. CMS verifies against admin key registry.

API Reference

For interactive docs, visit http://localhost:8420/docs when the server is running. Use GET /help at runtime to discover operations.

EndpointMethodDescription
/healthGETHealth check — test connectivity
/statusGETVault lock state and loaded key count
/helpGETAll available operations with descriptions
/vault/unlockPOSTUnlock the key vault with password
/vault/lockPOSTLock vault, clear keys from memory
/keys/listGETList keypairs (public keys only)
/keys/generatePOSTGenerate new Substrate keypair
/keys/rotatePOSTRotate keypair — new key, deprecate old
/cms/signPOSTSign message with canonical JSON
/apps/cms/installPOSTInstall and configure CMS-AE instance
/apps/cms/admin/grantPOSTGrant admin privileges to a key
/apps/cms/access/grantPOSTGrant channel access to a key
/apps/cms/access/revokePOSTRevoke access from a key