Blinkin 2.0 — Architecture

Implementation Status · Updated: 2026-03-15

36,297
Lines of Code
183
Files
25
Tests Passed
7
Layers
Implemented + tested
Partial / in progress
Planned / contracts ready
External / existing repos
Layer 1 — InterfacesPartial
Chat Panel
Central chat window, free-form, streaming
Implemented
Tests: state-store, agent-loop
Executive Editor
TipTap inline editor for documents
Implemented
Source Panel
Source selection, feed import, RSS
Implemented
Widget Surface
17 widget components, action handler
Implemented
Tests: widget-renderer
Review Inbox
Side-by-side diff, package review, approve/reject
Implemented
Control Plane Board
Kanban for agent tasks, operator actions, live SSE
Implemented
Tests: operator-actions, scheduler
Memory Panel
View/edit agent memory files, scope selection
Implemented
Tests: memory-api, memory-runtime
Actor Identity Bar
Operator / reviewer / supervisor identity
Implemented
Tests: actor-identity
Sidebar Navigation
Browse, Companions, Boards, Apps, Agents, Spaces, Controls
Planned
Target: 1:1 match with existing Blinkin UI
Chat History
Past conversations in sidebar under "OLDER"
Planned
Agent Chips
Quick-select at bottom of chat window
Planned
Companions (Houston)
Mini-apps via link, 15+ components, whitelabel
Via Host Bridge
Boards (React Flow)
Canvas with nodes and connections
Stays in Picasso FE
Design System
Manrope, cool white, #1B1F23 accent
Tokens ready, not applied
Layer 2 — AgentsPartial
Agent Loop
Plan-Act-Observe-Emit-Verify, Anthropic tool use, 10 tools
Implemented
Tests: agent-loop
Agent Definitions
Schema: persona, model routing, tools, constraints, triggers
Contracts ready
Tests: agent-definition-mapping
Executive Summary Agent
Sources → draft → TipTap → PDF. First E2E use case.
Implemented
Jingle Writer Agent
Write 3 jingles, save as documents
Preset defined
Tests: jingle-use-case
TTS Agent
Text → ElevenLabs → MP3, blob storage
Preset + TTS tool
Tests: tts-inference
Quality Review Agent
Fact check, style check, brand check
Preset defined
Research Agent
Deep research with web search, source analysis
Preset defined
Zweistein Agent Mapping
mapZweisteinAgent() — existing agents to new format
Implemented
Tests: agent-definition-mapping
Multi-Model Router
Claude, Gemini, OpenAI, DeepSeek — per subtask
Anthropic only, Gemini/OpenAI contracts ready
Partner Agents (A2A)
External agents via A2A protocol
Planned
Layer 3 — Orchestration, Governance, EvalCore implemented
Scheduler Daemon
Autonomous loop: reconcile → lease → dispatch → heartbeat
Implemented
Tests: autonomous-scheduler, scheduler
Work Items + Dependencies
DAG-based tasks with hard/soft/approval dependencies
Implemented
Tests: operator-actions
Leasing
Prevents double execution, expiry, drain batching
Implemented
Artifact Graph
Provenance: derived_from, input_to, reviews, publishes
Implemented
Scheduler Coordinator
Multi-worker coordination (local / postgres / durable-object)
Implemented
Tests: scheduler-coordinator-service, scheduler-coordination
Human Review Gate
Review column — only humans can approve
Implemented
Review Packages
Widget bundles, selective / all-or-nothing approval
Implemented
Policy Profiles
Tool allowlists, autonomy level, retry + publish policy
Contracts + store
Tool Audit Log
Every tool call: allow/deny, hash-chain, severity
Contracts + store
Notifications
Control plane notifications for reviewers/operators
Implemented
Operator Actions
Retry, cancel, reassign, pause/resume scheduler
Implemented
Tests: operator-actions
Rate Limiter
Token-bucket per org, tier presets (free → enterprise)
Contracts ready
Tests: rate-limiter
Eval Loop
Quality, accuracy, style, cost, user feedback
Planned
Circuit Breaker / SLO
Error budget, SLO enforcement, replay debugging
Planned
Layer 4 — Blinkin ComputerCore implemented
SSE Streaming
text.delta, widget.spec, state.patch, tool.result, run.completed
Implemented
State Store
Unified: form + agent + chat + widgets + documents + memory
Implemented
Tests: state-store
Memory Layer
5 model-agnostic tools + Claude-native enhancement + scoping
Implemented
Tests: memory-api, memory-runtime, anthropic-memory, memory-tools
Tool Router
10+ registered tools, CLI/API first
Implemented
Blob Store
Local + S3/R2, per-org partitioning
Implemented
Tests: runtime-blob-store
PDF Export
Server-side via pdf-lib
Implemented
Context Engine
Business context + agent memory + run context loading
System prompt yes, dynamic context loading no
Multi-Tenant Isolation
SQLite per org + PostgreSQL production
Implemented
Tests: tenant-runtime-isolation, runtime-store-backend
Graceful Shutdown
SIGTERM/SIGINT → scheduler stop → DB close
Contracts ready
Health Check
GET /health + /api/ready
Implemented
Tests: health
Structured Logger
JSON logging, level filtering, child loggers
Contracts ready
Tests: logger
Layer 5 — Business ContextContracts ready
Writing Rules
Tonality, style, formality, forbidden phrases
Contract defined
Brand Guidelines
Colors, logo, key messages, voice attributes
Contract defined
Personas
Target audiences, pain points, tone override
Contract defined
Templates
Document templates (executive, blog, social, etc.)
Contract defined
SOPs
Process descriptions with approval steps
Contract defined
Domain Knowledge
Glossary, regulations, FAQ
Contract defined
Skill Playbooks
Workflow recipes with agent roles and tools
Contract defined
Context Store + Loading
DB storage, assembleContextPrompt(), agent bindings
assembleContextPrompt() yes, DB store no
Context Editor UI
Visual editor for writing rules, brand, templates
Planned
Layer 6 — Systems of RecordCore implemented
SQLite Runtime Store
47+ specialized stores, isolated per org
Implemented
Tests: runtime-store-backend, tenant-runtime-isolation
PostgreSQL Store
Production-ready schema, all tables
Implemented
Document Store
TipTap JSON, versions, document ops
Implemented
Blob Store
Local + S3/R2, per-org namespace
Implemented
Tests: runtime-blob-store
Memory File Store
Agent memory files per work item / chat room / org
Implemented
Tests: memory-api, memory-runtime
Feed / Source Store
RSS import, article management
Implemented
Studio API Adapter
Read/import flows, fixture support
Implemented
Tests: server-authorization
Spaces (Knowledge Base)
RAG, document collections, vector search
Stays on Google Cloud
External APIs
CRM, CMS, Slack, Zammad
Planned
Layer 7 — Platform ServicesPartial
Auth (Server Authorization)
Actor headers, org routing, bearer token
Implemented
Tests: server-authorization
Auth0 Integration
JWT validation, RBAC, SSO
Planned — pattern from Studio API
Multi-Tenant Store Manager
SQLite per org, lazy loading, listKnownOrgIds()
Implemented
Tests: tenant-runtime-isolation
Input Validation
5 validators for API endpoints
Contracts ready
Tests: validation
Constants
48 magic strings as typed constants
Contracts ready
Tests: constants
Stripe / Paddle Billing
Subscriptions, webhooks, invoicing
Planned — port from Zweistein
Token Tracking
Usage per org, metrics in AgentRunRecord
Metrics schema yes, tracking UI no
PostHog Analytics
Product analytics events
Planned — 1 script tag
Email Notifications
Nodemailer, templates (invite, reset, verify)
Planned — port from Studio API
Host Bridge
PostMessage SDK for Houston/Picasso embedding
Implemented
React Embed
BlinkinRuntimeFrame component
Implemented
Picasso FE Integration
Patch + components for existing Picasso FE
Implemented

