Lubili
Client work

atom, a publishing platform for Instagram and YouTube

A client’s video publishing outgrew a hosted automation tool. Lubili designed and delivered atom: a custom platform that reads from Google Drive, schedules in the cloud, publishes to Instagram and YouTube, and can be operated by an AI assistant over MCP. It is live in production, serving an active user base.

Built by Lubili
Type
Custom publishing platform with an MCP server
Role
Architecture, engineering and delivery of the full system for a client
Stack
Cloudflare Workers, D1, Queues and KV, TypeScript, Hono, Zod, Next.js (static export), Tailwind CSS, WebAuthn passkeys, OAuth 2.1 and MCP, Google Drive API, YouTube Data API, Instagram Graph API, Vitest
atom overviewFiles in Google Drive are reviewed and approved by a person, either in the dashboard or through an AI assistant over MCP. Approved items are scheduled by a cloud scheduler and published to YouTube as videos and Shorts and to Instagram as Reels and Stories.DashboardReview, approveAI assistantOver MCPapprovesdrafts, schedulesGoogle DriveYour foldersReviewa person approvesSchedulecloud schedulerYouTubeVideos and ShortsInstagramReels and Stories
Files in Drive become scheduled posts. A person or an AI assistant reviews and approves, and atom publishes.Scroll sideways or pinch to zoom

Context

The problem: a hosted automation tool was no longer enough

The client publishes short video to Instagram and YouTube from files kept in Google Drive. The workflow ran on a hosted automation tool, and its plan no longer fit the volume.

Publishing to two platforms is more than moving a file. Each has its own upload rules, quotas, scheduling model and ways to fail halfway. The client needed posts to go out on time without a computer switched on, a person in control of what goes live, and a clear record of what happened.

Why a custom platform

A general automation tool is built to connect steps. Scheduling, the state of each post, platform quotas and recovery after a half-finished publish are left to the workflow.

Owning that logic meant limits could come from the platforms’ own rules instead of a plan tier, and controls the client needed, such as an approval step and an AI assistant interface, could be built in.

Lubili’s role

Lubili designed, engineered and delivered atom for the client: the architecture, the scheduler and publishing engine, the Google Drive, YouTube and Instagram integrations, the dashboard, the MCP server, security, and the automated test suite.

The system runs in production on serverless infrastructure and is operated through a dashboard and, optionally, an AI assistant.

What we built

Inside atom: a custom Instagram and YouTube publishing platform

  • Google Drive media library

    Connects through OAuth and syncs from Drive’s change feed, including folders backed up with Drive for desktop. New files arrive as “in review”, duplicates are linked, and files are checked for completeness before they can be approved. Drive access is read-only: atom never changes, moves or deletes a file.

  • Drafts and composer

    Instagram Reels and Stories, and YouTube videos and Shorts, with captions, titles, tags, privacy and thumbnails. Fields are validated against each platform’s rules before anything is submitted, and a draft can be saved, scheduled or published now.

  • A cloud scheduler

    A one-minute cron claims due jobs, hands them to a queue and sweeps for overdue or stuck work, so posts go out with every device switched off. A global pause switch and a dry-run mode stop or rehearse everything without losing a job.

  • YouTube publishing

    Resumable uploads streamed from Drive in windows, with the confirmed offset saved so an interrupted upload resumes instead of restarting. Privacy is always set explicitly, scheduling uses YouTube’s own publish time, and upload, processing and visibility are tracked separately.

  • Instagram publishing

    Creates a Reel or Story container, waits for Meta to finish processing, then publishes exactly once. If the outcome is ever unclear, atom asks Meta what happened instead of sending the request again. The video reaches Meta through a short-lived, single-use link or a resumable upload.

  • Quota awareness

    YouTube’s upload allowance is counted and checked, and Instagram’s publishing limit is read from Meta, not hard-coded. A job that would exceed a limit is deferred and resumes by itself when capacity returns, so it is never lost or failed.

  • Dashboard

    Connections for each account, a schedule with a live execution log for every job, what is currently live on each platform, usage and quotas, and system health. It works on a phone.

  • MCP server

    A remote MCP server with OAuth 2.1 and four scopes (read, draft, schedule, publish) exposes 19 tools, so an AI assistant can find files, prepare drafts, schedule posts and check results. It calls the same services as the dashboard, so both behave identically.

  • Security and access

    Passkeys, owner-only Google sign-in and single-use recovery codes. Platform tokens are encrypted at rest with AES-256-GCM, every API route denies by default, and security-relevant actions go to a separate audit log.

Engineering

