Skip to main content

Why TeaQL Rust?

A Rust Domain-Driven Data Framework tailored for the AI Era and Enterprise Compliance

In traditional software engineering, ORMs are merely tools for mapping objects to tables. However, in today's landscape where AI-assisted code generation is ubiquitous and enterprise data compliance is increasingly stringent, we need to redefine what a data framework is.

TeaQL abandons the narrow, traditional focus of "only caring about how to generate SQL" and instead reconstructs the value paradigm of a data runtime from the perspective of six core roles in the software lifecycle.


1. Architect & Compliance Perspective

Core Demands: Data isolation, privacy protection, and absolute safety of the architectural foundation.

Architects usually do not care about how CRUD is written; they care about whether the system suffers from cross-tenant/cross-user privilege escalation, whether database leaks will expose private data, and whether the system can pass rigorous compliance audits like SOC2.

  • UserContext-Based Safety Net: TeaQL makes UserContext an absolute precondition for all database operations. This is not just a simple connection pool, but a sandbox environment containing tenant IDs, user tokens, and permission declarations.
  • Enforced Row-Level Security (RLS): Through the TypedChecker interceptor, architects can globally force the injection of tenant_id = ? conditions at the bottom layer, physically blocking privilege escalation vulnerabilities at the framework level.
  • Non-Repudiable Audit Trail: With the built-in EntityEventSink, any state transition of data (e.g., [PLANNED -> READY]) automatically generates a structured audit trail, directly satisfying financial-grade compliance requirements.

2. AI Coder Perspective

Core Demands: High modularity, unambiguous contracts, and extremely high-density context.

In the future, 80% of code will be generated by AI. AI dislikes implicit conversions and prose-like documentation without examples; AI loves strong patterns.

  • Highly Isomorphic API Surface: TeaQL employs highly predictable fluent chain patterns such as Q::entity().facet_by... and entity.audit_as("Save operation").save(&ctx). AI only needs to see an example once to accurately infer 100% of the CRUD code for all tables.
  • Machine-Friendly Rustdocs: Avoiding long-winded text, the documentation is entirely composed of minimal executable examples containing preconditions, generic bounds, and # Errors contracts. Paired with the built-in .cursorrules, it helps AI write perfect best practices from the very first line of code.

3. Human Reviewer Perspective

Core Demands: Understand business intent at a glance, rather than getting lost in SQL joins and logic.

If code is generated by AI, the human job shifts to code review. Reviewers dread looking at dozens of lines of string-concatenated SQL logic.

  • Declarative Domain Graphs: Instead of seeing raw INSERT/UPDATE statements, reviewers see task.logs_mut().push(log); task.save(). Business logic (dispatching tasks) and underlying persistence (cascading storage) are completely decoupled.
  • Intent-Driven Code: Through Q::tasks().comment("Get high-priority overdue tasks"), reviewers can directly see the business intent in the code without having to guess what the query is for.

4. SRE / Ops Perspective

Core Demands: Instantly locate specific business code and context when slow queries or dirty data occur.

SQL generated by traditional ORMs is like hieroglyphics. When a DBA finds a slow query that locks a table, developers often fail to recognize which part of the code initiated it.

  • Business Intent SQL Propagation: TeaQL packs and propagates the .comment("business intent") directly into the database's SQL execution comments (e.g., /* [Get active tasks -> count_stats] */ SELECT ...). DBAs can throw the SQL directly back to developers, who can locate the exact line of code in seconds.
  • UnifiedLogBuffer: Outputs executed SQL, execution duration, UserContext info that triggered the change, and domain events all within the same log pipeline, making troubleshooting as clear as peeling an onion.

5. Data Ops & Quality Perspective [In Planning]

Core Demands: The database is no longer a black box; it can actively detect quality issues like orphan data, invalid foreign keys, and abnormal states.

Based on our mature enterprise experience with the Java version, TeaQL is introducing a global data quality inspection engine to the Rust ecosystem:

  • Schema Drift Detection: At startup, it precisely compares the in-memory EntityDescriptor with the actual database schema and outputs a detailed drift report.
  • Data Health Scanning: Utilizing the metadata association graph at the framework level, future releases will support generating data quality reports to automatically find issues like "orphan data with a Task but no corresponding Project" or "dirty data whose state transitions violate the state machine". Work that previously required offline big-data jobs is executed directly in the runtime data layer.

6. Real-time Analytics Perspective [In Planning]

Core Demands: Seamlessly pipe data streams generated by business operations to analytical engines.

Traditional solutions rely on heavy components like Maxwell/Canal to monitor binlogs.

  • Built-in Facet Analysis: The current version of TeaQL already provides the facet_by_* API to perform multi-dimensional statistics in a single business query, reducing the development cost of backend dashboards by 80%.
  • Real-time EventSink Distribution: Building upon the implemented EntityEvent change capture mechanism, future plugins for Kafka/ClickHouse EventSinks will allow business data changes to flow to data warehouses for real-time analysis with just a single line of configuration, removing the need for external CDC components.

To our customers: What you are looking at is not a toy that just started, but a mature system reconstructed using Rust's extreme performance and safety features, refined through years of practice in Java's massive enterprise ecosystem. Adopting TeaQL today solves your current development efficiency challenges, while simultaneously securing your ticket to future-proof data compliance, AI collaboration, and real-time analysis.