MATIH Platform is in active MVP development. Documentation reflects current implementation status.
16. User Experience
Export & Embedding

Export and Embedding

The MATIH platform provides comprehensive export and embedding capabilities for sharing dashboards, charts, query results, and reports outside the platform. Users can export content in multiple formats (PDF, PNG, CSV, Excel, JSON), embed interactive dashboards via iframe, schedule automated report delivery, and generate shareable links with configurable access controls. This section covers the export system architecture, embedding integration, and scheduled report delivery.


Export System Architecture

The export system spans three layers: client-side export for immediate downloads, server-side rendering for high-fidelity output, and scheduled exports for automated delivery.

+-----------------------------------------------------------+
|  Export Trigger                                            |
|  [Export button] [Keyboard shortcut] [Scheduled job]       |
+-----------------------------------------------------------+
         |                    |                    |
         v                    v                    v
  +-------------+    +----------------+    +--------------+
  | Client-side |    | Server-side    |    | Scheduled    |
  | Export      |    | Render Service |    | Export       |
  | (browser)   |    | (Node.js 8098) |    | (cron)       |
  +-------------+    +----------------+    +--------------+
         |                    |                    |
         v                    v                    v
  +-------------+    +----------------+    +--------------+
  | Download    |    | Download or    |    | Email / S3 / |
  | to browser  |    | store in S3    |    | Webhook      |
  +-------------+    +----------------+    +--------------+

Client-Side Export

Client-side export uses browser APIs and JavaScript libraries for immediate content download.

Export Formats

FormatLibraryContent TypesMax Size
PDFjspdf + html2canvasDashboards, reports, charts~50 pages
PNGhtml2canvasCharts, dashboard snapshots, lineage4096x4096 px
SVGD3.js native exportIndividual chartsUnlimited
CSVCustom generatorQuery results, data tables~1M rows
Excel (XLSX)xlsx libraryTabular data with formatting~1M rows
JSONJSON.stringifyAPI responses, configurations, metadata~100 MB

Export Dialog

The shared ExportDialog component at frontend/shared/src/components/Export/ExportDialog.tsx provides a unified export interface:

+-----------------------------------------------------------+
|  Export Dashboard: Q4 Revenue Analysis                     |
+-----------------------------------------------------------+
|                                                            |
|  Format:                                                   |
|  [x] PDF    [ ] PNG    [ ] CSV    [ ] Excel               |
|                                                            |
|  Options:                                                  |
|  Page size:       [A4 Landscape    v]                      |
|  Quality:         [High            v]                      |
|  Include filters: [x]                                      |
|  Include title:   [x]                                      |
|  Include timestamp: [x]                                    |
|                                                            |
|  Preview:                                                  |
|  +---------------------------------------------------+    |
|  | [Thumbnail preview of exported content]            |    |
|  +---------------------------------------------------+    |
|                                                            |
|  [Cancel]                                    [Export]      |
+-----------------------------------------------------------+

Export Hook

The useExport hook at frontend/shared/src/hooks/useExport.ts provides the programmatic API:

interface ExportOptions {
  target: string;             // CSS selector of element to capture
  filename?: string;          // Output filename (without extension)
  format?: 'pdf' | 'png' | 'csv' | 'xlsx' | 'json';
  options?: {
    orientation?: 'portrait' | 'landscape';
    pageSize?: 'A4' | 'A3' | 'Letter' | 'Legal';
    quality?: 'low' | 'medium' | 'high';
    margin?: { top: number; right: number; bottom: number; left: number };
    includeFilters?: boolean;
    includeTimestamp?: boolean;
    scale?: number;           // Pixel ratio for PNG (1x, 2x, 3x)
  };
}
 
export function useExport() {
  const [isExporting, setIsExporting] = useState(false);
  const [progress, setProgress] = useState(0);
 
  const exportToPdf = useCallback(async (options: ExportOptions) => { /* ... */ }, []);
  const exportToPng = useCallback(async (options: ExportOptions) => { /* ... */ }, []);
  const exportToCsv = useCallback(async (data: CsvExportData) => { /* ... */ }, []);
  const exportToExcel = useCallback(async (data: ExcelExportData) => { /* ... */ }, []);
  const exportToJson = useCallback(async (data: unknown, filename: string) => { /* ... */ }, []);
 
  return { isExporting, progress, exportToPdf, exportToPng, exportToCsv, exportToExcel, exportToJson };
}

PDF Export Process

1. User clicks Export PDF
        |
        v
2. html2canvas captures the target element as a canvas
   - Respects CSS transforms, shadows, and gradients
   - Handles cross-origin images via proxy
   - Applies scale factor for print quality (2x default)
        |
        v
3. Canvas is converted to PNG data URL
        |
        v
4. jspdf creates a PDF document
   - Sets page orientation and size
   - Adds margins
   - Splits content across pages if needed
   - Adds header (title, timestamp) and footer (page numbers)
        |
        v
5. PDF is saved to the browser download

Server-Side Rendering

For high-fidelity exports and scheduled reports, the Render Service (Node.js, port 8098) provides server-side rendering:

Render Service Capabilities

CapabilityDescription
Dashboard renderingFull dashboard capture with all widgets
Chart renderingIndividual chart rendering with data
Report generationMulti-page reports with table of contents
Thumbnail generationDashboard thumbnails for catalog views
Batch exportMultiple dashboards in a single request

Render API

POST /render/v1/dashboard/{dashboardId}/pdf
POST /render/v1/dashboard/{dashboardId}/png
POST /render/v1/chart/{chartId}/png
POST /render/v1/chart/{chartId}/svg
POST /render/v1/report/generate

Render Request

