MATIH Platform is in active MVP development. Documentation reflects current implementation status.
15. Workbench Architecture
Shared Library Deep Dive
API Client Modules

API Client Modules

The shared library provides 16 domain-specific API client modules at frontend/shared/src/api/. Each client wraps the base ApiClient class and exposes typed methods for its corresponding backend service. All clients are initialized together through the initializeApiClients() factory function.


Client Architecture

initializeApiClients(config)
  |
  +-> ApiClient (base)         # Fetch + auth + retry + timeout
  |     |
  |     +-> BIApiClient        # bi-service
  |     +-> QueryApiClient     # query-engine
  |     +-> SemanticApiClient  # semantic-layer
  |     +-> AIApiClient        # ai-service
  |     +-> MLApiClient        # ml-service
  |     +-> DataApiClient      # catalog-service
  |     +-> PipelineApiClient  # pipeline-service
  |     +-> DbtApiClient       # pipeline-service
  |     +-> DataQualityApiClient  # data-quality-service
  |     +-> GovernanceApiClient   # governance-service
  |     +-> OntologyApiClient     # ontology-service
  |     +-> RenderApiClient       # render-service
  |     +-> OpsAgentApiClient     # ops-agent-service
  |     +-> AgentStudioApiClient  # ai-service
  |     +-> NotificationApiClient # notification-service
  |     +-> BillingApiClient      # billing-service

Base Client Methods

class ApiClient {
  get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
  post<T>(path: string, body?: unknown): Promise<T>;
  put<T>(path: string, body?: unknown): Promise<T>;
  patch<T>(path: string, body?: unknown): Promise<T>;
  delete(path: string): Promise<void>;
  getRaw(path: string, params?): Promise<Response>;
  postRaw(path: string, body?: unknown): Promise<Response>;
  updateConfig(config: Partial<ApiConfig>): void;
  getBaseUrl(): string;
}

BI API Client (api/bi.ts)

Manages dashboards, widgets, and BI-specific operations:

  • getDashboards(params) -- List dashboards with pagination
  • getDashboard(id) -- Get dashboard detail
  • createDashboard(data) -- Create new dashboard
  • updateDashboard(id, data) -- Update dashboard
  • deleteDashboard(id) -- Delete dashboard
  • getWidgets(dashboardId) -- List widgets for a dashboard
  • createWidget(dashboardId, data) -- Add widget to dashboard
  • updateWidget(dashboardId, widgetId, data) -- Update widget configuration
  • exportDashboard(id, format) -- Export dashboard as PDF/PNG

Query API Client (api/query.ts)

Manages SQL query execution against the query engine:

  • executeQuery(sql, dataSourceId) -- Execute SQL query
  • getQueryStatus(queryId) -- Check query execution status
  • getQueryResults(queryId, page, size) -- Fetch paginated results
  • cancelQuery(queryId) -- Cancel running query
  • getQueryHistory(params) -- List recent queries
  • explainQuery(sql, dataSourceId) -- Get query execution plan

AI API Client (api/ai.ts)

Manages AI chat sessions and agent execution:

  • createChatSession(tenantId, userId) -- Create new chat session
  • chat(request) -- Send message and get response
  • streamChat(request) -- Stream chat response via SSE
  • getChatHistory(sessionId) -- Get session history
  • getSuggestions(context) -- Get AI-powered suggestions

ML API Client (api/ml.ts)

Manages experiments, models, and deployments:

  • getExperiments(params) -- List experiments
  • createExperiment(data) -- Create new experiment
  • getModels(params) -- List registered models
  • deployModel(modelId, config) -- Deploy model to endpoint
  • getDeployments(params) -- List active deployments
  • getTrainingRuns(experimentId) -- List training runs

Data API Client (api/data.ts)

Manages data catalog, lineage, and quality:

  • searchAssets(request) -- Search data assets
  • getAssetDetail(assetId) -- Get asset metadata
  • getLineage(assetId, depth) -- Get lineage graph
  • getQualityProfile(assetId) -- Get quality profile
  • createQualityRule(assetId, rule) -- Create quality rule
  • getGlossary() -- Get business glossary

Initialization

All workbenches initialize clients at startup:

import { initializeApiClients } from '@matih/shared';
 
const clients = initializeApiClients({
  baseUrl: import.meta.env.VITE_API_BASE_URL || '/api',
  tenantId: import.meta.env.VITE_TENANT_ID || 'default',
});