Architecture Diagrams — How Modules Connect

Full Architecture — 7 Layers
100%
graph TB
  subgraph L1["LAYER 1 — INTERFACES"]
    direction LR
    Chat["Chat Panel\n+ Editor + Widgets"]
    ControlBoard["Control Plane\nBoard"]
    MemPanel["Memory\nPanel"]
    ReviewUI["Review\nInbox"]
    Companions["Companions\n(Houston)"]
    Boards["Boards\n(React Flow)"]
  end
  subgraph L2["LAYER 2 — AGENTS"]
    direction LR
    AgentLoop["Agent Loop\nPlan-Act-Observe\nEmit-Verify"]
    ExecAgent["Executive\nSummary"]
    JingleAgent["Jingle\nWriter"]
    TTSAgent["TTS\nAgent"]
    ResearchAgent["Research\nAgent"]
    ModelRouter["Model Router\nClaude Gemini\nGPT DeepSeek"]
  end
  subgraph L3["LAYER 3 — ORCHESTRATION"]
    direction LR
    Scheduler["Scheduler Daemon\nLease Drain\nReconcile"]
    WorkItems["Work Items\nDAG Dependencies"]
    ArtifactGraph["Artifact Graph\nProvenance"]
    PolicyGate["Policy Gate\nTool Audit"]
    HumanGate["Human Review\nGate"]
    Coordinator["Scheduler\nCoordinator"]
  end
  subgraph L4["LAYER 4 — BLINKIN COMPUTER"]
    direction LR
    SSE["SSE\nStreaming"]
    StateStore["State\nStore"]
    MemoryLayer["Memory\nLayer"]
    ToolRouter["Tool\nRouter"]
    BlobStore["Blob\nStore"]
    ContextEng["Context\nEngine"]
  end
  subgraph L5["LAYER 5 — BUSINESS CONTEXT"]
    direction LR
    WritingRules["Writing\nRules"]
    Brand["Brand\nGuidelines"]
    Personas["Personas"]
    Templates["Templates"]
    Playbooks["Skill\nPlaybooks"]
  end
  subgraph L6["LAYER 6 — SYSTEMS OF RECORD"]
    direction LR
    SQLite["SQLite\nper Org"]
    Postgres["PostgreSQL\nProduction"]
    DocStore["Document\nStore"]
    MemFiles["Memory\nFiles"]
    Spaces["Spaces\n(Google)"]
    StudioAPI["Studio API\nAdapter"]
  end
  subgraph L7["LAYER 7 — PLATFORM SERVICES"]
    direction LR
    Auth["Auth"]
    Tenant["Multi-Tenant\nManager"]
    RateLimiter["Rate\nLimiter"]
    HostBridge["Host\nBridge"]
    ReactEmbed["React\nEmbed"]
  end
  Chat -->|user input| AgentLoop
  Chat -->|shows| SSE
  ControlBoard -->|dispatch| Scheduler
  MemPanel -->|reads| MemoryLayer
  ReviewUI -->|approve| HumanGate
  AgentLoop -->|tool calls| ToolRouter
  AgentLoop -->|emits| SSE
  AgentLoop -->|reads/writes| MemoryLayer
  ModelRouter -.->|selects model| AgentLoop
  Scheduler -->|leases| WorkItems
  WorkItems -->|resolves DAG| ArtifactGraph
  PolicyGate -->|before tool call| ToolRouter
  HumanGate -->|blocks until approve| WorkItems
  Coordinator -.->|multi-worker| Scheduler
  SSE -->|streams to| Chat
  StateStore -->|unified state| Chat
  ToolRouter -->|search/create| DocStore
  ToolRouter -->|write/read| BlobStore
  MemoryLayer -->|persists| MemFiles
  ContextEng -->|loads| WritingRules
  ContextEng -->|loads| Brand
  SQLite -->|dev| StateStore
  Postgres -->|production| StateStore
  Spaces -.->|RAG API| ToolRouter
  Auth -->|validates| Chat
  Tenant -->|isolates| SQLite
  HostBridge -.->|embeds in| Companions
