Opening.theVeltrix.

> Initializing Session...

INITIALIZING_WORKSPACE·0%
02.Veltrix
Active Session
01 . Project Overview

Veltrix

Autonomous Run • Python • Gemini API

veltrix/hero.webp
Hero view

Description

Every post ships through an adversarial pipeline before it goes live: Gemini drafts the topic and caption, then Groq and Cerebras — two independent models — must both sign off before it's trusted. A statistically-adaptive embedding check catches duplicate topics without a hardcoded similarity cutoff, and a self-expiring checkpoint file carries each post across two separate GitHub Actions runners so it can sit for a 30-minute human review window before auto-publishing. Branded slides render through Jinja2 + headless Playwright at full carousel resolution.

Timeline

10 Days

Role

Solo developer

Status

Production

Year

2026

Deployment

2 posts / day (auto)

Core Stack

Python / Playwright

Private Repository
02 . Core Rationale

Why I Built It

Understanding the core problems, proposed solutions, and realized product achievements.

The problem

Running a growth Instagram account solo means someone has to write, fact-check, design, and publish twice a day, forever — and the one time a hallucinated stat or a shadowban-trigger phrase slips through, reach tanks for weeks.

What actually happens
T+0s

GitHub Actions cron fires at 18:00 IST — a brand-new, stateless runner boots with zero memory of the last run.

T+1s

auto_post.py checks pipeline_checkpoint.json first, in case a post from the last run is still sitting in review.

T+3s

No pending checkpoint found. config.json's WEEKLY_SCHEDULE resolves today's evening slot to CAROUSEL_FLOW; content_generator.py drafts a topic and caption with Gemini.

T+5s

The topic's embedding is compared against the last 30 days via cosine similarity — adaptive_thresholds() computes today's duplicate cutoff from the mean and standard deviation of recent similarity pairs, not a fixed number.

T+6s

Similarity lands between the low and high threshold — the ambiguous middle band Vurlo-style fixed cutoffs can't resolve.

T+7s

is_semantic_duplicate_llm() breaks the tie: not a duplicate. Pipeline proceeds.

T+9s

verify_text_content() sends the caption to Groq and Cerebras independently — both must return caption_ok AND facts_ok, or the whole caption is rejected.

T+11s

Both approve. Jinja2 renders the slide templates; Playwright screenshots them at 1080x1350, 2x scale, after waiting on networkidle plus a settle buffer for Google Fonts.

T+14s

save_checkpoint() base64-encodes the slide images into pipeline_checkpoint.json with status: pending_review and a timestamp. The runner exits — the container is destroyed.

T+1,800s

30 minutes later, the next cron tick's load_checkpoint() finds the same checkpoint, sees age_hours >= 0.5, and auto-approves — publishing through the Instagram Graph API and deleting the checkpoint.

The fix, step by step
1
Persist state across two runners that never coexist
database.py

save_checkpoint()/load_checkpoint() serialize the topic, caption, and base64-encoded media bytes to a local pipeline_checkpoint.json, since nothing in memory survives a GitHub Actions job ending.

2
Score duplicates against a moving baseline, not a fixed cutoff
database.py

adaptive_thresholds() derives low/high similarity cutoffs each run from μ + σ and μ + 1.5σ of the recent embedding pairs (capped at 0.78 / 0.88), so the bar shifts with how similar the account's own recent output has actually been.

3
Never let one model grade its own homework
text_auditor.py

verify_text_content() routes the caption to Groq (llama-3.3-70b-versatile) and Cerebras (gpt-oss-120b) independently — different vendors, different base models — and ANDs their decisions together.

4
Force a human decision point before anything goes live
auto_post.py

A generated post sits at status: pending_review for a 30-minute window on the dashboard; the next cron tick or a manual --action=approve/reject decides its fate.

Result

Every post clears two independent auditors and a statistically-adaptive duplicate filter before it's even eligible to publish, and the whole two-post day — drafting, auditing, rendering, and shipping — runs for roughly $0.0002 without a manual click when nobody intervenes.

Inference cost / post
~$0.0002
Independent audits required
2 of 2
Human review window
30 min
Output formats
4 (photo/carousel/reel/listicle)
03 . System Pipeline

Architecture Pipelines

Visual system flow diagrams representing data pipelines and structured checks.

Pipeline Data flow nodes (Glows on Hover)
01 // cron

GitHub Actions cron → auto_post.py

fires at fixed IST slot hours and resolves the day's format (photo/carousel/reel/listicle) from config.json's WEEKLY_SCHEDULE map, keyed by weekday and slot instead of one fixed daily template.

