TypedChrono

Tutorials

Step-by-step guides to help you master SchoBase, from basic setup to advanced industrial integrations and real-time analytics.

Getting Started with SchoBase

Beginner15 minutes

This tutorial will walk you through installing SchoBase, defining your first schema, and writing time series data.

1

Install SchoBase

Install the SchoBase SDK using your preferred package manager:

npm install schobase zod
2

Define Your Schema

Create a schema for your time series data using Zod validators:

import { defineSchema } from 'schobase'
import { z } from 'zod'

const schema = defineSchema({
  tables: {
    temperatures: {
      validator: z.object({
        sensorId: z.string(),
        timestamp: z.date(),
        temperature: z.number().min(-40).max(125),
        location: z.string(),
      }),
      timeIndex: 'timestamp',
      indexes: ['sensorId', 'location'],
    },
  },
})
3

Initialize the Client

Create a client instance with your credentials:

import { createClient } from 'schobase'

const client = createClient({
  endpoint: process.env.SCHOBASE_ENDPOINT,
  apiKey: process.env.SCHOBASE_API_KEY,
  schema,
})
4

Write Your First Data Point

Write a temperature reading to the database:

await client.temperatures.write({
  sensorId: 'temp-sensor-01',
  timestamp: new Date(),
  temperature: 23.5,
  location: 'warehouse-a',
})

console.log('Data written successfully!')
5

Query Your Data

Retrieve data with type-safe queries:

const readings = await client.temperatures
  .query()
  .where('sensorId', '==', 'temp-sensor-01')
  .timeRange({
    start: new Date(Date.now() - 3600000), // Last hour
    end: new Date(),
  })
  .orderBy('timestamp', 'desc')
  .limit(10)
  .execute()

console.log('Recent readings:', readings)

Congratulations!

You've successfully set up SchoBase and written your first time series data. Check out the other tutorials to learn more advanced features.

Building a Real-Time Dashboard

Intermediate30 minutes

Build a React dashboard with live data updates using SchoBase real-time subscriptions.

What You'll Build

  • Real-time line chart showing temperature trends
  • Live metrics cards (current, min, max, average)
  • Automatic reconnection and error handling
  • Alert system for threshold violations

Prerequisites

This tutorial assumes you've completed the Getting Started tutorial and have a working SchoBase client.

Key Code Snippet

import { useEffect, useState } from 'react'
import { client } from './schobase'

function TemperatureDashboard() {
  const [readings, setReadings] = useState([])

  useEffect(() => {
    const unsubscribe = client.temperatures
      .subscribe()
      .where('location', '==', 'warehouse-a')
      .onUpdate((reading) => {
        setReadings((prev) => [...prev.slice(-99), reading])
      })

    return unsubscribe
  }, [])

  return (
    <div>
      <LineChart data={readings} />
      <MetricsGrid readings={readings} />
    </div>
  )
}

Connecting to OPC UA Servers

Intermediate25 minutes

Learn how to connect to industrial OPC UA servers and automatically ingest data into SchoBase.

What You'll Learn

  • OPC UA connection setup with security modes
  • Browse OPC UA address space and subscribe to nodes
  • Automatic data transformation and validation
  • Error handling and reconnection strategies

Example Configuration

import { OpcUaAdapter } from 'schobase'

const opcua = new OpcUaAdapter({
  endpoint: 'opc.tcp://plc-01.factory.local:4840',
  securityMode: 'SignAndEncrypt',
  securityPolicy: 'Basic256Sha256',
  credentials: {
    username: process.env.OPCUA_USER,
    password: process.env.OPCUA_PASSWORD,
  },
})

// Subscribe to multiple nodes
await opcua.subscribe([
  { nodeId: 'ns=2;s=Temperature', samplingInterval: 1000 },
  { nodeId: 'ns=2;s=Pressure', samplingInterval: 1000 },
  { nodeId: 'ns=2;s=FlowRate', samplingInterval: 500 },
])

Pro Tip: Use the SignAndEncrypt security mode for production deployments to ensure data integrity and confidentiality.

More Tutorials

Time Series Analytics

Coming Soon

Robot Telemetry

Coming Soon

Security Hardening

Coming Soon

Need Help with Your Project?

Join our community to get support, share your progress, and learn from other developers.