Skip to main content

Idiomark - Architecture Documentation

Deep dive into the Idiomark system architecture, data flows, and design decisions.


Table of Contents​

  1. System Architecture
  2. Component Design
  3. Data Flows
  4. Design Decisions
  5. Performance Optimization

Data Flow Overview​

Idiomark processes user-provided text samples through a structured pipeline, transforming raw writing into AI-ready personality profiles.

Key Stages​

StageDescription
Text SourcesWriting samples the user provides: emails, chat logs, posts, documents
ExtractorProcesses raw text and extracts relevant personality signals
AnalyzerPerforms NLP analysis, pattern detection, and trait identification
GeneratorCreates structured Idiomark files with validated personality profiles
Inference EngineLoads Idiomark files and generates context-aware AI responses

System Architecture​

High-Level Overview​

┌─────────────────────────────────────────────────────────────────────────┐
│ Applications │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Web App │ │ MCP Agent │ │ HTTP API │ │ CLI │ │
│ │ │ │ │ │ Server │ │ (Node.js) │ │
│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
└─────────┼─────────────────┼─────────────────┼─────────────────┼──────────┘
│ │ │ │
└─────────────────┴─────────────────┴─────────────────┘
│
┌───────────────────────────────────────────────────┐
│ Idiomark Layer (Monorepo) │
│ ┌─────────┐ ┌─────────┐ ┌────────────┐ │
│ │ Core │ │ SDK │ │ Inference │ │
│ └─────────┘ └─────────┘ └────────────┘ │
│ ┌─────────┐ ┌─────────┐ ┌────────────┐ │
│ │ CLI │ │ MCP │ │ Projectors │ │
│ └─────────┘ └─────────┘ └────────────┘ │
└──────────────────────────┬────────────────────────────┘
│
┌──────────────────────────┴────────────────────────────┐
│ LLM Providers (user-configured) │
│ ┌──────────┐ ┌──────────┐ ┌──────────────────┐ │
│ │ Anthropic│ │ OpenAI │ │ Local (Ollama...) │ │
│ └──────────┘ └──────────┘ └──────────────────┘ │
└────────────────────────────────────────────────────────┘

Package Dependencies​

@idiomark/core
└── (no internal dependencies)

@idiomark/sdk
└── @idiomark/core

@idiomark/inference
└── @idiomark/core

@idiomark/mcp
└── @idiomark/core

@idiomark/projectors
└── @idiomark/core

@idiomark/cli
└── @idiomark/core

Component Design​

1. Core (@idiomark/core)​

Purpose: Extraction, validation, and generation of Idiomark files.

Key Classes:

IdiomarkExtractor // Extract personality from text samples
IdiomarkGenerator // Generate Idiomark file from personality
IdiomarkValidator // Validate Idiomark file structure
IdiomarkReader // Consume personality for inference

Design Principles:

  • Pure functional programming for data transformations
  • Immutable data structures
  • Zod for runtime validation
  • JSON Schema-validated .idiomark documents

2. Inference (@idiomark/inference)​

Purpose: Applies a personality profile to AI responses, pointed at a user-configured LLM provider.

Design Principles:

  • Personality strength modes (strict / balanced / subtle / custom)
  • Provider-agnostic: works with cloud or local LLMs
  • Prompt construction isolated from provider clients

3. MCP (@idiomark/mcp)​

Purpose: Exposes a personality as MCP tools and resources for agents.

Design Principles:

  • Context mode (read-only) and engine mode (generative)
  • stdio or HTTP transport
  • Local-first: no LLM required for read-only use

4. Projectors (@idiomark/projectors)​

Purpose: Project an existing profile onto external systems (MCP servers, HTTP APIs) — the opposite direction of extraction.

Design Principles:

  • Shared base adapter (rate limiting, caching, retry, metrics)
  • Reusable personality modes across projector types

Data Flows​

Flow 1: Personality Extraction​

User Text Samples (Emails, Posts, Documents)
↓
┌─────────────────────────────────────────────────┐
│ IdiomarkAnalyzer │
│ - NLP processing │
│ - Pattern extraction │
│ - Domain detection │
│ - Value analysis │
└──────────────┬────────────────────────────────┘
│
↓
┌─────────────────────────────────────────────────┐
│ IdiomarkGenerator │
│ - Structure validation │
│ - File creation │
│ - Optional signature │
└──────────────┬────────────────────────────────┘
│
↓
┌─────┴─────┐
│ Idiomark File │
└─────────┘

Flow 2: Personality Inference​

┌───────────────┐
│ Idiomark File │
└───────┬───────┘
│
↓
┌─────────────────────────────────────────────────┐
│ Inference Engine │
│ - Load and validate profile │
│ - Build personality system prompt │
│ - Apply mode (strict/balanced/subtle) │
└──────────────┬────────────────────────────────┘
│
↓
┌─────────────────────────────────────────────────┐
│ LLM Provider │
│ - User-configured (cloud or local) │
└──────────────┬────────────────────────────────┘
│
↓
┌───────────────┐
│ In-character │
│ AI Response │
└───────────────┘

Design Decisions​

Why Monorepo?​

  • Shared Types: Consistent models across all packages
  • Unified Testing: Cross-package integration tests
  • Simplified Releases: Version all packages together
  • Code Sharing: Common utilities in one place

Why TypeScript?​

  • Type Safety: Catches errors at compile time
  • Great IDE Support: Autocomplete, refactoring
  • Easy Adoption: Familiar to most developers
  • Cross-Platform: Runs in Node.js and browsers

Why Separate Packages?​

  • Tree Shaking: Import only what you need
  • Independent Releases: Version packages separately
  • Clear Boundaries: Each package has a single responsibility
  • Flexibility: Mix and match as needed

Why a File Format, Not a Service?​

  • Ownership: The profile lives wherever you put it
  • Portability: Any system that reads JSON can consume it
  • Privacy: Nothing leaves your machine unless you choose a provider
  • Simplicity: No accounts, no servers, no lock-in

Performance Optimization​

Extraction Optimization​

  • Chunking: Large text corpora split into chunks
  • Parallel Processing: Multiple samples processed concurrently
  • Caching: Reuse previous extractions
  • Incremental Updates: Update only changed content

End of Architecture Documentation