# Rayfin > Define your backend in TypeScript: database, type-safe APIs, Entra ID auth, functions, storage, and hosting. Rayfin deploys it to Microsoft Fabric — inside your organization's boundary. Rayfin is a backend platform for TypeScript developers. You define entities as decorated TypeScript classes; Rayfin generates the database schema, REST and GraphQL APIs, and type-safe clients, then runs them on Microsoft Fabric with auth, functions, blob storage, and static hosting built in. ## How to use these docs as an agent - Append `.md` to **any** documentation route to get that page as clean Markdown. Example: https://rayfin.ai/docs/data/querying -> https://rayfin.ai/docs/data/querying.md - [AGENTS.md](https://rayfin.ai/AGENTS.md) contains the short operating rules for writing Rayfin code. - Start with [Rules for coding agents](https://rayfin.ai/docs/reference/agent-rules) before generating any Rayfin code. - Every page carries `sdk_version`, `cli_version` and `last_updated` in its frontmatter. Do not mix API shapes across SDK versions. - Features added or changed after Rayfin 1.35.0 are tagged inline, for example `[New in 1.36](/docs/reference/changelog#rayfin-136)`. If the project's installed `@microsoft/rayfin-*` packages are older than the tag, the feature is not available there. See the [changelog](https://rayfin.ai/docs/reference/changelog) for upgrade steps. Documented against `@microsoft/rayfin-*` v1.36.2 and `@microsoft/rayfin-cli` v1.36.2. ## Bulk downloads Prefer a section bundle over the full corpus unless you genuinely need everything. - [llms-full.txt](https://rayfin.ai/llms-full.txt): every page in one file, 925.1 KB (~236k tokens) - [Overview](https://rayfin.ai/llms-full/docs.txt): 1 page, 8.9 KB (~2k tokens) - [Get started](https://rayfin.ai/llms-full/start.txt): 5 pages, 41.2 KB (~10k tokens) - [Data](https://rayfin.ai/llms-full/data.txt): 11 pages, 89.3 KB (~23k tokens) - [Auth](https://rayfin.ai/llms-full/auth.txt): 7 pages, 75.8 KB (~19k tokens) - [Functions](https://rayfin.ai/llms-full/functions.txt): 7 pages, 63.2 KB (~16k tokens) - [Connectors](https://rayfin.ai/llms-full/connectors.txt): 8 pages, 109.7 KB (~28k tokens) - [Storage](https://rayfin.ai/llms-full/storage.txt): 1 page, 12.8 KB (~3k tokens) - [Hosting](https://rayfin.ai/llms-full/hosting.txt): 3 pages, 19.0 KB (~5k tokens) - [Deploy](https://rayfin.ai/llms-full/deploy.txt): 8 pages, 62.3 KB (~16k tokens) - [Recipes](https://rayfin.ai/llms-full/recipes.txt): 3 pages, 41.4 KB (~11k tokens) - [Reference](https://rayfin.ai/llms-full/reference.txt): 39 pages, 404.6 KB (~103k tokens) # Docs - [Rayfin](/docs): Define your data model in TypeScript. Rayfin generates the database and type-safe APIs, then runs them on Microsoft Fabric — with auth, functions, storage, and hosting built in. - **Get started** - [Installation](/docs/start/installation): Install Node.js 20+ and the Rayfin project CLI workflow before scaffolding or deploying a Fabric app. - [Quickstart](/docs/start/quickstart): Scaffold a Rayfin project, sign in to Fabric, run the local development loop, and deploy the app with rayfin up. - [Develop locally](/docs/start/develop-locally): Use rayfin dev to provision or reuse a Fabric backend while running the frontend and Functions locally. - [Project structure](/docs/start/project-structure): Understand the Rayfin scaffold layout, including rayfin.yml, deployment metadata, environment files, and the 1.36 universal app workspace. - [Deploy to Fabric](/docs/start/deploy-to-fabric): Enable Fabric apps, sign in, deploy a Rayfin project with rayfin up, and confirm the static hosting URL. - **Build** - Data: Model entities in TypeScript and query them with a type-safe client. - [Data](/docs/data): Model entities once as decorated TypeScript classes and get a database schema, GraphQL API, type-safe client, permissions, and validation from the same source. - **Model** - [Modeling entities](/docs/data/modeling): Define Rayfin entities as decorated TypeScript classes in rayfin/data/ and register them in schema.ts to get a database table and a typed API. - [Field types](/docs/data/field-types): Complete reference for Rayfin's field decorators — @uuid, @text, @int, @decimal, @boolean, @date, @email, @set, and @blob — and the options each accepts. - [Relationships](/docs/data/relationships): Model one-to-many associations between Rayfin entities with @one and @many, and work around the lack of native many-to-many support. - [Permissions and row-level security](/docs/data/permissions): Secure Rayfin entities with @role, @anonymous, and @authenticated, including row-level policies, field visibility, action-specific rules, and multi-tenant scoping. - **Read and write** - [Querying](/docs/data/querying): Read Rayfin entities with the type-safe select/where/orderBy/execute chain, including filtering, sorting, and cursor pagination. - [Aggregations](/docs/data/aggregations): Compute sums, averages, minimums, maximums, and counts over your entities with groupBy() and aggregate(), including grand totals and having filters. - [Creating, updating, deleting](/docs/data/mutations): Create, update, and delete Rayfin records through the type-safe client, and set relationship fields correctly in mutations. - [Validation](/docs/data/validation): Generate a Standard Schema validator directly from a Rayfin entity to validate form input without a separate validation library. - **Operate** - [Schema changes](/docs/data/migrations): Apply Rayfin entity changes to the database with rayfin up and rayfin up db apply, and verify the schema actually reached the server. - [Seeding data](/docs/data/seeding): Populate @anonymous() Rayfin entities with RayfinServerClient in a Node.js script — @authenticated() entities have no scripted seeding path today. - Auth: Sign users in with Microsoft Entra ID. - [Auth](/docs/auth): Choose a Microsoft Entra sign-in path for Rayfin apps: Fabric SSO, direct Entra token exchange, external embed host, and sessions. - [Fabric SSO](/docs/auth/fabric-sso): Sign users in with Microsoft Entra ID through Fabric SSO, using the popup flow for browser apps or embedded flow in the Fabric portal. - [Sign in with an Entra token](/docs/auth/entra-token): Exchange an existing delegated Microsoft Entra access token for a Rayfin session in browser or Node.js code. - [Embed in your own portal](/docs/auth/embed-host): Use the external embed host to sign a Rayfin app in when your own portal embeds it in an iframe. - [Sessions](/docs/auth/sessions): Use Rayfin's opaque auth session safely: read documented fields, subscribe with onSessionChange, refresh, and sign out. - [Delegated and application access](/docs/auth/delegated-access): Which identity each server-side Rayfin surface uses — the signed-in user or the app — and what access to grant at each data source. - [React integration](/docs/auth/react): Add a Rayfin AuthProvider, useAuth hook, route guard, Fabric SSO startup, and sign-in button to a React app. - Functions: Run server-side TypeScript alongside your data. - [Functions](/docs/functions): Run server-side TypeScript in Rayfin with typed frontend calls, typed secrets, and app-identity connections to Azure and Fabric resources. - [Writing a function](/docs/functions/writing-functions): Register Rayfin functions with udf.func, use RayfinContext for typed data access, and keep generated frontend types in sync. - [Secrets in functions](/docs/functions/secrets): Declare Rayfin secrets with the CLI, read them as typed ctx.Secrets properties, and supply local values through local.settings.json. - [Connections](/docs/functions/connections): Give Rayfin functions app-identity tokens for Fabric SQL, OneLake, Fabric REST, Azure AI Foundry, and Azure DevOps. - [Calling functions from your app](/docs/functions/calling-functions): Invoke Rayfin functions from the frontend with RayfinClient, AppFunctionsSchema, per-call options, and local Vite routing. - [Run functions locally](/docs/functions/local-development): Start the local Rayfin Functions host with rayfin dev, route frontend calls, attach a debugger, and troubleshoot local host errors. - [Deploying functions](/docs/functions/deploying): Deploy Rayfin functions with rayfin up, deploy only function code, skip function deploys, and understand deploy-time packaging. - Connectors: Query Fabric warehouses, SQL databases, semantic models, and KQL databases from your app. - [Connectors](/docs/connectors): Read and write existing Microsoft Fabric data — warehouses, SQL databases, Lakehouse SQL endpoints, semantic models, and KQL databases — from a Rayfin app. - [Adding a connector](/docs/connectors/adding): Discover Fabric sources, add a connector to rayfin.yml, install its pinned packages, and manage connector entries safely. - [Wiring connectors into your app](/docs/connectors/client-setup): Configure ConnectorsRayfinClient with connector schemas, runtime hooks, and generated connectorConfig maps. - [Fabric SQL sources](/docs/connectors/sql-sources): Read and write Fabric SQL connector entities from Rayfin apps, including query chains, by-key reads, mutations, defaults, and troubleshooting. - [Generating entity files](/docs/connectors/entity-generation): Generate Category A connector entity files from metadata.json, including keys, relationships, permissions, aggregate schema, and apply steps. - [Semantic models](/docs/connectors/semantic-models): Run DAX against a Fabric semantic model from a Rayfin app and handle typed table results, row limits, and connector diagnostics. - [KQL databases](/docs/connectors/kusto): Run KQL queries and Kusto management commands against a Fabric KQL Database from a Rayfin app. - [Connector authentication](/docs/connectors/auth): Configure connector auth.type values, validation rules, and caller identity for delegated and application connector access. - Storage: Store and serve files with the blob storage client. - [Storage](/docs/storage): Enable experimental Rayfin Storage, declare blob folders, configure object rules, and call the typed storage client. - Hosting: Serve your frontend from the same app as your backend. - [Static content hosting](/docs/hosting): Configure Rayfin static hosting, asset access, package version declarations, deployment commands, and the 100 MB archive limit. - [Redirect URIs](/docs/hosting/redirect-uris): Configure allowedRedirectUris for Fabric SSO, local rayfin dev ports, static hosting origins, and retained frontend port aliases. - [Deep linking](/docs/hosting/deep-linking): Use @microsoft/rayfin-app-state-fabric to store shareable app state in Fabric portal URLs for embedded Rayfin apps. - **Ship** - Deploy: Ship your app to Microsoft Fabric. - [Deploy](/docs/deploy): Deploy Rayfin projects to managed Fabric apps, manage deployment targets, and understand capacity and static hosting. - [Fabric apps](/docs/deploy/fabric-apps): Understand the Fabric App (preview) item Rayfin deploys into, including services, permissions, capacity, and portal creation. - [Deploying with rayfin up](/docs/deploy/rayfin-up): Deploy a Rayfin project with rayfin up, including login, capacity readiness, targeting flags, dry runs, and deployment metadata. - [Deployment pipelines](/docs/deploy/deployment-pipelines): Prepare Rayfin apps for Microsoft Fabric Deployment Pipelines by resolving runtime config instead of baking stage values into the bundle. - [Secrets](/docs/deploy/secrets): Set, list, delete, and type Rayfin secrets so functions can read server-only values without exposing them to client code. - [Environments and configuration](/docs/deploy/environments): Understand Rayfin environment files, deployment records, frontend variables, and workspace targeting rules. - [Capacity and billing](/docs/deploy/pricing): Learn which Fabric services behind a Rayfin app consume capacity units and which deployment operations have no separate Rayfin charge. - [Deployment troubleshooting](/docs/deploy/troubleshooting): Fix common rayfin up, capacity, static hosting, and deployment-target errors using exact CLI messages. - Recipes: End-to-end walkthroughs for common application patterns. - [Recipes](/docs/recipes): End-to-end walkthroughs that combine Rayfin's data, auth, and deployment features into complete application patterns. - [Build a todo app](/docs/recipes/todo-app): Build a Fabric-authenticated todo app end to end, from a per-user data model through a React UI to a deploy on Microsoft Fabric. - [Testing a Rayfin app](/docs/recipes/testing): Test Rayfin data and auth logic in Vitest with injectable auth stubs and the todo template's in-memory data seam. - **Reference** - [Reference overview](/docs/reference): Landing page for the complete Rayfin reference — CLI commands, configuration schema, SDK packages, rules for coding agents, known limitations, deprecations, and troubleshooting. - [Changelog](/docs/reference/changelog): What changed in each Rayfin release these docs cover — new features, behavior changes, and step-by-step upgrade instructions, linked to the pages that document them. - CLI: Every rayfin command, flag, and subcommand. - [CLI](/docs/reference/cli): Overview of the rayfin CLI — root options, the Fabric development workflow, and links to every visible command in Rayfin 1.36.2. - [CLI installation](/docs/reference/cli/installation): Install @microsoft/rayfin-cli for a project, verify the version, and keep the CLI aligned with the Rayfin packages in package.json. - [rayfin init](/docs/reference/cli/init): Scaffold a new Rayfin project, add Rayfin to an existing directory, select templates, and choose services with rayfin init. - [rayfin dev](/docs/reference/cli/dev): Start a local frontend and optional Functions runtime against a deployed Fabric Rayfin backend with rayfin dev. - [rayfin login](/docs/reference/cli/login): Sign in to Rayfin for Fabric operations, inspect status, sign out, and understand token cache storage. - [rayfin up](/docs/reference/cli/up): Deploy a Rayfin project to Fabric, resolve workspace and capacity, apply schema and settings, and run deploy-only up subcommands. - [rayfin secret](/docs/reference/cli/secret): Command reference for setting, listing, deleting, describing, bulk importing, and typing Rayfin secrets for Functions. - [rayfin env](/docs/reference/cli/env): Emit framework-specific .env.local files from rayfin/.env for Vite, Next.js, or plain frontend tooling. - [rayfin functions](/docs/reference/cli/functions): Command reference for scaffolding, running, and deploying Rayfin Functions projects with functions init and related dev/up commands. - [rayfin connector](/docs/reference/cli/connector): rayfin connector manages external Fabric sources, from discovery and registration through inspection and invocation. - [rayfin docs](/docs/reference/cli/docs): Search, list, fetch, discover, and inspect Rayfin package documentation from the terminal with rayfin docs. - [rayfin init ai-files](/docs/reference/cli/ai-files): Install, refresh, disable, and audit Rayfin-managed agent files with rayfin init ai-files install and status. - [Templates](/docs/reference/cli/templates): Use built-in, local, git, and registered Rayfin templates, including the 1.36 universal-app starter and registry behavior. - [Telemetry](/docs/reference/cli/telemetry): What Rayfin CLI telemetry records, what it never records, and the environment variables that control telemetry. - Configuration: rayfin.yml and environment variable reference. - [Configuration](/docs/reference/config): Reference for Rayfin project configuration, environment variables, and rayfin.yml interpolation in Rayfin 1.36.2. - [rayfin.yml reference](/docs/reference/config/rayfin-yml): Complete Rayfin 1.36.2 rayfin.yml schema for services, static hosting, Functions, storage, connectors, and secret declarations. - [Environment variables](/docs/reference/config/environment-variables): Exhaustive Rayfin 1.36.2 environment variable reference for frontend builds, CLI overrides, feature flags, telemetry, and file locations. - [Environment variable interpolation](/docs/reference/config/env-interpolation): Use ${VAR} and ${VAR:-default} in rayfin.yml with Rayfin's .env resolution, type coercion, and missing-variable errors. - SDK: API reference for every @microsoft/rayfin-* package. - [SDK](/docs/reference/sdk): Choose the right @microsoft/rayfin-* package, keep package versions in lockstep, and find each SDK reference page. - [@microsoft/rayfin-core](/docs/reference/sdk/rayfin-core): Complete decorator reference for @microsoft/rayfin-core — entities, field types, relationships, and permissions that generate Data API Builder configuration. - [@microsoft/rayfin-client](/docs/reference/sdk/rayfin-client): RayfinClient construction, configuration options, and the client.data, client.auth, and client.functions facades, with exact signatures from the SDK. - [@microsoft/rayfin-data](/docs/reference/sdk/rayfin-data): The fluent GraphQL query and mutation API behind client.data — select, where, orderBy, pagination, and CRUD methods with exact signatures. - [@microsoft/rayfin-auth](/docs/reference/sdk/rayfin-auth): Auth client reference for sessions, storage options, refresh, sign-out, events, and provider integration points in Rayfin apps. - [@microsoft/rayfin-auth-provider-fabric](/docs/reference/sdk/rayfin-auth-provider-fabric): Fabric auth provider reference for Fabric SSO, direct Entra token exchange, embedded handoff, and external embed support. - [@microsoft/rayfin-embed-host](/docs/reference/sdk/rayfin-embed-host): Parent-page SDK reference for brokering external Entra authentication into a Rayfin app embedded in an iframe. - [@microsoft/rayfin-functions](/docs/reference/sdk/rayfin-functions): SDK reference for FunctionClient, FunctionsSchema, InvokeOptions, FunctionsError, and typed client.functions invocations. - [@microsoft/rayfin-storage](/docs/reference/sdk/rayfin-storage): Type-safe client SDK for experimental Rayfin Storage folders, including client composition, operation options, result shapes, and error codes. - [@microsoft/rayfin-connectors](/docs/reference/sdk/rayfin-connectors): Connector runtime APIs for mounting typed Fabric SQL, semantic model, and KQL Database connectors on the Rayfin client. - [@microsoft/rayfin-connector-fabric-graphql](/docs/reference/sdk/rayfin-connector-fabric-graphql): Marker APIs for Category A Fabric SQL connectors that expose typed entity CRUD through client.connectors. - [@microsoft/rayfin-connector-fabric-semanticmodel](/docs/reference/sdk/rayfin-connector-fabric-semanticmodel): Marker, runtime, direct execution, URL parsing, Arrow decoding, and normalized result APIs for Fabric semantic model connectors. - [@microsoft/rayfin-connector-kusto](/docs/reference/sdk/rayfin-connector-kusto): Marker, runtime, config, raw response, and normalization APIs for Fabric KQL Database connectors. - [@microsoft/rayfin-app-state-fabric](/docs/reference/sdk/rayfin-app-state-fabric): SDK reference for Fabric-hosted deep-link state: createFabricAppStateClient, state limits, capabilities, listeners, and errors. - [@microsoft/rayfin-lib](/docs/reference/sdk/rayfin-lib): The shared ApiClient, error classes, and small utilities every other Rayfin SDK package builds on — an internal dependency most builders never import directly. - [Rules for coding agents](/docs/reference/agent-rules): The condensed set of rules and anti-patterns for writing Rayfin code — read this before generating entities, queries, permissions, functions, connectors, or deployment commands. - [Known limitations](/docs/reference/known-limitations): Current constraints in Rayfin — service availability, functions, connectors, the data client, Data API Builder, relationships, auth, and schema apply — each with a workaround. - [Deprecations](/docs/reference/deprecations): APIs, settings, and flags deprecated or removed in recent Rayfin releases with their replacements, and how to silence Rayfin's deprecation warnings. - [Errors and troubleshooting](/docs/reference/errors): A symptom-to-fix index of the errors Rayfin builders hit most — deployment, capacity, static hosting, schema apply, secrets, functions, connectors, and Fabric auth.