05
← Transmissions / AI / LLM

The 3AM Architecture Decision That Made insanemesh.ai Run Itself

How I wired Gemini Flash → Groq → Puppeteer → Telegram → Meta API into a pipeline that fires at 7PM IST every night without my hands touching it.

Building automation is easy. Building automation that you can entirely disconnect from is a completely different engineering challenge. The core objective behind insanemesh.ai wasn't just to see if AI could generate content—it was to build a system that operated completely autonomously for 90 straight days without a single manual intervention on my end.

The Prototype Phase

Days 1 through 10 were brutal. The pipeline was functional, but "functional" meant I was the orchestrator running bash scripts from my terminal. The concept generation felt disjointed. Llama models on Groq would occasionally hallucinate formatting rules, causing downstream Puppeteer rendering to crash when it expected JSON but got markdown.

I realized that if I wanted zero-touch execution, the architecture required strict decoupling and absolute fault tolerance at the boundaries.

The Core Pipeline

Here is the exact flow that now fires at 7PM IST every single evening:

  1. Ideation: A cron job initiates a call to Gemini Flash. It pulls context from previous posts and generates a unique, thematic concept for the day.
  2. Drafting: The concept is passed to Groq Llama 3.3, which acts exclusively as the copywriter. It generates the caption and the structured layout data.
  3. Execution: Puppeteer boots up a headless instance, injects the generated payload into an HTML template, captures a high-fidelity render of the tile, and outputs a clean image asset.

The Telegram Gate

The most critical realization was that letting an AI post directly to production (Meta API) with zero oversight is a bad idea. But forcing me to approve things defeated the purpose of automation.

The solution was the Telegram Gate. Instead of me logging into a dashboard, the system sends the fully rendered asset and caption to a private Telegram channel via a bot.

// A simplified conceptual representation of the gate 
async function awaitApproval(payload) {
  await telegram.sendPhoto(chatId, payload.image, {
    caption: `**Pending Approval:**\n\n${payload.caption}`,
  });
  // System pauses execution; waits for '/approve' webhook from my device.
}

Once I reply /approve from my phone—whether I'm at dinner or on a train—the webhook fires, unlocks the final stage, and the system hits the Meta API to publish Day 42.

By Day 11, the pipeline transitioned from a fragile script to a hardened, event-driven architecture. Engineering autonomous systems isn't about writing code that does everything; it's about building a system that knows exactly what to do when something inevitably fails.