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. Security Model
  5. Scalability Considerations
  6. Design Decisions

Data Flow Overview​

The Idiomark processes user data through a structured pipeline, transforming raw content from various platforms into AI-ready personality profiles.

Key Stages​

StageDescription
Data SourcesUser content from social platforms, code repositories, forums, and messaging apps
AdaptersPlatform-specific connectors that normalize data into a common format
ExtractorProcesses raw content 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 │ │ iOS App │ │ Android App │ │ CLI │ │
│ │ (Next.js) │ │ (Swift) │ │ (Kotlin) │ │ (Node.js) │ │
│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
└─────────┼─────────────────┼─────────────────┼─────────────────┼────────────┘
│ │ │ │
└─────────────────┴─────────────────┴─────────────────┘
│
┌───────────────────────────────────────────────────┐
│ Idiomark Layer (Monorepo) │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────┐ │
│ │ Core │ │Storage │ │ Sync │ │ ... │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────┘ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────┐ │
│ │Adapters │ │Identity │ │ Teams │ │ ... │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────┘ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────┐ │
│ │ Mobile │ │Version │ │ Browser │ │ ... │ │
│ │ SDKs │ │ History │ │Extension│ │ │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────┘ │
└──────────────────────────┬────────────────────────────┘
│
┌──────────────────────────┴────────────────────────────┐
│ External Services │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────┐ │
│ │ AWS │ │Cloudflare│ │ OpenAI │ │ ... │ │
│ │ S3 │ │ R2 │ │ Anthropic│ │ │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────┘ │
└──────────────────────────────────────────────────────┘

Package Dependencies​

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

@idiomark/adapters
└── @idiomark/core

@idiomark/storage
├── @idiomark/core
├── @aws-sdk/client-s3
└── @cloudflare/workers-types

@idiomark/sync
├── @idiomark/storage
└── ws (WebSocket)

@idiomark/identity
└── @idiomark/core
├── tweetnacl (crypto)
├── @noble/curves (crypto)
└── uuid

@idiomark/teams
├── @idiomark/core
├── @idiomark/storage
└── zod (validation)

@idiomark/mobile-sdk-ios
├── @idiomark/storage
├── @idiomark/sync
└── @idiomark/inference

@idiomark/mobile-sdk-android
├── @idiomark/storage
├── @idiomark/sync
├── @idiomark/inference
└── okhttp3 (networking)

Component Design​

1. Core (@idiomark/core)​

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

Key Classes:

IdiomarkExtractor     // Extract personality from content
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
  • Adapter pattern for extensibility

2. Storage (@idiomark/storage)​

Purpose: Multi-provider cloud storage with caching and encryption.

Architecture:

┌──────────────────────────────────────────────┐
│ IdiomarkStorage (Manager) │
│ ┌─────────────────────────────────────────┐ │
│ │ AbstractStorageAdapter (Base) │ │
│ │ - Event emission │ │
│ │ - Retry logic with exponential backoff │ │
│ │ - In-memory caching with TTL │ │
│ │ - Rate limiting │ │
│ └─────────────────────────────────────────┘ │
│ │ │
│ ┌──────────────┐ ┌──────────────┐ │
│ │ S3Adapter │ │ R2Adapter │ ... │
│ └──────────────┘ └──────────────┘ │
└──────────────────────────────────────────────┘

Design Patterns:

  • Adapter Pattern: Abstract base with provider-specific implementations
  • Strategy Pattern: Different storage strategies (cache-first, write-through)
  • Observer Pattern: Event emission for lifecycle hooks

3. Sync (@idiomark/sync)​

Purpose: Real-time WebSocket-based synchronization.

Architecture:

┌─────────────────────────────────────────────────────┐
│ Sync Server │
│ ┌──────────────────────────────────────────────┐ │
│ │ WebSocket Server (ws library) │ │
│ │ - Connection manager │ │
│ │ - JWT authentication │ │
│ │ - Broadcast engine │ │
│ │ - Heartbeat monitor │ │
│ └──────────────────────────────────────────────┘ │
│ │
│ ┌──────────────┐ ┌──────────────┐ │
│ │ Channel: │ │ Channel: │ │
│ │ idiomark:{fileId} │ │ user:{userId} │ │
│ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────┐
│ Sync Client │
│ ┌──────────────────────────────────────────────┐ │
│ │ WebSocket Client │ │
│ │ - Auto-reconnection │ │
│ │ - Offline event queue │ │
│ │ - Message routing │ │
│ │ - Subscription management │ │
│ └──────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────┐ │
│ │ Offline Queue │ │
│ │ - Stores events when disconnected │ │
│ │ - Flushes on reconnect │ │
│ └─────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────┘

