Skip to content

Integrations

External integrations and third-party services in Lager Guru.

Overview

Lager Guru integrates with various external services and APIs for enhanced functionality, including Supabase, Edge Functions, webhooks, scanners, and RFID systems.

Supabase Client Configuration

Client Setup

Lager Guru uses Supabase as the backend-as-a-service platform.

Configuration: src/integrations/supabase/client.ts

typescript
import { createClient } from '@supabase/supabase-js';

const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY;

export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
  auth: {
    persistSession: true,
    autoRefreshToken: true,
    detectSessionInUrl: true
  },
  realtime: {
    params: {
      eventsPerSecond: 10
    }
  }
});

Environment Variables

Required environment variables:

env
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-key
VITE_SUPABASE_SERVICE_ROLE_KEY=your-service-role-key  # Server-side only

Features

  • Authentication: User authentication and session management
  • Database: PostgreSQL database with Row-Level Security
  • Realtime: Real-time subscriptions for live updates
  • Storage: File storage for documents and images
  • Edge Functions: Serverless functions for backend logic

Edge Functions

Overview

Supabase Edge Functions are serverless functions that run on Deno runtime. They're used for:

  • Server-side operations that require service role
  • External API integrations
  • Background processing
  • Webhook handlers

Available Functions

sso-callback

Handles SSO authentication callbacks (OIDC/SAML).

Location: supabase/functions/sso-callback/index.ts

Usage:

typescript
// Called automatically by SSO provider
// Handles OIDC/SAML callbacks
// Maps SSO user to tenant

webhook-handler

Processes incoming webhooks from external systems.

Location: supabase/functions/webhook-handler/index.ts

Usage:

typescript
// Receives webhook payloads
// Validates webhook signatures
// Processes webhook events

tenant-bootstrap

Bootstraps new tenant with initial data.

Location: supabase/functions/tenant-bootstrap/index.ts

Usage:

typescript
// Creates tenant structure
// Sets up initial zones
// Configures default settings

Calling Edge Functions

typescript
import { supabase } from '@/integrations/supabase/client';

// Call edge function
const { data, error } = await supabase.functions.invoke('function-name', {
  body: { /* payload */ }
});

if (error) {
  console.error('Error:', error);
  return;
}

console.log('Result:', data);

Edge Function Rate Limits

  • Standard Functions: 1000 invocations per minute
  • Background Functions: 500 invocations per minute
  • Webhook Functions: 200 invocations per minute

See Rate Limits for details.


External Webhooks

Outgoing Webhooks

Lager Guru can send webhooks to external systems when events occur.

Supported Events:

  • Order created
  • Shipment assigned
  • Pick list completed
  • Inventory movement
  • Equipment position updated

Webhook Configuration

typescript
// Configure webhook endpoint
const webhookConfig = {
  url: 'https://your-system.com/webhook',
  secret: 'webhook-secret',
  events: ['order.created', 'shipment.assigned']
};

Webhook Payload

typescript
{
  event: 'order.created',
  timestamp: '2025-01-15T10:30:00Z',
  tenant_id: 'tenant-uuid',
  data: {
    order_id: 'order-uuid',
    // ... order data
  }
}

Webhook Security

Webhooks include:

  • Signature: HMAC signature for verification
  • Timestamp: Prevents replay attacks
  • Tenant ID: Identifies source tenant

See Webhooks for detailed documentation.


Scanner / Barcode Integrations

Barcode Scanner

Lager Guru supports barcode scanning via:

  • Camera-based scanning (browser)
  • USB barcode scanners
  • Mobile device cameras

Component: src/components/ui/BarcodeScanner.tsx

Usage

typescript
import { BarcodeScanner } from '@/components/ui/BarcodeScanner';

function ScanComponent() {
  const handleScan = (result: string) => {
    console.log('Scanned:', result);
    // Process barcode result
  };
  
  return (
    <BarcodeScanner
      onScan={handleScan}
      onError={(error) => console.error(error)}
    />
  );
}

Supported Formats

  • EAN-13: European Article Number
  • EAN-8: Short EAN
  • UPC-A: Universal Product Code
  • Code 128: Alphanumeric barcode
  • QR Code: Quick Response code

Scanner Configuration

typescript
const scannerConfig = {
  formats: ['ean_13', 'ean_8', 'code_128', 'qr_code'],
  continuous: true,
  videoConstraints: {
    facingMode: 'environment' // Use back camera
  }
};

RFID Support

RFID Integration

RFID (Radio Frequency Identification) support for equipment tracking.

Features:

  • Automatic equipment detection
  • Zone-based tracking
  • Real-time position updates
  • Maintenance scheduling

RFID Setup

  1. Configure RFID Reader

    • Connect RFID reader to system
    • Configure reader settings
    • Test reader connection
  2. Register Equipment

    • Assign RFID tags to equipment
    • Link tags to equipment records
    • Configure tracking zones
  3. Enable Tracking

    • Enable RFID tracking in settings
    • Configure update frequency
    • Set up notifications

RFID Data Format

typescript
interface RFIDData {
  tag_id: string;        // RFID tag identifier
  equipment_id: string;  // Linked equipment
  zone_id: string;      // Current zone
  timestamp: string;     // Detection timestamp
  signal_strength: number; // RSSI value
}

OAuth / SSO Integrations

OIDC Integration

OpenID Connect (OIDC) support for enterprise SSO.

Configuration:

typescript
const oidcConfig = {
  issuer: 'https://auth.example.com',
  client_id: 'client-id',
  client_secret: 'client-secret',
  redirect_uri: 'https://app.example.com/callback',
  scopes: ['openid', 'profile', 'email']
};

See OIDC Setup for detailed instructions.

SAML Integration

SAML 2.0 support for enterprise SSO.

Configuration:

typescript
const samlConfig = {
  entity_id: 'https://app.example.com',
  acs_endpoint: 'https://app.example.com/saml/acs',
  issuer: 'https://idp.example.com',
  certificate: 'base64-certificate'
};

See SAML Setup for detailed instructions.


Payment Integrations

Payment Processing

Payment integration support (reserved for future expansion).

Status: Not implemented — reserved for future expansion.


Email Integration

Email Notifications

Email notifications via Supabase or external SMTP.

Configuration:

typescript
// Supabase email (built-in)
// Configure in Supabase dashboard → Settings → Auth → Email Templates

// External SMTP (future)
const smtpConfig = {
  host: 'smtp.example.com',
  port: 587,
  secure: false,
  auth: {
    user: 'username',
    pass: 'password'
  }
};

Analytics Integrations

Analytics Tracking

Analytics integration support (reserved for future expansion).

Status: Not implemented — reserved for future expansion.


Best Practices

  1. Secure Credentials: Never expose API keys in client-side code
  2. Error Handling: Always handle integration errors gracefully
  3. Rate Limiting: Respect API rate limits
  4. Retry Logic: Implement retry logic for transient failures
  5. Monitoring: Monitor integration health and errors

Released under Commercial License