Key decisions

  1. The database is the truth, the queue only delivers.

    Every state change and its dispatch request are written in one transaction, and the queue is treated as at-least-once. A duplicate delivery finds a newer version or a held lease and does nothing, so a retry cannot publish twice.

  2. Reconcile, never repeat.

    After any request that may have succeeded, such as a timeout during publish, atom checks what the platform recorded before it acts again. A post that cannot be confirmed goes to “needs attention” for a person instead of being sent a second time.

  3. Stream, never store.

    Video moves from Drive to the platform in bounded windows and is never buffered whole or copied. That keeps memory flat and avoids holding a second copy of the client’s media.

  4. Defer, do not fail.

    A used-up quota, a revoked token or a paused switch moves a job to a waiting state with a reason and a resume time. Nothing is marked failed for a cause that will clear.

  5. The assistant prepares, the owner decides.

    Publishing straight from an assistant needs the publish scope, an owner switch that is off by default, and a single-use confirmation tied to the exact content previewed. There are no admin tools over MCP, and text from Drive is returned as data, never as instructions.

  6. One module per platform.

    Each platform sits behind its own connector with its own state, quota entry and error mapping, so a problem with one cannot stop the other. Adding another platform is a new module, not a rewrite.

  7. Built for tight limits.

    The serverless platform’s per-request CPU and outbound-call limits shaped the design: work is bounded, streamed and resumable, and heavy steps run as queued jobs instead of inside a request.

Custom versus off the shelf

Where a custom platform goes further than a no-code tool

Hosted automation tools such as Zapier are a good fit for many workflows. atom exists because this one needed things a tool of that kind is not built to provide.

  • Scheduling that is part of the system

    Jobs have explicit states, overdue work is found and recovered, and publishing can be paused or rehearsed with a switch.

  • Large files, streamed

    Video goes from Drive to the platform in resumable windows, so the limits are those of YouTube and Instagram themselves.

  • Platform rules built in

    Reel format checks before upload, YouTube privacy always explicit, quotas read from the platforms, and unclear results reconciled instead of repeated.

  • Custom control

    An approval step, a live execution log and an MCP interface for AI assistants, designed around how the client works.

  • Extensible by design

    Google Drive, Instagram and YouTube today. Because each platform is a connector behind a common interface, any tool or platform that offers a developer API can be added, subject to its terms and API access.

Results

Results of atom

  • Live in production and serving an active user base.
  • Posts go out on schedule with no computer switched on.
  • Every action is recorded, with a live log for each job and a separate audit trail.
  • Duplicate and missed publishes are guarded against: steps are idempotent and unclear results are reconciled.
  • An AI assistant can handle the routine work while the owner keeps final control.
  • Platform limits, not a plan tier, decide what can be published.

Architecture

The full system

For engineering readers. Everything in the drawing is described in the text above.

atom architectureA cron trigger every minute, an AI assistant over MCP with OAuth 2.1, and the dashboard start work, and the client team uses the dashboard. All of it reaches one TypeScript Worker on Cloudflare. The Worker has four interfaces: a Hono REST API that denies by default, the static dashboard, an MCP server with scopes and confirmations, and access control with passkeys, Google sign-in and recovery codes. Behind them are five core services: a Drive-backed media library, a composer, a scheduler with a recovery sweeper, a publish engine built as a job state machine, and a quota service. The dashboard API and MCP call the same services. Three connectors, one per platform, share one interface: Google Drive is read-only, YouTube uploads in resumable windows, and Instagram creates a container and publishes once. The Worker uses Cloudflare services: a D1 database that holds the authoritative state, a queue that only delivers, and a KV namespace for the OAuth provider. The platforms are Google Drive through its API, YouTube through the Data API and Instagram through the Graph API.WHAT STARTS WORKCron triggerEvery minuteAI assistantMCP, OAuth 2.1DashboardPasskeys or Google sign-inPEOPLEClient teamActive usersONE WORKER ON CLOUDFLAREatom, TypeScriptINTERFACESREST APIHono, ZodDeny by default, CSRFDashboardStatic assetsNo server renderingMCP serverStreamable HTTPScopes, confirmationsAccess controlPasskeys, GoogleRecovery codes, auditThe dashboard API and MCP call the same servicesCORE SERVICESMedia libraryDrive change feedRead-only syncDuplicate linksComposerZod validationReels, StoriesVideos, ShortsSchedulerCron, every minuteClaims due jobsRecovery sweeperPublish engineJob state machineIdempotent stepsReconciliationQuota serviceUsage ledgerDefers, never failsMeta and YouTubeCONNECTORS, ONE PER PLATFORMDrive connectorSame connector interfaceReads, never writesYouTube connectorSame connector interfaceResumable windowed uploadInstagram connectorSame connector interfaceContainer, publish onceCLOUDFLARE SERVICESD1 databaseAuthoritative statepublish_jobs: the truthoutbox: dispatch intentsjob_events: append-only logaudit_logs: security trailQueueDelivery onlyAt-least-once deliveryRecovery sweeper behind itKVOAuth provider onlyHashed MCP tokensPLATFORMSGoogle DriveDrive API v3, read-onlyYouTubeData API v3InstagramGraph APIread-onlyresumable uploadcontainer, publish
One Worker, one source of truth. The dashboard and the AI assistant call the same services, and each platform sits behind its own connector.Scroll sideways or pinch to zoom

One Worker and one source of truth. The dashboard and the AI assistant call the same services, and each platform sits behind its own connector. Three more drawings follow: a post’s life, the streaming path, and the assistant workflow.

