ZenStack
A powerful TypeScript data layer providing an intuitive modeling language, type-safe ORM, built-in access control, and automatic query services for modern web frameworks.
ZenStack is a comprehensive data layer for modern TypeScript applications that centers the application around a well-defined data model. By treating the data schema as the single source of truth, ZenStack enables developers to streamline the development lifecycle, ensuring that data modeling, access control, and API generation are cohesive and maintainable. It was built with the goal of providing an ideal balance between low cognitive burden and high flexibility, helping teams scale their applications efficiently as they grow.
Functionally, ZenStack extends the capabilities of traditional database interaction by introducing ZModel, a powerful, intuitive, and Prisma-superset schema language. It includes a high-performance ORM built on top of Kysely that provides both a high-level query API and a low-level SQL query builder. Furthermore, ZenStack provides automatic API and hook generation, enabling developers to build full-stack features, such as data-driven services and frontend queries, without having to write redundant boilerplate code.
Some of the key features are:
- Intuitive Schema Language: Uses a ZModel language that is a superset of the Prisma Schema Language, making it easy to define data models, relationships, access control, and validation rules in one location.
- Flexible and Type-Safe ORM: Includes a powerful ORM built on the Kysely SQL builder, offering high-level query APIs and low-level SQL control with robust type safety.
- Built-in Access Control: Integrates security directly into the data layer, allowing for policy-based control over how data is accessed and modified.
- Automatic Data Query Service: Generates HTTP query services automatically, mirroring the ORM API and integrating seamlessly with popular frameworks like Next.js, Nuxt, and others.
- AI-Friendly Infrastructure: Provides a single, clean source of truth that helps AI-assisted programming tools generate accurate, high-quality code.
- Plugin System: Features a powerful, extensible plugin system that allows deep customization of behavior throughout the development lifecycle.
- Computed Fields: Supports database-side computed fields for efficient data transformation and enrichment.
- Auto-generated Frontend Hooks: Derived hooks based on TanStack Query simplify the process of making type-safe queries from frontend components without writing custom API handlers.
ZenStack is operated via a CLI that compiles the ZModel schema into TypeScript artifacts. Developers define their models in a .zmodel file, and the CLI generates the necessary types, plugins, and query services. The ORM client is then instantiated and configured within the application code, where security policies and authentication contexts can be injected. This approach allows developers to manage their entire data access layer, from the database down to the frontend hooks, through a single declarative file.
Some common use cases include:
- Multi-tenant SaaS Applications: Implementing complex, secure, and performant data separation for different tenants using built-in access control.
- Complex Access Control Requirements: Managing intricate authorization and data visibility rules directly within the data definition.
- Rapid CRUD-intensive API Development: Eliminating the need to manually build and maintain standard CRUD endpoints and API glue code.
- AI Agent Database Integration: Creating robust and type-safe database access for AI agents by providing a well-structured and machine-readable data schema.
Comments
0Markdown is supported.