Data Flow — From User Input to Result
100%
graph LR
  User["User types\nin chat"] -->|POST /api/agent-runs| Server["Server"] -->|creates| Run["Agent Run"] -->|starts| Loop["Agent Loop"]
  Loop -->|1. checks| Memory["Memory files"]
  Loop -->|2. loads| Context["Business context"]
  Loop -->|3. calls| LLM["LLM\n(Claude/Gemini/GPT)"]
  LLM -->|tool_use| Tools["Tool Router"]
  Tools -->|search| KB["Knowledge Base"]
  Tools -->|create_doc| Docs["Document Store"]
  Tools -->|write_blob| Blobs["Blob Store"]
  Tools -->|memory_write| MemStore["Memory Store"]
  Loop -->|emits SSE| Stream["Stream Emitter"]
  Stream -->|text.delta| ChatUI["Chat\n(live text)"]
  Stream -->|widget.spec| Widgets["Widgets\n(cards, tables)"]
  Stream -->|document.op| Editor["TipTap\nEditor"]
  Stream -->|run.completed| Done["Done"]
Kanban Flow — Work Items Through the Pipeline
100%
graph LR
  Create["User creates\nwork item"] -->|POST /api/work-items| Backlog["Backlog"] -->|dependencies met| Ready["Ready"] -->|scheduler leases| Leased["Leased"] -->|agent starts| Running["Running"]
  Running -->|agent done| Verify["Verifying"]
  Verify -->|policy check| Review["Awaiting\nReview"]
  Review -->|human approves| Approved["Approved"]
  Approved --> Done["Done"]
  Running -->|error| Failed["Failed"]
  Failed -->|retry| Ready
  Review -->|rejected| Ready
