> ## Documentation Index
> Fetch the complete documentation index at: https://ksync.klastra.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Welcome to kSync v0.2 - Enterprise-grade, real-time sync engine for modern applications

<img className="block dark:hidden" src="https://mintcdn.com/klastra/fOXNfdt5r9HdQIx7/logo/light.png?fit=max&auto=format&n=fOXNfdt5r9HdQIx7&q=85&s=95b3be68c2021d9616907e24abac3115" alt="Hero Light" width="606" height="357" data-path="logo/light.png" />

<img className="hidden dark:block" src="https://mintcdn.com/klastra/fOXNfdt5r9HdQIx7/logo/dark.png?fit=max&auto=format&n=fOXNfdt5r9HdQIx7&q=85&s=548c89a8ae4bb8e7eb581ccca1df9968" alt="Hero Dark" width="1819" height="1067" data-path="logo/dark.png" />

## What is kSync?

kSync v0.2 is an **enterprise-grade, real-time sync engine** that delivers 600k+ operations per second with developer-friendly APIs. Designed for modern web and AI applications that need instant real-time collaboration, streaming support, and production-ready scalability — without the complexity.

<CardGroup cols={2}>
  <Card title="🚀 Factory Functions" icon="magic-wand" href="/guides/factory-functions">
    Instant setup with createChat(), createGame(), createAI() - optimized for your use case
  </Card>

  <Card title="⚡ 600k+ ops/sec" icon="bolt" href="/benchmarks">
    Enterprise-scale performance with only 2MB memory for 1000 concurrent clients
  </Card>

  <Card title="🎯 Smart Defaults" icon="bullseye" href="/quickstart">
    Works instantly without configuration - just import and start building
  </Card>

  <Card title="📡 Streaming Support" icon="stream" href="/guides/streaming">
    Real-time AI responses and live data streams with built-in chunk management
  </Card>

  <Card title="👥 Presence System" icon="users" href="/guides/presence">
    Advanced user presence with metadata, status tracking, and room management
  </Card>

  <Card title="🔧 50+ Config Options" icon="cog" href="/api-reference/configuration">
    Comprehensive configuration with full TypeScript documentation
  </Card>
</CardGroup>

## Key Features

<AccordionGroup>
  <Accordion title="🚀 Factory Functions & Smart Defaults" icon="magic-wand">
    Get started instantly with createKSync(), createChat(), createTodos(), createGame(), createAI() - each optimized for specific use cases with intelligent defaults.
  </Accordion>

  <Accordion title="⚡ Enterprise Performance" icon="bolt">
    600k+ operations per second with only 2MB memory usage for 1000 clients. Network resilient with graceful 10-200ms latency handling.
  </Accordion>

  <Accordion title="📡 Advanced Streaming" icon="stream">
    Built-in support for AI streaming responses, live data streams, and real-time chunk processing with automatic flow control.
  </Accordion>

  <Accordion title="👥 Comprehensive Presence" icon="users">
    Real-time user presence with status tracking, metadata support, room-based isolation, and automatic cleanup.
  </Accordion>

  <Accordion title="🌐 Multi-Room Architecture" icon="layer-group">
    Automatic room management and routing with isolated event streams and presence tracking per room.
  </Accordion>

  <Accordion title="💾 Offline-First Design" icon="hard-drive">
    Advanced offline support with event queueing, persistence, and automatic sync when reconnected.
  </Accordion>

  <Accordion title="🔧 Comprehensive Configuration" icon="cog">
    50+ configuration options with full TypeScript documentation covering performance, authentication, debugging, and features.
  </Accordion>

  <Accordion title="🔒 Enterprise Security" icon="shield-check">
    Authentication providers, token management, client-side encryption options, and secure WebSocket connections.
  </Accordion>

  <Accordion title="📊 Built-in Monitoring" icon="chart-line">
    Performance metrics, debugging tools, status monitoring, and comprehensive logging for production deployments.
  </Accordion>

  <Accordion title="🔄 Backward Compatibility" icon="arrows-rotate">
    All v0.1 APIs continue to work without changes while gaining access to new v0.2 features.
  </Accordion>
</AccordionGroup>

## Why Choose kSync v0.2?

