Instagram Automation and Analytics Platform
A distributed platform that operates a fleet of isolated Instagram sessions from one place, generates their content with AI, and tracks engagement per account.
Running scheduled work across many independent browser sessions creates four constraints at once. Two workers must never drive the same session simultaneously. A worker that crashes must not take its in-flight jobs with it. Enough concurrent browsers will exhaust the memory on a single host. And one account’s session state or network identity must never surface inside another’s. This is the multi-account infrastructure built around those constraints: a durable job queue with leases and reclamation, a per-session mutex, a box-wide concurrency cap with resource admission, per-account proxy isolation, and an AI pipeline that produces the post content.
The public repository contains the reusable queue, concurrency, proxy, monitoring, and content-pipeline infrastructure rather than the full account-specific application.
Durable job queue
The backbone is a distributed job runner that leases work to worker processes instead of running it inline. A worker takes a lease on a job, does it, and marks it done. If the worker dies, the lease expires and another worker reclaims the job, so a restart does not lose queued work. It is built from filesystem primitives rather than a message broker, which keeps the leases, reclamation, and backpressure visible in a few hundred lines.
Concurrency and isolation
Each browser session holds hundreds of megabytes of memory, so the number that can run at once on one host is bounded. Two tiers of control keep a box from tipping over. A per-session mutex makes sure two processes never touch the same account profile at once, and a box-wide concurrency cap with a resource-admission gate refuses to start another session when free memory drops below a watermark. Admission backpressure holds the job in the queue rather than failing it. Every account is pinned to its own proxy, so sessions never share a network identity.
AI content pipeline
Post content is generated rather than hand written. The content pipeline writes captions with a language model steered by few-shot examples and generates images from scene descriptions. Prompt versions are hashed, so any output traces back to the exact prompt that produced it. The pipeline runs across more than one model provider with retry and fallback, so a single provider outage does not stop a run.
Per-account analytics
Engagement and audience statistics were collected for every account and stored over time, so performance could be tracked account by account and aggregated across the fleet.
Reliability
A monitor process watches queue depth and worker health, and the worker fleet runs under PM2 with bounded auto-restart, so a crashed worker comes back without a persistent fault spinning forever. The architecture is written up in ARCHITECTURE.md.