The life of a post

The life of a publishing jobA publishing job moves from scheduled to queued, running, at the platform and published. Four side states exist: paused when a token is revoked or publishing is switched off, deferred when a quota is used up and resumes at reset, needs attention when an outcome is unclear and must be reconciled first, and failed when the platform refuses. A job can be cancelled until it has started. Below, reliable delivery: every state change is written with an outbox row in one D1 transaction, the queue delivers at least once, a consumer takes a lease and checks the version, does one step and saves its result first. A repeated delivery finds a newer version or a held lease and does nothing.PUBLISHING JOB STATESpublish_jobs, one row per post and platformScheduledwaiting for its timeQueuedsent via the outboxRunningheld by one workerAt platformprocessingPublishedIDs and link savedPausedDeferredNeeds attentionFailedtoken revoked,switch offquota used up,resumes at resetoutcome unclear,reconcile firstplatform said no,reason recordedCancel works untila job has startedRELIABLE DELIVERYAt-least-once delivery, exactly-once effectsone D1 transactionState changeoptimistic versionOutbox rowsame transactionQueueat-least-onceConsumerlease, version checkOne stepresult saved firstA repeated delivery finds a newer version or a held lease, and does nothing.
Jobs move through explicit states, and no delivery or retry can publish a post twice.Scroll sideways or pinch to zoom

Streaming from Drive to the platforms

Streaming from Drive to the platformsGoogle Drive is read-only and the file stays in Drive. For YouTube: preflight checks format, size and quota, a resumable session is opened with privacy always set, each window is streamed from Drive to YouTube, and the confirmed offset is saved so an interrupted upload resumes. After the upload atom checks processing, sets the thumbnail and relies on YouTube's own publish time. For Instagram: preflight checks the file, size and limit, a Reel or Story container is created, the video is delivered through a short-lived single-use link or a resumable upload, and the post is published once, with reconciliation if the outcome is unclear. Offsets and container IDs are saved in the database before the next step.Google DriveRead-onlyRange readsFile stays in DriveYOUTUBEWindowed resumable uploadPreflightformat, size, quotaOpen sessionprivacy always setStream windowDrive to YouTubeSave offsetresume after a breakYouTubeData API v3Never buffered, never stored: each window is piped from Drive to YouTube.Afterwards: processing check, thumbnail and YouTube's own publish time.INSTAGRAMContainer, then publish oncePreflightfile, size, limitCreate containerReel or StoryDeliver videolink or uploadPublish oncereconcile if unsureInstagramGraph APIMeta pulls a short-lived, single-use link, or atom uploads the bytes.Container IDs are saved first, so a retry resumes instead of repeating.Offsets and container IDs live in the database, so a restart picks up where it stopped.
The video is never buffered whole and never copied. Progress is saved after every step.Scroll sideways or pinch to zoom

How an AI assistant works with atom

How an AI assistant works with atomAn AI assistant works through six MCP tools: it finds a file in Drive, registers it, approves it when the owner has said so, creates a draft, schedules it and checks the result. The assistant passes file IDs and text; video never passes through it. Publishing straight from an assistant is a separate path with four safeguards: four least-privilege scopes with publish off by default, a single-use five-minute confirmation bound to the exact content, an owner switch that is off by default, and a posture that treats Drive text as data and exposes no admin tools over MCP.ROUTINE WORK, ONE STEP AT A TIMEMCP toolsFinddrive.findRegistermedia.registerApprovemedia.approveDraftdraft.createScheduleschedule.createCheckjobs.getThe assistant passes file IDs and text. Video never passes through it: atom reads the file from Drive.Approval needs the owner's instruction and the schedule scope.SAFEGUARDSPublishing straight from an assistant is a separate, gated pathFour scopesLeast privilegeread, draft, schedule, publishpublish is off by defaultSingle-use confirmationFive minutesBound to the exact contentVoid if the draft changesOwner switchOff by defaultAssistant publishing stays offuntil the owner turns it onData, not instructionsInjection-safe by designDrive text is returned as dataNo admin tools over MCP
The assistant prepares and schedules. Publishing directly from it needs a scope, a switch and a confirmation.Scroll sideways or pinch to zoom

Stack

Technology

  • Cloudflare Workers, D1, Queues and KV
  • TypeScript
  • Hono
  • Zod
  • Next.js (static export)
  • Tailwind CSS
  • WebAuthn passkeys
  • OAuth 2.1 and MCP
  • Google Drive API
  • YouTube Data API
  • Instagram Graph API
  • Vitest

For your business

Similar problems Lubili can solve

Any workflow that has outgrown a hosted automation tool: scheduled publishing, document or media pipelines, multi-platform integrations, and processes that need approval, quotas, recovery and an audit trail. Lubili also builds the AI assistant interface (MCP) on top of such systems.

Client work. Client details are kept confidential.

Need a system that goes beyond what an automation tool can do?

Book a free consultation, and we will look at what you need, what a custom platform would involve, and whether it is the right choice.

Free. No obligation. You get a one-page written summary.