Memory Layer — Model-Agnostic Context Sharing
100%
graph TB
  subgraph Agents["Different Models"]
    Claude["Claude\n(Opus/Sonnet)"]
    Gemini["Gemini\n(Research)"]
    GPT["GPT"]
  end
  subgraph MemTools["Memory Tools (all models)"]
    List["memory_list"]
    Read["memory_read"]
    Write["memory_write"]
    Update["memory_update"]
    Delete["memory_delete"]
  end
  subgraph ClaudeExtra["Claude Enhancement"]
    NativeMem["memory_20250818\n(Claude-native)"]
    CtxEdit["Context Editing\n(auto-clear)"]
  end
  subgraph Storage["Persistence"]
    BlobMem["Blob Store"]
    ArtifactMem["Artifact Store"]
  end
  subgraph Scopes["Scoping"]
    PerTask["Per Work Item"]
    PerChat["Per Chat Room"]
    PerOrg["Per Org"]
  end
  Claude -->|tool_use| MemTools
  Claude -->|native| ClaudeExtra
  Gemini -->|function_calling| MemTools
  GPT -->|function_calling| MemTools
  MemTools --> Storage
  ClaudeExtra --> Storage
  Storage --> Scopes
  Scopes -->|visible in| Panel["Memory Panel UI"]
Two-Interface Principle — Platform vs. Companion
100%
graph TB
  subgraph Creator["CREATOR — Platform"]
    KB["Kanban Board\n+ Control Plane\nAll agents visible\nFull config\nAudit trail"]
  end
  subgraph EndUser["END USER — Companion"]
    CU["Chat + Widgets\nNo board visible\nResults only\nBranded"]
  end
  subgraph Backend["SAME BACKEND"]
    Agents["Agents"]
    Scheduler["Scheduler"]
    Memory["Memory"]
    Store["Storage"]
  end
  Creator --> Backend
  EndUser --> Backend