Secure AI-Driven Data Access with Intent-Driven Architecture
Introduction The evolution of modern applications has led to a demand for more intuitive user interactions. Users now expect to interact with systems conversationally, asking qu...
Introduction
The evolution of modern applications has led to a demand for more intuitive user interactions. Users now expect to interact with systems conversationally, asking questions like, “Where is my order from last Tuesday?” or “How does this month’s usage compare to last year’s?” Traditionally, creating user interfaces to answer such questions required extensive development time. The simplistic "Text-to-SQL" approach, which lets a language model access a database schema to generate queries, poses significant security risks when used by untrusted users. These risks include data leaks and unauthorized access. There is a need for a system that provides the flexibility of natural language while maintaining strict control over database access.

This guide outlines a secure architecture using managed databases and AI platforms to achieve this. By employing Intent-Driven Function Routing, the AI acts as a dispatcher, allowing secure data access without giving direct database access to the AI, thus safeguarding infrastructure and enhancing user experience.
Key Takeaways
- Intent-Driven Data Interfaces: These allow users to access data flexibly via natural language while maintaining strict query control.
- Security Measures: The AI system operates behind a tool menu, ensuring that backend systems maintain query control and enforce permissions.
- Platform Components: AI platform agents manage routing and memory, while serverless functions handle secure execution and orchestration.
- Scalability: This architecture can be scaled across departments by adding new tools instead of creating new endpoints for every query.

The Guardrail Pattern: Advantages Over Text-to-SQL
The naive "Text-to-SQL" method can be insecure, especially in customer-facing applications, as it exposes systems to risks such as prompt injection and data leaks. Instead, the Guardrail Pattern places the AI in a secure environment, preventing direct database access.
Securing the Perimeter: AI as an Intelligent Dispatcher
In this pattern, the AI does not directly interact with the database schema. Instead, it uses a predefined set of tools, translating user queries into standardized requests that the backend application executes securely.
The Magic of Tool Chaining
Tool Chaining allows for dynamic query composition by the AI, enabling it to answer complex questions by combining basic functions rather than relying on pre-written endpoints for every potential query.
Implementation Paths
This architecture can be implemented in different ways, illustrated using a scenario where a customer inquires about an order status.
Path A: Declarative Approach with AI Platform Agents
This approach employs AI platform agents to handle conversational state and routing. The AI identifies user intent and triggers serverless functions to execute secure queries.
Implementation Steps:
- Create the Agent: Configure agents with strict behavior guidelines.
- Create the Function: Develop serverless functions for executing secure database logic.
- Define Routes: Connect agents to functions using routing configurations.
- Input and Output Schemas: Define schemas to prevent data hallucination and ensure accurate responses.
Path B: Code-First Approach with Serverless Inference
This approach offers developers control over orchestration, using serverless inference as a stateless intelligence engine.
Implementation Steps:
- Secure Inference Credentials: Generate access keys for the serverless inference service.
- Define Database Tools Locally: Write Python functions to handle database queries.
- Define Tool Schema: Describe available functions to the AI using JSON schema.
- Implement Orchestration Loop: Coordinate conversation logic and tool execution securely.
Which Path to Choose?
- Path A is suitable for quickly deploying standalone chatbots with built-in chat memory.
- Path B is ideal for embedding AI into complex systems, offering control over authentication and data handling.
Extending the Architecture
This architecture is modular and can be scaled to handle complex, enterprise-level requirements.
Horizontal Scaling Across Departments
By expanding toolsets, a single AI agent can serve multiple departments, routing queries to appropriate tools based on user intent.
Multi-Step Reasoning
Modern AI models can handle multi-step reasoning, using several tools sequentially to answer complex questions.
Safe Write Operations
Function Routing allows secure execution of database writes with thorough validation before any data changes occur.
Integrating External APIs
The architecture supports routing requests to third-party APIs, enhancing its versatility.
Advanced Capabilities
The architecture enables secure execution of actions and proactive development through metadata analysis, transforming user queries into actionable insights for software development.
Conclusion
Developing natural language interfaces doesn't require sacrificing security. With an Intent-Driven Architecture, teams can deliver flexible user experiences while maintaining strict control over data access, thereby enhancing customer satisfaction and operational efficiency.