Design Patterns:

  • Publisher-Subscriber: Channel-based messaging
  • Command Pattern: Encapsulated actions in message types
  • State Pattern: Connection state management

4. Identity (@idiomark/identity)​

Purpose: Privacy-preserving identity verification with ZK proofs.

Architecture:

┌─────────────────────────────────────────────────────┐
│ Identity Verification │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌─────────┐ │
│ │ Crypto │ │ Claims │ │Verifier │ │
│ │ - Keys │ │ - Issue │ │- Verify │ │
│ │ - Sign │ │ - Revoke │ │- Score │ │
│ │ - DID │ │ - Validate │ │ │ │
│ └──────────────┘ └──────────────┘ └─────────┘ │
│ │
│ ┌─────────────────────────────────────────────┐ │
│ │ Zero-Knowledge Proof System │ │
│ │ - Ownership proofs │ │
│ │ - Timestamp proofs │ │
│ │ - Authorship proofs │ │
│ │ - Membership proofs │ │
│ └─────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────┘

Design Patterns:

  • Builder Pattern: Fluent claim construction
  • Strategy Pattern: Different proof types
  • Factory Pattern: Key and claim generation

5. Teams (@idiomark/teams)​

Purpose: Team collaboration with RBAC.

Architecture:

┌─────────────────────────────────────────────────────┐
│ Team Collaboration │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌─────────┐ │
│ │ TeamManager │ │MemberManager │ │Resource │ │
│ │ - CRUD │ │ - Add/Remove │ │Manager │ │
│ │ - Stats │ │ - Roles │ │- Share │ │
│ └──────────────┘ └──────────────┘ └─────────┘ │
│ │
│ ┌─────────────────────────────────────────────┐ │
│ │ Permission Checker (RBAC) │ │
│ │ - Role-based access control │ │
│ │ - Resource ownership checks │ │
│ │ - Permission conditions │ │
│ └─────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────┐ │
│ │ Invitation Manager │ │
│ │ - Token-based invites │ │
│ │ - Email delivery │ │
│ │ - Expiration handling │ │
│ └─────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────┘

Design Patterns:

  • ACL Pattern: Access Control Lists with role inheritance
  • Specification Pattern: Permission conditions
  • Repository Pattern: Data access abstraction

6. Mobile SDKs​

iOS SDK​

┌─────────────────────────────────────────────┐
│ IdiomarkSDK (Swift) │
│ │
│ ┌─────────────────────────────────────────┐ │
│ │ State Management │ │
│ │ - @Published properties │ │
│ │ - ObservableObject protocol │ │
│ └─────────────────────────────────────────┘ │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Storage │ │ Sync │ │Inference │ │
│ │ Client │ │ Client │ │ Client │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ │
│ ┌─────────────────────────────────────────┐ │
│ │ Swift Concurrency │ │
│ │ - async/await │ │
│ │ - Actor pattern │ │
│ └─────────────────────────────────────────┘ │
└─────────────────────────────────────────────┘

Android SDK​

┌─────────────────────────────────────────────┐
│ IdiomarkSDK (Kotlin) │
│ │
│ ┌─────────────────────────────────────────┐ │
│ │ State Management │ │
│ │ - StateFlow │ │
│ │ - Coroutines │ │
│ └─────────────────────────────────────────┘ │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │Storage │ │ Sync │ │Inference │ │
│ │ Client │ │ Client │ │ Client │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ │
│ ┌─────────────────────────────────────────┐ │
│ │ Android Architecture │ │
│ │ - Singleton object │ │
│ │ - Lazy initialization │ │
│ │ - OkHttp networking │ │
│ └─────────────────────────────────────────┘ │
└─────────────────────────────────────────────┘

Data Flows​

Flow 1: Personality Extraction​

