Data Engineering & Applied AI
IPSE — National Energy Telemetry & AI Platform
A mission-critical telemetry ingestion pipeline and dual-engine conversational AI platform engineered for Colombia's remote non-interconnected energy grid (ZNI).
The Operational Friction: Isolated Micro-Grids Across Colombia (ZNIs)
Colombia's Zonas No Interconectadas (ZNIs) encompass vast, geographically isolated territories—Amazonian river basins, dense Pacific jungles, and remote Caribbean archipelagos like San Andrés and Providencia. These regions are physically disconnected from the national electrical grid. Local communities rely entirely on hybrid micro-grids: complex installations pairing solar photovoltaic arrays and high-capacity battery banks with diesel backup generators.
Monitoring these plants was the mandate of IPSE (*Instituto de Planificación y Promoción de Soluciones Energéticas de Colombia*), working in partnership with Spartan IT. The operational reality on the ground was plagued by severe technical friction:
- Fragile Satellite Transmissions: Telemetry packets streamed over intermittent, high-latency satellite uplinks. Network dropouts frequently corrupted incoming socket streams, resulting in telemetry loss and dark monitoring periods.
- Siloed Legacy Databases: Core generation records were trapped inside Oracle GESTEL (the legacy national telemetry database), while regional field operators manually uploaded massive, unstandardized Excel matrices (
proyectos.o-matriz.xlsx) containing hundreds of uncurated columns. - The Two-Week Reporting Bottleneck: Ministry officials and regional auditors lacked direct analytics access. To audit diesel consumption vs. solar yield, verify battery degradation, or assess plant uptime, non-technical coordinators had to file manual SQL query requests with database administrators—creating a multi-week backlog for routine energy reports.
This was my first major enterprise architecture engagement at Spartan IT. I was entrusted with the end-to-end engineering of the core platform: bridging real-time distributed data pipelines with pioneering early-stage generative AI.
Architecture Homologation: Why Contract Theory Met Production Reality
The initial government contract proposed a traditional enterprise technology stack. During the initial technical discovery phase, I evaluated the throughput demands and operational realities, presenting an architectural homologation that replaced theoretical specifications with production-hardened tools:
| Domain | Contract Proposal | Implemented Production Stack | Technical Rationale & Trade-off |
|---|---|---|---|
| IaaS Infrastructure | OpenStack | VMware vCenter | vCenter was already established on-premise at the Ministry, eliminating months of complex hypervisor provisioning and hyper-converged storage setup. |
| Real-Time OLAP | Apache Cassandra / HBase | Apache Druid | Cassandra's wide-column model introduced heavy schema-tuning and compaction overhead. Druid was selected for native time-series columnar rollups, sub-second aggregation over 10M+ rows, and seamless streaming ingestion. |
| Event Streaming | RabbitMQ / Mosquitto MQTT | Apache Kafka | Druid requires native streaming supervisor ingestion directly from partitioned topic offsets. Kafka provided high-throughput disk buffering and enterprise mTLS encryption across remote endpoints. |
| Predictive Analytics | Apache Spark Cluster | MindsDB & PandasAI | A distributed Spark cluster introduced massive resource and maintenance overhead. MindsDB provided in-database SQL machine learning models, complemented by conversational LLM code execution via PandasAI. |
| Business Intelligence | Cloud PowerBI Alone | PowerBI + Apache Superset | PowerBI was augmented with self-hosted Apache Superset. Superset queried the on-premise Druid cluster directly via SQL without exporting sensitive national energy grid telemetry to external clouds. |
| Unified Portal | Disjointed Scripts | SADP (Django Control Plane) | Unified all services into a single platform: *Sistema de Analítica Descriptiva y Predictiva* (SADP), hosting embedded dashboards, monitoring feeds, and AI assistants. |
End-to-End Ingestion: Kafka, Druid, and The Ingestion Offset Desync
The ingestion layer was engineered to handle millions of continuous sensor pulses from remote ZNI plants without dropping records:
- Secure Stream Ingestion: Telemetry pulses streamed into an Apache Kafka cluster (
kafka.ipse.gov.co:9092) secured with mutual TLS (mTLS) using dedicatedkeystore.jksandcacerts.jkscertificate stores, protecting sensor data over public satellite hops. - Columnar Time-Series Rollups: Apache Druid consumed Kafka topic partitions through its Kafka Indexing Service. Telemetry rows were compacted into columnar segments partitioned by plant ID, region, and timestamp granularity, enabling instant aggregations over multi-million row ranges.
- Orchestrated ETL Workflows: Apache Airflow scheduled recurring DAGs that pulled structured data warehouse matrices (
proyectos.o-matriz.xlsx), executed schema validation, and synchronized batch records into MySQL storage.
### The Production War Story: Ingestion Offset Desynchronization
During early production operations, an upstream maintenance event on Oracle GESTEL caused Kafka topic retention to prune older messages while Druid's middle-manager tasks were recovering from a network interruption.
When Druid resumed consuming, its stored partition offset was pointing to a message index that no longer existed in the Kafka partition watermark. Druid's Kafka Indexing Supervisor immediately crashed into a failed state:
[Consumer clientId=consumer-kafka-supervisor-..., groupId=kafka-supervisor-...]
WARN [task-runner-0-priority-0] org.apache.druid.indexing.kafka.KafkaIndexTask -
Offset out of range for partition, resetting offset to latest...The supervisor ceased pulling new telemetry records, causing data to queue up on Kafka without reaching Druid.
Rather than manually SSH-ing into coordinator instances or rebuilding data sources from scratch, I engineered an automated monitoring and recovery routine. The system continuously audited supervisor health via Druid's Coordinator REST API. When an offset out-of-range condition was detected, the recovery worker triggered an authenticated reset:
POST /druid/indexer/v1/supervisor/{datasource}/resetThis REST trigger instructed Druid's coordinator to cleanly reset partition markers to the earliest available offset watermark, re-establishing continuous stream ingestion within seconds and preventing telemetry gaps.
The Dual-Engine AI Architecture: Pioneers in Tabular & Document RAG
In late 2023 and early 2024, enterprise Retrieval-Augmented Generation (RAG) frameworks were in their infancy. Regional energy managers faced two fundamentally distinct data challenges:
- They needed to analyze massive, multi-column Excel spreadsheets and tabular telemetry.
- They needed to understand dense, unstructured regulatory legal frameworks, technical manuals, and plant specifications.
A single generic LLM pipeline failed both requirements: vector databases corrupted structured arithmetic and multi-column tabular relationships, while pure SQL generation could not read PDF technical manuals.
To solve this, I designed and developed a dual-engine conversational AI architecture:
### Engine A: The Tabular Data Analytics Engine (PandasAI + Headless Plotting)
Regional managers frequently uploaded complex Excel spreadsheets (asistencia-evento.csv, proyectos.o-matriz.xlsx) with dozens of numerical indicators.
Using PandasAI, I engineered an execution bridge powered by OpenAI:
- Natural Language to Code: When a coordinator asked: *"What was the total diesel consumption and solar peak yield for hybrid plants in Chocó last month?"*, PandasAI instantiated a
SmartDataframe. - In-Memory Transformation: It translated the natural language query into native, optimized Pandas aggregation commands, filtering by department, plant status, and fuel type.
- Dynamic In-Chat Plotting: To provide instant visual reporting, I configured a headless Matplotlib/Seaborn rendering pipeline utilizing the
Aggnon-interactive backend. The engine dynamically compiled bar plots, line charts, and pie charts, serializing them into responsive HTML image blocks and rich tables directly inside the chat window.
### Engine B: The Semantic Document RAG Engine (LangChain + ChromaDB)
For non-tabular queries involving national energy policies, technical maintenance guidelines, and hybrid plant blueprints:
- Token-Budgeting Chunking: Built a token-splitting pipeline (
token_spliter) usingtiktokento compute exact token boundaries. This prevented large document uploads from exceeding context window constraints. - Vector Store Indexing: Document chunks were transformed into dense embeddings and stored in a local ChromaDB vector database.
- Context-Augmented Assembly: Using LangChain
PromptTemplateandConversationBufferMemory, the engine retrieved semantically relevant document excerpts and assembled a context-grounded response in Spanish with verifiable citations.
Headless Apache Superset Integration
To give coordinators deep, interactive visual analytics without duplicating data, I integrated Apache Superset headlessly into the Django SADP portal:
- Programmatic JWT Authentication: The Django backend managed a dedicated Superset service account. On user navigation, the backend called Superset's REST API (
/api/v1/security/login), retrieved a scoped bearer access token, and refreshed it dynamically. - Embedded Dashboards with RBAC: Live Superset dashboards querying Apache Druid were embedded into the SADP user interface via secure iframes. Role-Based Access Control (RBAC) ensured that regional coordinators could only view energy telemetry for their assigned zones.
The 15-Month Evolution: From IPSE to SADP
Building enterprise software inside a national ministry involves long-term political and organizational shifts:
- The Rebranding Pivot: After 15 months of active platform development, shifts in ministry leadership and institutional priorities altered the project's direction. To protect the engineering investment, Spartan IT leadership initiated a refactor to generalize the platform into SADP (*Sistema de Analítica Descriptiva y Predictiva*).
- Dynamic Branding via Django Admin: To prevent future branding friction, I architected a dynamic multi-tenant asset system. Platform names, client logos, color modes, and portal themes were decoupled from static source code and moved into Django Admin models. Administrators could toggle between IPSE government branding and standalone SADP industrial branding in real time with zero code redeployment.
- Dual-Language Infrastructure: The platform codebase was refactored with internationalization support, allowing it to serve both Colombian energy authorities in Spanish and international partner engineering teams.
Quantified Outcomes & Engineering Impact
- 10M+ Real-Time Sensor Records Ingested: Streamed and indexed with sub-second OLAP query performance across Apache Druid clusters.
- Reporting Turnaround Cut by 99%: Replaced two-week database ticket backlogs with real-time conversational data exploration and instant dynamic chart generation.
- Zero Data Loss: Successfully maintained telemetry integrity across intermittent satellite blackouts through Kafka mTLS disk buffers and automated Druid supervisor recovery.
- Foundational Architecture: Established an early production blueprint for dual-engine enterprise AI, proving that tabular numerical data and unstructured text require dedicated, specialized RAG pipelines.
Key Achievements & Metrics
Engineered a high-throughput telemetry pipeline streaming real-time sensor packets from Colombia's non-interconnected energy grid (ZNI) via Apache Kafka with mTLS.
Architected sub-second OLAP indexing for 10M+ telemetry rows using Apache Druid, resolving streaming partition desync via Coordinator REST API resets.
Researched and built an early-stage dual-engine AI layer: PandasAI for spreadsheet data-to-chart compilation and LangChain + ChromaDB for semantic document retrieval.
Programmed headless Apache Superset integration with automated JWT authentication, embedding live telemetry charts into the Django SADP portal.
Spartan IT