<Tabs>
  <Tab title="Instant">
    **Ready in seconds, not hours**

    Factory functions with smart defaults mean you can start building real-time features immediately without complex configuration.
  </Tab>

  <Tab title="Fast">
    **600k+ ops/sec performance**

    Enterprise-grade performance with memory efficiency - only 2MB for 1000 concurrent clients with 10k events.
  </Tab>

  <Tab title="Smart">
    **Intelligent defaults that just work**

    Automatically optimized for your use case - chat apps get presence, games get low-latency, AI apps get streaming.
  </Tab>

  <Tab title="Scalable">
    **From prototype to production**

    Proven to handle 500+ concurrent clients with network resilience and enterprise-ready monitoring.
  </Tab>

  <Tab title="Developer-Friendly">
    **API designed for humans**

    Comprehensive TypeScript support, clear error messages, and extensive documentation with real-world examples.
  </Tab>
</Tabs>

## Quick Examples

### Instant Chat Application

```typescript theme={null}
import { createChat } from '@klastra/ksync';

// Chat app with presence and optimized batching
const chat = createChat('my-room', {
  serverUrl: 'ws://localhost:8080'
});

// Set user presence
await chat.setPresence({
  status: 'online',
  metadata: { name: 'Alice', avatar: 'avatar-url' }
});

// Send messages
await chat.send('message', {
  text: 'Hello everyone!',
  author: 'Alice',
  timestamp: Date.now()
});

// Listen for messages
chat.on('message', (data) => {
  console.log(`${data.author}: ${data.text}`);
});
```

### AI Streaming Application

```typescript theme={null}
import { createAI } from '@klastra/ksync';

// AI with streaming responses
const ai = createAI('assistant', {
  features: { streaming: true }
});

// Listen for streaming chunks
ai.on('stream-chunk', (data) => {
  process.stdout.write(data.data); // Live AI response
});

// Start AI response stream
await ai.startStream('response-1');
await ai.streamChunk('response-1', { data: 'Hello! ' });
await ai.streamChunk('response-1', { data: 'How can I help?' });
await ai.endStream('response-1');
```

### Basic Real-time Sync

```typescript theme={null}
import { createKSync } from '@klastra/ksync';

// Works instantly with smart defaults
const ksync = createKSync();

// Listen for events
ksync.on('message', (data, event) => {
  console.log(`${event.userId}: ${data.text}`);
});

// Send events (instant local, auto-synced if server configured)
await ksync.send('message', {
  text: 'Hello world!',
  timestamp: Date.now()
});
```

## Use Cases

kSync v0.2 is perfect for:

* **💬 Real-time chat applications** with presence, typing indicators, and multi-room support
* **🎮 Multiplayer games** with low-latency updates, player presence, and state synchronization
* **🤖 AI-powered applications** with streaming responses, real-time feedback, and conversation management
* **📝 Collaborative editing** with conflict-free operations and real-time cursors
* **📊 Live dashboards** with real-time data updates and user presence
* **📋 Project management** with task updates, team collaboration, and offline sync
* **🏪 E-commerce platforms** with real-time inventory, cart sync, and customer presence
* **📱 Mobile applications** with offline-first design and automatic sync
* **🏢 Enterprise tools** requiring high performance, security, and reliability

## Performance at Scale

<Callout type="info">
  **Enterprise Benchmarks**: kSync v0.2 delivers exceptional performance:

  * 🎯 **600k+ ops/sec** for 500 concurrent clients
  * 🧠 **2MB memory** for 1000 clients + 10k events
  * 🌐 **Network resilient** - handles 10-200ms latency gracefully
  * 💬 **300k+ ops/sec** for high-load chat across multiple rooms
</Callout>

## Getting Started

<CardGroup cols={2}>
  <Card title="Quick Start" icon="play" href="/quickstart">
    Get up and running with kSync v0.2 in under 2 minutes
  </Card>

  <Card title="Installation" icon="download" href="/installation">
    Install kSync and set up your development environment
  </Card>

  <Card title="Factory Functions" icon="magic-wand" href="/guides/factory-functions">
    Learn about optimized presets for different application types
  </Card>

  <Card title="Performance Benchmarks" icon="chart-line" href="/benchmarks">
    See detailed performance metrics and optimization guides
  </Card>
</CardGroup>

***

**kSync v0.2: From prototype to production, without the complexity.**
