Posts

Showing posts from October, 2026

Building Production-Ready Report Exporters: PDF and Excel

Image
 Introduction Exporting application data to PDF and Excel is a core requirement for enterprise dashboards, billing engines, and analytics platforms. However, handling dynamic pagination, heavy payloads, cell styling, and memory bottlenecks requires deliberate architectural choices. 1. Match the Format to the User’s True Intent PDF and Excel fulfill distinct business functions: PDF (Document-first): Read-only, pixel-perfect, intended for formal distribution, archiving, or printing (invoices, audit summaries, executive briefs). Excel (Data-first): Interactive, formula-driven, intended for downstream modeling, filtering, and ad-hoc analysis by finance or operations teams. 2. Client-Side vs. Server-Side Generation Decide execution runtime based on dataset size and visual complexity: Client-Side (e.g., html2pdf.js, SheetJS in browser): Best for lightweight datasets (< 500 rows) or simple screen-captures. Saves server CPU, but risks browser tab freezes on large datasets. Server-Sid...

Building a Secure AI Data API with MySQL REST Service (MRS) and JSON Duality Views

Image
  Introduction Giving an LLM direct database credentials or arbitrary "Text-to-SQL" access is an anti-pattern in enterprise security. A single jailbreak or prompt injection can wipe schemas, exfiltrate PII, or execute rogue queries. By placing MySQL REST Service (MRS) as a mediated gateway between the AI agent and the database, we enforce strict privilege separation. The agent operates strictly via discrete OpenAPI-documented tools, bounded endpoints, and deterministic business logic. 1. Executive Summary & Architecture Overview Instead of granting raw database connections to an AI reasoning engine, the agent interacts solely with approved REST endpoints exposed via MySQL REST Service. The Security Model Principle of Least Privilege: The AI agent never receives SQL credentials, table catalogs, or arbitrary DDL/DML execution privileges. Granular Scoping: Endpoints restrict agent actions to discrete operations ( GET /orders/{id} , POST /returns ). Controlled W...