User Content (Tweets, Posts, Code)
↓
┌─────────────────────────────────────────────────┐
│ Platform Adapters │
│ - TwitterAdapter │
│ - GitHubAdapter │
│ - RedditAdapter │
└──────────────┬────────────────────────────────┘
│
↓
┌─────────────────────────────────────────────────┐
│ IdiomarkAnalyzer │
│ - NLP processing │
│ - Pattern extraction │
│ - Domain detection │
│ - Value analysis │
└──────────────┬────────────────────────────────┘
│
↓
┌─────────────────────────────────────────────────┐
│ IdiomarkGenerator │
│ - Structure validation │
│ - File creation │
│ - Signature generation │
└──────────────┬────────────────────────────────┘
│
↓
┌─────┴─────┐
│ Idiomark File │
└─────────┘

Flow 2: Cloud Storage​

┌─────────────────────────────────────────────────┐
│ Application │
│ - Web, iOS, Android, CLI │
└──────────────┬────────────────────────────────┘
│
↓
┌─────────────────────────────────────────────────┐
│ IdiomarkStorage │
│ - Encryption (AES-256-GCM) │
│ - Compression │
│ - ETag calculation │
└──────────────┬────────────────────────────────┘
│
↓
┌───────┴────────┐
│ Storage Adapter │
│ (S3, R2, FS) │
└────────────────┘
│
↓
┌─────────────────┐
│ Cloud Storage │
│ (S3, R2, etc.) │
└─────────────────┘

Flow 3: Real-Time Sync​

┌──────────────────────┐         ┌──────────────────────┐
│ Client A │ │ Client B │
│ ┌────────────────┐ │ │ ┌────────────────┐ │
│ │ Local Storage │ │ │ │ Local Storage │ │
│ └───────┬────────┘ │ │ └───────┬────────┘ │
└────────┼───────────┘ └────────┼───────────┘
│ │
└──────────┬──────────────────┘
│ WebSocket
↓
┌──────────────────────┐
│ Sync Server │
│ - Broadcast engine │
│ - Presence tracker │
└──────────────────────┘

Flow 4: Identity Verification​

┌──────────────────────┐
│ User │
└──────────┬───────────┘
│
↓
┌──────────────────────┐
│ Generate Keys │
│ - ed25519 keypair │
│ - DID generation │
└──────────┬───────────┘
│
↓
┌──────────────────────┐
│ Issue Claim │
│ - Platform link │
│ - ZK proof │
│ - Signature │
└──────────┬───────────┘
│
↓
┌──────────────────────┐
│ Verify Claim │
│ - Proof validation │
│ - Signature check │
│ - Trust scoring │
└──────────────────────┘

Security Model​

Encryption Strategy​

  1. Client-Side Encryption

    • Files encrypted before upload
    • AES-256-GCM encryption
    • Keys stored securely (Keychain/Keystore)
  2. Zero-Knowledge Proofs

    • Prove ownership without revealing private data -zk-SNARKs for compact proofs
    • Verifier contracts on-chain
  3. Authentication

    • JWT-based API authentication
    • Token rotation and refresh
    • Multi-factor auth support

Data Privacy​

Data TypeStorageEncryptionAccess
Idiomark FilesEncrypted at restAES-256-GCMOwner + shared users
Identity KeysEncryptedHardware-backedOwner only
Sync TokensEphemeralTLS in transitAuthenticated users
Audit LogsEncryptedAES-256Team admins

Scalability Considerations​

Storage Scaling​

  • S3/R2: Designed for infinite horizontal scaling
  • CDN Caching: Public files cached at edge
  • ETag Caching: Reduces unnecessary transfers
  • Pagination: All list operations support pagination

Sync Scaling​

  • Connection Pooling: WebSocket server scales horizontally
  • Channel Sharding: Broadcast to channel subsets
  • Message Queues: Offline queues for reliability
  • Heartbeat: Keep-alive with ping-pong

API Rate Limits​

TierRequests/MinConcurrentBurst
Free60510
Pro60050100
Enterprise60005001000

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, browsers, mobile

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 Mobile SDKs?​

  • Native Performance: Better than web views
  • Offline Support: Local caching and sync
  • Push Notifications: Real-time updates
  • Platform Features: Native UI components

Performance Optimization​

Extraction Optimization​

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

Storage Optimization​

  • Compression: Gzip compression before upload
  • Batch Operations: Combine multiple operations
  • Lazy Loading: Load only what's needed
  • Indexing: Fast lookup by ID, tags, metadata

Sync Optimization​

  • Delta Sync: Only sync changed data
  • Compression: WebSocket message compression
  • Connection Pooling: Reuse connections
  • Smart Reconnection: Exponential backoff

End of Architecture Documentation