Watcher Architecture

One card in, posts out. Visual map of every part and every flow.

Entry / UI Success path Async / waiting External API Storage

1. System overview

The browser talks to one Flask process. That process renders UI, runs OAuth, and spawns one background thread per post job.

System overview
Download PNG

2. File map

Each file has one job. This is the whole project.

File map
Download PNG
FileResponsibilityKind
app.pyRoutes, sessions, render templates, start jobs, OAuth endpointsentry
jobs.pyCreate job, background pipeline, retry one channel, status and logsorchestrator
media.pyDownload, detect kind, mix music, force H.264 yuv420pmedia
channels.pyFacebook, Instagram, TikTok posting and secret loadingexternal
facebook_auth.pyOAuth URL, token exchange, page list, page selectauth
templates/index.html, pages.html, job.html, callback.htmlview
data/jobs.jsonAll jobs, per-channel results, logsstate
config.jsonPage, page token, Instagram id (env vars override)secrets

3. Posting flow

From the one card to a final status. The heavy work runs in a background thread so the page stays responsive.

Posting flow
Download PNG

4. Media pipeline

Music is video only. A mix failure stops the whole job. Retry reuses the processed files, so ffmpeg does not run twice.

Media pipeline
Download PNG
RuleBehavior
File vs linkFile wins when both are set
MusicApplied to video only; ignored for images
Mix failureJob posts nothing
CodecVideo always normalized to H.264 yuv420p mp4

5. Facebook login flow

The user never types an App ID, App Secret, Page ID, or token. The App ID is fixed, the page token is captured automatically.

Facebook login flow
Download PNG

6. Channels

Each channel has its own upload and completion rule.

Channels
Download PNG

7. State and storage

Secrets and job state are plain JSON on disk. Environment variables override file values.

State and storage
Download PNG

8. Deployment

Gunicorn runs one worker with threads, so the in-process background jobs keep working. Public HTTPS is required for Facebook login.

Deployment
Download PNG

Back to Watcher ยท Flow