02 // checkpoint

database.py — save_checkpoint() / load_checkpoint()

the only state that survives between two entirely separate ephemeral runners — serializes topic, caption, and base64-encoded media to pipeline_checkpoint.json, self-expiring after 24 hours.

03 // content-gen

content_generator.py

drafts a topic and caption using Gemini, pulling from a weighted voice pool (Punchy, Listicle, Storytelling, Question-Hook, Stat-Led) so back-to-back posts don't read like the same template.

04 // dedupe

database.py — cosine_similarity() / adaptive_thresholds()

a three-tier duplicate filter: fast-reject below a statistically adaptive low threshold, fast-flag above a high threshold, and only the ambiguous middle band falls through to an LLM tiebreaker.

05 // auditor

text_auditor.py — verify_text_content()

local regex/heuristic pre-checks (emoji density, disclaimer placement, shadowban phrase patterns) reject for free before any API call, then Groq and Cerebras independently audit whatever survives.

06 // renderer

listicle_pipeline.py — render_pages()

fills Jinja2 HTML templates with the approved copy, then screenshots them via headless Playwright Chromium at 1080x1350 / 2x device scale, waiting on networkidle plus a fixed settle buffer for web fonts.

07 // publisher

instagram_publisher.py / threads_publisher.py

publishes the approved asset set through the Instagram Graph API and cross-posts the same content to Threads, sitting behind the 30-minute review gate rather than firing immediately.

08 // dashboard

database.py — update_dashboard() → dashboard.html

renders a static control panel showing the pending-review card with Approve/Reject buttons wired to a GitHub workflow_dispatch, plus live per-post API cost telemetry from APITracker.

04 . Core Capabilities

Features & Capabilities

Key features and built-in components implemented inside the codebase.

Feature Checklist
  • ✓Zero-touch daily publishing — a GitHub Actions cron resolves each day's format from a weekly schedule map instead of posting the same content type every day.
  • ✓Adversarial fact-checking before anything ships — every caption is drafted by Gemini, then independently audited by Groq and Cerebras, with both providers required to agree before it's approved.
  • ✓Statistically-adaptive duplicate detection — cosine similarity against the account's post history, scored against thresholds recomputed each run from the mean and standard deviation of recent embedding pairs, not one fixed cutoff.
  • ✓Free local pre-screening before any API spend — regex and heuristic checks (emoji count, disclaimer placement, banned-phrase patterns) reject risky captions before a single audit call is made.
  • ✓State that survives an ephemeral runner dying mid-post — a self-expiring JSON checkpoint carries topic, caption, and base64-encoded media across two separate GitHub Actions invocations.
  • ✓Built-in human veto window — every generated post sits for 30 minutes as pending_review on a live dashboard before auto-publishing, with one-click approve/reject wired to a GitHub workflow.
  • ✓Headless-render pipeline for branded slides — Jinja2 templates screenshot through Playwright Chromium at 1080x1350, 2x scale, with explicit waits so slides don't ship mid-font-swap.
  • ✓Perceptual duplicate guards for media, separate from text — dhash/pHash image comparisons stop the same visual from posting twice, independent of the caption-level embedding check.
  • ✓Cross-platform publishing from one pipeline — the same approved asset set republishes to Threads without regenerating any content.
  • ✓Per-run cost telemetry — an APITracker tallies Gemini token costs and per-provider fallback usage straight into the dashboard, so spend is visible per post, not just in aggregate.
03 . Technical Barriers

Solving Complex Bottlenecks

A deep dive into security rule architectures, race conditions, and verification solutions.

Problem

auto_post.py runs as a brand-new GitHub Actions job every invocation — no memory, no disk, no in-process variables carry over between the run that drafts a post and the run 30 minutes later that's supposed to publish it.

Why it was difficult

A GitHub Actions runner is torn down completely when the job ends. Adding a human review window between generation and publish meant handing a fully-generated post — including binary image and video bytes — from one ephemeral container to a container that didn't exist yet.

The fix
1
Base64-encode every binary asset — image bytes, video slide frames — into the checkpoint JSON, not just text fields
auto_post.py
2
Stamp every checkpoint with an ISO timestamp and self-expire it after 24 hours
database.py
3
Check checkpoint.status === 'pending_review' before drafting anything new, so a cron tick during the review window can't generate a second, competing post
What I learned

"Idempotency isn't optional on ephemeral infrastructure — it's the only way a stateless scheduler can approximate a stateful workflow. The checkpoint file is effectively the pipeline's entire call stack, frozen and reloaded by whichever runner picks it up next."

06 . Build Log Timeline