{
  "dashboardId": "dash-123",
  "format": "pdf",
  "options": {
    "width": 1920,
    "height": 1080,
    "scale": 2,
    "orientation": "landscape",
    "pageSize": "A4",
    "includeFilters": true,
    "filterValues": {
      "region": "Western",
      "dateRange": "last_30_days"
    },
    "waitForSelector": ".chart-rendered",
    "timeout": 30000
  }
}

Dashboard Embedding

Dashboards can be embedded in external applications via iframe with configurable access controls.

Embedding Methods

MethodAuthenticationUse Case
Signed URLTime-limited signed tokenTemporary sharing with external users
API keyTenant-scoped API keyEmbedded in internal applications
SSO passthroughOrganization SSOEmbedded in authenticated portals
Public linkNo authenticationPublic dashboards (explicitly enabled)

Iframe Integration

<!-- Embed a MATIH dashboard -->
<iframe
  src="https://platform.matih.ai/embed/dashboards/dash-123?token=eyJ..."
  width="100%"
  height="600"
  frameborder="0"
  allow="fullscreen"
  sandbox="allow-scripts allow-same-origin allow-popups"
></iframe>

Embed Configuration

ParameterTypeDescription
tokenstringSigned authentication token
themelightdark
hideHeaderbooleanHide the dashboard title bar
hideFiltersbooleanHide the filter bar
filterValuesJSONPre-applied filter values
refreshIntervalnumberAuto-refresh interval in seconds
interactionModeviewexplore

Embed Security

Security MeasureImplementation
Token expirationSigned URLs expire after configurable duration (default: 24 hours)
Tenant scopingEmbedded content is scoped to the tenant context in the token
Row-level securityAll RLS policies apply to embedded views
CORS policyEmbedding domain must be whitelisted in tenant configuration
Content Security Policyframe-ancestors header restricts which domains can embed
Rate limitingEmbedded views have separate rate limits to prevent abuse

Scheduled Reports

Scheduled reports automate recurring export and delivery.

Schedule Configuration

+-----------------------------------------------------------+
|  Schedule Report: Weekly Revenue Summary                   |
+-----------------------------------------------------------+
|                                                            |
|  Dashboard: [Q4 Revenue Analysis   v]                      |
|                                                            |
|  Schedule:                                                 |
|  Frequency:  [Weekly             v]                        |
|  Day:        [Monday             v]                        |
|  Time:       [08:00 AM           v]                        |
|  Timezone:   [America/New_York   v]                        |
|                                                            |
|  Format:     [x] PDF  [ ] PNG  [ ] CSV                    |
|                                                            |
|  Filters:                                                  |
|  Region:     [Dynamic: user's region v]                    |
|  Date range: [Rolling: last 7 days   v]                    |
|                                                            |
|  Delivery:                                                 |
|  [x] Email to: [team@company.com, ceo@company.com]       |
|  [ ] Upload to S3: [s3://reports/weekly/]                 |
|  [ ] Webhook: [https://hooks.slack.com/...]               |
|                                                            |
|  [Cancel]                              [Schedule Report]   |
+-----------------------------------------------------------+

Delivery Channels

ChannelConfigurationDescription
EmailRecipient listPDF/PNG attached to email with summary
S3 / GCS / Azure BlobBucket and pathFile uploaded to cloud storage
WebhookURLPOST request with file URL and metadata
SlackChannel or DMFile posted to Slack with message

Scheduled Report Flow

1. Scheduler triggers at configured time (cron)
        |
        v
2. Report Service retrieves dashboard configuration
        |
        v
3. Dynamic filter values are resolved
   (e.g., "last 7 days" calculated from current date)
        |
        v
4. Render Service generates the export
   - Renders dashboard with resolved filters
   - Produces PDF/PNG/CSV
        |
        v
5. Delivery Service distributes the report
   - Sends emails with attachments
   - Uploads to cloud storage
   - Triggers webhooks
        |
        v
6. Delivery confirmation logged in audit trail

Shareable Links

The platform supports generating shareable links with configurable access controls:

Link Types

Link TypeAuthenticationExpirationUse Case
Workspace linkRequires loginNeverShare with team members
Signed linkToken in URLConfigurable (1h - 30d)Share with external stakeholders
Public linkNoneNever (until revoked)Public dashboards
Snapshot linkNoneConfigurablePoint-in-time snapshot of data

Link Generation

// Generate a shareable link
const shareLink = await biService.createShareLink({
  dashboardId: 'dash-123',
  type: 'signed',
  expiresIn: '7d',
  permissions: {
    canFilter: true,
    canDrillDown: true,
    canExport: false,
  },
  filterValues: {
    region: 'Western',
  },
});
 
// Returns: https://platform.matih.ai/share/dash-123?token=eyJ...

Export in Workbench Context

Each workbench provides context-specific export capabilities:

WorkbenchExport TargetsFormats
BI WorkbenchDashboards, charts, query results, metricsPDF, PNG, CSV, Excel, SVG
Data WorkbenchQuery results, lineage diagrams, quality reportsCSV, JSON, PNG, PDF
ML WorkbenchExperiment results, model comparison, training curvesCSV, PDF, PNG
Agentic WorkbenchConversation transcripts, generated SQL, workflow definitionsPDF, JSON, YAML
Ops WorkbenchHealth reports, incident timelines, cost reportsPDF, CSV
Control Plane UIAudit logs, usage reports, tenant summariesCSV, PDF, Excel

Key Source Files

ComponentLocation
Export dialogfrontend/shared/src/components/Export/ExportDialog.tsx
Export hookfrontend/shared/src/hooks/useExport.ts
Render service APIfrontend/shared/src/api/render.ts
BI service (sharing)frontend/shared/src/api/bi.ts
Dashboard export (BI)frontend/bi-workbench/src/components/dashboard/