System Architecture

PromptDSL → PromptModule → PromptVault
↘ PromptRouter / PromptSig / PromptDAG → LLM
The PromptHub protocol is built on a modular, extensible architecture that reflects the lifecycle of prompts from definition to execution, storage, governance, and monetization. As an independent protocol layer and trading system, PromptHub is designed to be compatible with various model interaction standards:
┌───────────────────────────────────────────────────────────────────────────┐
│ PROMPTHUB SYSTEM ARCHITECTURE │
├───────────────┬───────────────────────┬──────────────────┬────────────────┤
│ │ │ │ │
│ PromptDSL │ PromptModule │ PromptVault │ PromptRouter │
│ (Definition) │ (Execution) │ (Storage) │ (Coordination)│
│ │ │ │ │
├───────────────┴───────────────────────┴──────────────────┴────────────────┤
│ │
│ PROTOCOL INTEGRATION LAYER │
│ (Supporting various model interaction standards) │
│ │
├───────────┬─────────────────┬────────────────────┬────────────────────────┤
│ │ │ │ │
│ LLMs │ Data │ Tool │ Applications │
│ │ Sources │ Integration │ │
│ │ │ │ │
└───────────┴─────────────────┴────────────────────┴────────────────────────┘
1. PromptDSL: Semantic Definition Layer
PromptDSL is the entry point of the system. It defines prompts as typed, structured templates that declare:
Input and output schema
Template body and embedded logic
Parameterized configuration
Dependency injection (referencing other prompt modules)
This abstraction makes prompts interoperable, testable, and reusable across different contexts and models.
// Core interfaces for PromptDSL
interface PromptDefinition {
id: string; // Unique identifier
name: string; // Human-readable name
description: string; // Description of functionality
version: string; // Semantic version (e.g., "1.2.0")
author: string; // Creator's wallet address
license: string; // License type (e.g., "CC-BY-SA")
inputs: Record<string, InputParameter>; // Input parameters schema
template: string; // The prompt template with placeholders
output_schema: OutputSchema; // Expected output structure
dependencies?: string[]; // Other modules this depends on
execution_settings?: Record<string, any>; // Model-specific parameters
}
interface InputParameter {
type: "string" | "number" | "boolean" | "array" | "object";
required?: boolean;
default?: any;
description?: string;
items?: InputParameter; // For array types
properties?: Record<string, InputParameter>; // For object types
}
2. PromptModule: Execution Interface Layer
Each prompt defined in DSL is registered as a PromptModule, serving as the standard interface for prompt execution. A PromptModule:
Exposes specific prompts as capabilities to LLMs
Provides resources and tools that can be accessed by models
Maintains consistent context and execution patterns
Enables models to interact with on-chain and off-chain data sources
interface PromptModule {
id: string;
version: string;
// Core execution method
execute(
input: Record<string, any>,
context?: ExecutionContext
): Promise<ModuleResponse>;
// Metadata retrieval
getMetadata(): PromptMetadata;
// Input validation against schema
validateInput(input: Record<string, any>): ValidationResult;
// Optional methods
getRoyaltyInfo?(): RoyaltyConfiguration;
getAccessControl?(): AccessPolicy;
}
interface ExecutionContext {
caller: string; // Caller's wallet address
modelProvider?: string; // Model provider being used
timestamp: number; // Execution timestamp
previousOutputs?: Record<string, any>; // DAG upstream outputs
requestId: string; // Unique request identifier
}
PromptModule supports multiple model interaction protocols, enabling it to function with various AI systems and model providers.
3. PromptVault: Persistence and Version Control
Once registered, prompts are published to PromptVault, a smart contract on Solana responsible for:
Canonical versioning and metadata binding
Storing IPFS references
Enforcing access licenses and token restrictions
Enabling auditability and forking transparency
// Key PromptVault operations
interface PromptVaultOperations {
// Registration
registerPrompt(
promptDSL: PromptDefinition,
licenseParams: LicenseParameters
): Promise<RegisterResponse>;
// Version management
createNewVersion(
promptId: string,
newVersion: PromptDefinition
): Promise<VersionResponse>;
// Retrieval
getPromptById(promptId: string): Promise<PromptDefinition | null>;
getPromptVersions(promptId: string): Promise<VersionInfo[]>;
// Licensing and access
updateLicense(
promptId: string,
licenseParams: LicenseParameters
): Promise<UpdateResponse>;
}
The vault maintains a secure on-chain record of prompt ownership, version history, and execution permissions. Each prompt entry contains:
interface PromptVaultEntry {
id: string; // Prompt's unique identifier
owner: string; // Author's wallet address
contentHash: string; // Hash of the DSL definition
metadataUri: string; // IPFS URI to full definition
licenseType: number; // License code (0=open, 1=gated, etc.)
tokenGate?: string; // Optional SPL token for access control
feeAmount?: number; // Optional usage fee
createdAt: number; // Creation timestamp
lastUpdated: number; // Last update timestamp
versionHistory: VersionRef[]; // Array of version references
status: number; // Status code (active, deprecated, etc.)
}
4. PromptRouter: Coordination Layer
PromptRouter acts as the coordination layer responsible for managing interactions between LLMs and PromptModules:
Connects models to appropriate resources based on context needs
Routes model requests to the right prompt modules
Manages authentication and access control
Orchestrates complex workflows through PromptDAG
interface PromptRouter {
// Semantic routing
resolvePrompt(
query: SemanticQuery,
constraints?: RouteConstraints
): Promise<PromptResolution>;
// Direct invocation
executePrompt(
promptId: string,
inputs: Record<string, any>,
executionOptions?: ExecutionOptions
): Promise<ExecutionResult>;
// DAG execution
executeDag(
dagId: string,
rootInputs: Record<string, any>,
executionOptions?: DagExecutionOptions
): Promise<DagExecutionResult>;
}
interface SemanticQuery {
intent: string; // Natural language description of need
domain?: string; // Optional domain constraint
outputFormat?: string; // Desired output format
modelProvider?: string; // Preferred model provider
}
PromptRouter's core functionality is not dependent on any specific model interaction protocol, allowing it to work with various AI systems.
5. LLM Integration Layer
The outermost layer consists of language models that consume PromptHub resources:
Large language models (e.g., Claude, GPT-4)
Model-specific adapters
Frontend applications that utilize LLMs
AI-powered tools and platforms
This architectural design ensures that PromptHub is not merely a backend service, but a programmable, composable, and trustworthy semantic layer for decentralized AI ecosystems. The core value of PromptHub lies in its capability as a prompt protocol layer and trading system, able to operate independently while integrating with various model interaction standards.
6. Data Flow Diagram
The following diagram illustrates the typical data flow for prompt registration, execution, and monetization within the PromptHub ecosystem:
┌─────────────────────────────────────────────────────────────────────────────────┐
│ PROMPTHUB SYSTEM DATA FLOW │
│ │
│ ┌──────────┐ ┌────────────┐ ┌───────────┐ ┌─────────┐ │
│ │ │ (1)DSL │ │ (2)Anchor│ │ │ │ │
│ │ Developer├─────────►│ SDK Client ├─────────►│PromptVault├───────►│ IPFS │ │
│ │ │ │ │ │ │ │ │ │
│ └──────────┘ └─────┬──────┘ └───┬───────┘ └─────────┘ │
│ │ │ │
│ │ (3)Mint NFT │ (4)Event │
│ ▼ ▼ │
│ ┌────────────┐ ┌────────────┐ │
│ │ │ │ │ │
│ │PromptNFT/ │ │ Index │ │
│ │SPL Token │ │ Service │ │
│ │ │ │ │ │
│ └────────────┘ └───────┬────┘ │
│ │ │
│ │ (5)Query │
│ ┌──────────┐ ┌────────────┐ ┌─────▼──────┐ ┌─────────┐ │
│ │ │ (6)Call │ │ (7)Route │ │ │ │ │
│ │ Agent ├─────────►│PromptRouter├─────────►│PromptModule├─────►│ LLM │ │
│ │ │ │ │ │ │ │ │ │
│ └──────────┘ └────────────┘ └─────┬──────┘ └────┬────┘ │
│ │ │ │
│ │ (8)Result │ │
│ ▼ │ │
│ ┌──────────┐ ┌────────────┐ ┌───────────┐ ┌────▼────┐ │
│ │ │(11)Reward│ │(10)Log │ │(9)Sign│ │ │
│ │ Creator ◄──────────┤ Fee Oracle ◄──────────┤PromptSig ◄───────┤ Output │ │
│ │ │ │ │ │ │ │ │ │
│ └──────────┘ └────────────┘ └───────────┘ └─────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘
This data flow demonstrates how PromptHub facilitates the entire prompt lifecycle from creation through execution to monetization, with cryptographic verification at every step.
Last updated