Development Journey

A chronological day-by-day log detailing core milestones and features added.

Milestone timeline
Day 1

Core Pipeline & LLM Hooks

content_generator.py drafting flow wired to Gemini; config.json's weekly schedule map and voice pool established.

Day 3

Dual-Brain Auditor

text_auditor.py built out — local heuristic pre-checks, then independent Groq and Cerebras audit calls, AND-ed together.

Day 5

Adaptive Duplicate Detection

Embedding cache and adaptive_thresholds() written in database.py, replacing an earlier fixed-cutoff version that kept misfiring.

Day 7

Playwright + Jinja2 Render Pipeline

listicle_pipeline.py template rendering and headless screenshot capture stood up; chased down the font-loading race in CI.

Day 9

Checkpoint & Review Gate

save_checkpoint()/load_checkpoint() shipped in database.py; auto_post.py wired to the 30-minute pending_review window and dashboard approve/reject actions.

Day 10

Publishing & Dashboard

instagram_publisher.py and threads_publisher.py cross-posting wired up; dashboard.html control panel and APITracker cost telemetry finished before enabling the cron.

07 . System Reliability

Operational Metrics

No public-facing site to audit — these are the safeguards that keep an unattended pipeline honest.

Orchestrated APIs18+ Keys

Integrates content channels, competitor scrapers, database logs, alerting systems, and deployment APIs

Paid Gateway GateGemini API

Paid Gemini API invoked ONLY after the free/low-cost Llama audits approve the draft

Audit Fallback Chain4 Layers

Audits chain dynamically from Groq ➡️ Cerebras ➡️ OpenRouter ➡️ Raw Gemini to avoid blockages

Visual Generation3 Layers

Fails back from SiliconFlow (Flux/SD3) ➡️ Hugging Face ➡️ Gemini internal image generator

Checkpoint TTL24 hrs

self-expires so a stuck runner never resurrects a stale, half-finished post

Duplicate-check tiers3

embedding similarity ➡️ adaptive threshold band ➡️ LLM tiebreaker for the ambiguous zone

05 . Architecture Decisions

Trade-off Explanations

Concise rationales for technology selections and future roadmaps.

Design Choices

One Provider for Both Drafting and Embeddings

Gemini 2.5 Flash + gemini-embedding-2

Gemini writes the initial topic/caption and also generates the embedding vectors used for duplicate detection — keeping the 'creative' half of the pipeline on one low-cost, low-latency provider.

Independent Adversarial Audit, Not a Second Opinion From the Same Vendor

Groq + Cerebras

verify_text_content() requires both providers — running different base models (llama-3.3-70b-versatile, gpt-oss-120b) — to independently approve a caption, so a shared blind spot in one model family can't rubber-stamp a mistake.

Headless Card Generation

Playwright + Jinja2

Branded listicle slides are real HTML/CSS templates screenshotted at 1080x1350, 2x scale — layout, typography, and responsive-style rules come for free instead of hand-positioning text on a canvas.

Zero-Infra State for a Scheduler With No Server

Local JSON checkpoint + SQLite

No process stays alive between runs. pipeline_checkpoint.json and veltrix.db are the entire state layer, both just files the workflow commits back to the repo — no database server to provision or pay for.

Free Scheduler That Doubles as the Approval Queue

GitHub Actions cron + workflow_dispatch

The same GitHub Actions infra that runs the cron also handles the manual approve/reject action for the human review gate, so there's no separate approval service or webhook receiver to host.

If I built V2...

"Evaluating scaling adjustments and cache controls shows true engineering maturity."

  • ✓Move the checkpoint's binary asset payload out of a committed JSON file and into object storage (Supabase/Cloudinary) — base64-encoding video frames into the checkpoint bloats the repo's history over time.
  • ✓Cache Groq/Cerebras audit responses so a topic that gets re-evaluated after a checkpoint recovery doesn't burn two more audit calls for content that's already been reviewed.
  • ✓Extend perceptual image-hash duplicate checking to Reel source frames, not just PHOTO/CAROUSEL stills — a remade Reel can currently reuse near-identical frames undetected.
  • ✓Replace the fixed 1.5s Playwright settle buffer with an actual document.fonts.ready wait inside the page — it works today, but it's a guess dressed up as a timeout.
06 . Screenshots

Visual Gallery

Scrollable preview tracks showcasing panel responsive structures.

Horizontal Screenshot Scroll
Live Control Panel
Live Control Panel
Credential Health Board
Credential Health Board
credentials board
Secondary screenshot

Finished exploring this session?

End the workspace session to release resources and return back to the primary portfolio index.