Chapter 13: The ITI Shared Library
Chapter 13: The ITI Shared Library
Last Updated: 2026-03
13.2 Library Structure
ITI/shared/
├── wordpress/ # WordPress PHP components (11 files)
├── desktop/ # Tauri/Desktop TypeScript components (6 files)
├── ios-macos/ # Swift components (2 files)
├── python/ # Python utilities (2 files)
├── rust/ # Rust components (1 file)
├── patterns/ # Architecture documentation (6 pattern guides)
└── templates/ # Project starter templates
├── wordpress-plugin/
├── desktop-app/
└── pwa/
13.3 WordPress PHP Components
The WordPress library is the largest section. Used by all 20+ WordPress plugin products.
API Clients (wordpress/api-clients/)
| File | Class | Purpose |
|---|---|---|
class-iti-workflow-adapter.php |
ITI_Workflow_Adapter |
n8n-first + Claude-fallback (see Chapter 12) |
class-iti-claude-api.php |
ITI_Claude_API |
Direct Anthropic Claude API client |
class-iti-tavily-api.php |
ITI_Tavily_API |
Tavily search API client |
class-iti-pinecone-api.php |
ITI_Pinecone_API |
Pinecone vector DB client (legacy) |
Database Base (wordpress/database/)
| File | Class | Purpose |
|---|---|---|
class-iti-database-base.php |
ITI_Database_Base |
Base class for all plugin database tables |
The database base class provides:
- Standard
create_table(),insert(),update(),delete(),get_by_id()methods - Automatic table name prefixing with
{$wpdb->prefix}iti_ - Input sanitization on all write operations
- Prepared statement enforcement
// Example: extending the base for a plugin-specific table
class Career_Coach_Sessions extends ITI_Database_Base {
protected $table_name = 'career_coach_sessions';
protected function get_schema(): string {
return "
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
user_id BIGINT UNSIGNED NOT NULL,
session_data LONGTEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
";
}
}
Chat Handlers (wordpress/chat-handlers/)
Provides standardized AJAX handler boilerplate for chat-style WordPress plugins:
- Nonce verification
- User authentication checks
- Sanitized input parsing
- JSON response formatting
Admin UI (wordpress/admin-ui/)
Reusable WordPress admin page components:
- Settings pages with consistent ITI styling
- API key management UI with masked display
- Usage statistics displays
Utilities (wordpress/utilities/)
General helper functions used across plugins:
- Rate limiting helpers
- Response caching (transient-based)
- Error logging with consistent format
13.4 Desktop/Tauri TypeScript Components
Used by all Tauri 2 desktop apps (estate-manager, personal-assistant).
desktop/services/
| File | Purpose |
|---|---|
AgentRouter.ts |
Routes user requests to the appropriate AI agent |
AutonomyManager.ts |
Manages AI autonomy level (supervised vs autonomous) |
ConversationManager.ts |
Manages conversation history, truncation, context injection |
desktop/database/
| File | Purpose |
|---|---|
DatabaseConnection.ts |
Wrapper around Tauri’s rusqlite bindings |
desktop/auth/
| File | Purpose |
|---|---|
Encryption.ts |
AES encryption for sensitive data at rest |
Keychain.ts |
macOS Keychain integration via Tauri plugin |
13.5 iOS/macOS Swift Components
Used by Swift apps (expat-advisor).
ClaudeService.swift
Complete Anthropic Claude API client for Swift:
- Streaming and non-streaming responses
- Structured tool use support
- Automatic retry with exponential backoff
- Error types that map to user-facing messages
KeychainService.swift
Secure credential storage using the iOS/macOS Keychain:
- Store, retrieve, and delete API keys
- Separate keychain items per service
- Biometric authentication support
13.6 Python Components
Used in Flask and FastAPI services.
python/claude_client.py
Thin wrapper around the anthropic Python SDK:
- Standard system prompt injection
- Tool use scaffolding
- Consistent error handling and logging
python/utilities.py
General utilities:
- Environment variable loading with validation
- Structured logging configuration
- HTTP retry helpers
13.7 Architecture Patterns
ITI/shared/patterns/ contains documentation-only guides for cross-cutting architectural decisions. Read these before designing new products.
| Pattern | File | When to use |
|---|---|---|
| Singleton | singleton/README.md |
Services that should have only one instance (API clients, DB connections) |
| RAG Architecture | rag-architecture/README.md |
Designing retrieval-augmented generation pipelines |
| Multi-Agent | multi-agent/README.md |
Coordinating multiple AI agents on a task |
| Database | database/README.md |
Schema design, migration patterns, query optimization |
| WordPress Plugin | wordpress-plugin/README.md |
Standard plugin structure and hook architecture |
| Desktop App | desktop/README.md |
Tauri app architecture, state management, IPC patterns |
13.8 Project Templates
ITI/shared/templates/ contains starter templates for new projects. Always use these rather than starting from scratch.
| Template | Contents |
|---|---|
wordpress-plugin/ |
Plugin boilerplate with ITI shared library imports, standard file structure, admin page scaffold |
desktop-app/ |
Tauri 2 starter with Rust backend, React/TypeScript frontend, Zustand, SQLite integration |
pwa/ |
Progressive web app starter |
Using a template
# Copy the wordpress-plugin template to a new product
cp -r ITI/shared/templates/wordpress-plugin/ ITI/products/my-new-product/
cd ITI/products/my-new-product/
# Rename plugin slug, update composer.json/package.json, etc.
13.9 Contributing to the Shared Library
When you write code in a product that would be useful to other products:
- Extract the code into a standalone class/function with no product-specific dependencies.
- Add it to the appropriate subdirectory in
ITI/shared/. - Update
ITI/shared/CATALOG.mdwith the new component. - Update
ITI/shared/README.mdif the component requires setup instructions. - Notify the team so other products can adopt it.
Previous: Chapter 12 — The ITI Workflow Adapter | Next: Chapter 14 — WordPress Plugin Development
