Skip to content

Architecture

A guided tour of the code for a new contributor. It names the processes, the modules and what each one owns, then follows one watch from the moment a client reports it to the moment a note lands in Anki. The domain words (source, platform, tracker, judge, 判定) are defined in GLOSSARY.md; the user-facing overview is in the README.

Before you change anything, read CONTRIBUTING.md: it says which checks to run for which kind of change, and what a PR must report.

Where each part runs: capture on your devices, the core and media library on the server, Anki and Yomitan on your computer, optional audio services

AutoMiner is one server process plus clients and optional services. The server owns all state: the database, the job queue, the media library and every clip. Clients only report what was watched; Anki is read for known words and receives finished notes.

autominer serve (cli.py) runs uvicorn with the FastAPI app in app.py, on 0.0.0.0:8801 by default. On Windows the installer starts the same app through desktop.py (python -m autominer.desktop), on 127.0.0.1:8801.

The app’s lifespan does the startup work, then starts everything else inside the same process:

Part Where What it does
HTTP API and web UI app.py Every route (see HTTP API), plus the static pages under /static.
Job worker jobs.start_worker One thread, autominer-worker, that claims and runs one job at a time.
Trackers trackers.py A supervisor thread that starts one thread per installed platform that has a tracker (Stremio and Spotify today) and re-checks every 30 s.
One-time passes app._one_time_passes A thread that runs a few one-time data upgrades after start, then warms the Sources list; the worker waits for the upgrades.
Built-in Yomitan yomitan_local.py A Node child process running yomitan/server.mjs on a free local port, when enabled.
Local judge local_judge.py A llama-server child process from a pinned llama.cpp build, started the first time the local judge is asked a question once its files are downloaded.

Startup, in order: db.init_db creates or upgrades the schema (and refuses a database too old to upgrade, see The database), the built-in Yomitan starts, the job handlers are registered, and a series of repair and backfill steps run (clip score backfill, automine.settle, orphan thumbnail sweep, unfinished dictionary imports, line-join sweep, held judge work, loudness queues, disk measurement). Each step logs and carries on if it fails. Shutdown stops the trackers, then asks the worker to finish its current job within 30 s (jobs.WORKER_JOIN_TIMEOUT_S).

A tracker is a client like any other: it posts to POST /v1/events over HTTP at AUTOMINER_CORE_URL, which serve points at itself unless you set it. Each tracker takes a file lock, $AUTOMINER_HOME/state/<platform>-tracker.lock, so two cores sharing one home never track the same platform twice; the second one reports standby. /healthz lists each tracker’s state.

The Raspberry Pi deployment in deploy/ adds systemd timers that run short separate processes: the database backup (scripts/operations/backup_db.py), autominer qa-purge --commit, autominer retention-sweep --commit, and the yt-dlp update (deploy/update-ytdlp.sh). The deployment commands are in the command line reference; scheduling these jobs is in upkeep.

Client Code Door
Chrome extension extension/ POST /v1/events
YouTube on Android (Morphe patch) android/morphe-patches/ POST /v1/ingest/youtube-android
Stremio and Spotify trackers adapters/, run in the core POST /v1/events
Windows relay agent (legacy fallback) extension/agent/ forwards to POST /v1/events

Every door checks the producer first; see producer admission.

The core talks to these over HTTP. None is required to start; a feature whose service is missing reports not configured, and work that needs it is skipped or held with the reason.

Service Used for Configured by
Anki with AnkiConnect known words, duplicate checks, sending notes (anki.py) anki.url / ANKICONNECT_URL
Yomitan API (or the built-in one) definitions, readings, frequency, card format (yomitan.py) yomitan.url / AUTOMINER_YOMITAN_URL
Probe transcription, probe_asr/ blind transcription of short audio windows for the 判定 (probe_asr.py) evidence.asr_url / AM_PROBE_ASR_URL
Vocal separation, separator/ removing music before listening (separation.py) sync.separation_url / AM_SEPARATOR_URL
Search (Prowlarr or an addon), Deluge, VPN proxy getting Stremio media (acquire/) acquire.indexer_url, acquire.deluge_url, vpn.proxy_url
Cloud APIs transcription (OpenAI, ElevenLabs Scribe), translation (OpenAI, Gemini), the hosted judge Jev, Jimaku, OpenSubtitles secrets such as OPENAI_API_KEY, TYPESAFE_API_KEY

gpu_gateway/ packages the separator and the probe transcriber behind one URL for testing on a rented GPU. Installing and running the services: self-hosting.

All server code is the autominer package in core/autominer/. Most modules are flat files; a few areas are subpackages (repository layout says where new work belongs). The tables below group the modules by what they own.

Module Owns
app.py Every HTTP route, the startup and shutdown sequence, the /v1 token check, the “database busy” 503 answer.
cli.py The autominer command (command line): serve, doctor, setup, secret, producers, maintenance, repair scans and sweeps.
desktop.py, launcher.py The Windows desktop launcher; autominer install-command.
settings_registry.py Every installation setting and secret: name, type, default, feature, help.
service_urls.py Which URL each service uses: environment, saved row or default.
config_setup.py, doctor.py, help_text.py, dependencies.py autominer setup, the doctor report, CLI help, and the Settings rules that refuse a value another setting needs.
db.py, schema.sql Connections, schema creation, migrations.
maintenance.py, release.py, revision.py, backup.py The admission barrier used during deploys, the restart gate, the running revision, the last backup’s record.
admission.py, producers.py Producer admission at the ingestion doors and the record of admitted clients.
qa.py, wipe.py Marking test (QA) sources and purging them; erasing everything.
ports.py, pinned.py A free local port; downloading pinned programs (yt-dlp, its PO-token provider and plugin, llama.cpp) by checksum.
Module Owns
jobs.py The queue: enqueueing, claiming, running, retrying, cancelling; the table of job kinds and handlers.
jobruns.py The job_run history table, filled by triggers on job.
progress.py A job’s progress (stage, done, total, message) and the job view the UI polls.
versions.py The version number of each stage and the files each one covers.
freshness.py What a source’s results were built from, which inputs are stale, the stages that fix them.
converge.py The Fix button: running stages until a source is fresh or held for a named reason.
costs.py Spend limits for paid calls; holding and releasing jobs at a limit.
Module Owns
ingest.py Validating an event envelope, finding or creating the source, the session and the event row, and queuing the first job.
revanced.py The Android door: its shared secret and turning a phone report into an envelope.
trackers.py, adapters/spotify.py, adapters/stremio.py Running the in-process trackers; reading Spotify and Stremio playback.
ledger/intervals.py Turning a session’s events into watched intervals.
ledger/session_sweep.py Closing sessions that never sent session.end.
ledger/stats.py Watch-time statistics, the Sources list rows and each source’s freshness verdict.
dashboard.py, devices.py The Today page’s cards and layout; device names and colors.
dedupe.py Spotting the same title already mined under another source.
Module Owns
platforms/ The Platform interface (interface.py) and the built-in platforms: YouTube, Stremio, Spotify, Jellyfin (a stub without fetching). Install state lives in platform_install. See platforms.
fetch.py The shared fetch step that YouTube’s and Stremio’s fetch jobs run: language, details, media, subtitles, then the hand-off to transcription or mining. Spotify’s fetch job gets the episode audio and hands it straight to transcription.
fetch_yt.py yt-dlp, YouTube refusals and pauses, and the mine job handler.
fetch_stremio.py, acquire/, vpn.py Stremio: Jimaku subtitles, torrent search and Deluge downloads, the VPN check.
fetch_rss.py Podcast RSS feeds for Spotify episodes.
media_actions.py, sources.py, retention.py Per-source actions (mine now, re-mine, language change, fetch video), deleting and reviving sources, deleting old videos.
anime_mapping.py, episode_match.py Mapping anime episodes between numbering schemes; matching files to episodes.
artwork.py, channels.py, sized.py, frames.py, video.py Thumbnails, channel and series art, resized images, extracted frames, range-served video and VTT.
Module Owns
segments.py Parsing subtitle files into segment rows; subtitle filters; the source’s subtitle offset.
extract_subs.py, jimaku.py, animetosho.py, opensubtitles.py Embedded tracks and the outside subtitle providers.
subtracks.py, subpool.py, subcache.py, subupdate.py The subtitle files a source holds, the pool of candidates gathered for the 判定, cached copies, reloading from the original file.
asr.py Transcription when there are no subtitles: providers, costs, the asr job.
judge.py, evidence.py, reads.py, judge_pick.py The 判定: sampling audio windows, transcribing them, comparing with each subtitle candidate, the verdict and the pick.
judge_service.py, jev.py, local_judge.py, judge_setup.py Which judge answers (Jev or the local judge, see the judge), asking it, downloading and removing the local one.
subsync.py, words.py, linejoin.py Timing runs and their undo, word-level positions, joining lines that are one sentence.
separation.py, vad.py Vocal separation; the speech detector.
replay_judge.py Replaying stored 判定 evidence for evaluation.

The 判定 has its own long document: subtitle sync.

Module Owns
mine.py Mining one source: watched lines only, filters, candidates, then enrich and the 判定.
tokenize.py, lang/ Tokens and target-word rules; the language profiles (language profiles).
known.py Known words, read from Anki or a CSV.
mining/score.py, mining/aggregate.py The sentence score; grouping candidates by word and choosing the one to send.
mining/quality.py Asking the judge whether a sentence is usable.
mining/recalculate.py Rebuilding a source’s candidates (recalculation).
mining/target_form.py, mining/wordkey_sanity.py Scans and repairs for bad target forms and word keys.
exclusions.py Lines excluded from mining.
Module Owns
candidates.py Candidate rows: listing, editing, decisions, deletion.
enrich.py The enrich and assets.recut jobs: dictionary, translation, clip and screenshot.
assets.py, peaks.py Cutting clips and screenshots with ffmpeg, clip windows, loudness, context audio; waveform peaks (clip trimming).
verify.py, clipscore.py, music.py Scoring each clip with the clip model in models/, user OK/NG feedback, music-drowned clips.
clipmanager.py, clipquery.py The Clips table, its search language, the trash.
audit.py, audit_scan.py The Audit page: notes in Anki missing a sentence or clip, and their alternatives.
automine.py Each card’s derived status, the send gates, the queue of cards to send, immediate and daily sending.
push.py, kiku.py Building note fields and sending a note; the note type’s field mapping.
anki.py, duplicates.py, anki_same.py AnkiConnect calls; existing notes for a word (merge, overwrite, new) and links to sent notes; checking that the open Anki profile is the one AutoMiner sent to, by finding enough of its sent notes there.
yomitan.py, yomitan_local.py, dictionaries.py, dictsource.py, commons_audio.py The Yomitan API and the built-in Yomitan, imported dictionaries, the dictionary order per language, word audio.
translate.py, gemini.py Sentence translation and its cost log.
selfhost_bundle.py The zips Settings offers for the self-hosted services.

Every unit of background work is a row in the job table, run by the worker thread. A row is unique per (kind, key); the key is usually a source’s media.id, sometimes a candidate id or a fixed word like anki or all.

jobs.KINDS maps each kind to its handler (module:function) and a lane. Platforms add their own fetch and video kinds (fetch.yt, fetch.video, fetch.stremio, fetch.rss, fetch.audio) through platforms.jobs(); those run only while their platform is installed, and are skipped with a reason otherwise.

Lane Value Kinds
PRESS 0 Work a person is waiting for: subtitles.reload, anki.sync, source.delete, maintenance.wipe, acquire.tidy.
CHAIN 1 The pipeline: mine, asr, enrich, the other subtitles.* kinds, sync.*, assets.recut, candidates.*, verify.*, automine.push, media.lang, judge.fetch, platform fetches and more.
BULK 2 Background passes: session.sweep, known.refresh, audit.scan, loudness, music checks and more.

A payload can carry "lane": 0 to jump a job to the front; the routes a person presses do this.

  1. Enqueue. jobs.enqueue inserts a row, or returns the existing one with duplicate: true. enqueue_once returns the live (queued or running) row if there is one, else replaces a settled row with a new one. enqueue_again marks a running job to run once more when it finishes. During a deploy drain new work is inserted held (hold = 1); see autominer maintenance in the command line.
  2. Claim. Each turn, claim_next picks the oldest queued row with hold = 0 in the lowest lane, skipping kinds that must wait for upstream work on the same key (jobs.WAITS_FOR: for example enrich and assets.recut wait for any subtitle, mining or 判定 job of the same source). It sets status = 'running' and increments attempt.
  3. Run. The handler gets (conn, row). It reports progress with progress.job_hook, which merges {"progress": {stage, done, total, message}} into payload_json.
  4. Settle. The outcome is the row’s final status plus its last progress message:
Handler result Status Notes
returns done
raises SkipJob skipped for example a platform that is not installed
raises CancelJob, or a cancel was requested cancelled POST /v1/jobs/{id}/cancel; a running job stops at its next check
raises RetryLater queued, hold = 3 parked with backoff: 30 min, doubling to 6 h; failed after 3 days, unless the error names a cause: then it keeps retrying and is also released early when that cause clears (as when the judge becomes ready); Waiting names its own wait
raises BudgetHeld queued, hold = 2 waits until costs.release_held sees room under the spend limit
database locked (mine, enrich, assets.recut, candidates.recalc, media.lang) queued retried up to 3 attempts
any other exception failed the message is the error, cut to 300 characters

A job left running by a crash is marked failed at the next start, except media.lang, candidates.rescore and judge.fetch, which are queued again.

When the queue is empty, the worker runs its idle ticks instead (reading Anki again when due, automatic sending, music checks, trash purge, releasing the files of deleted sources, platform ticks, budget and retry releases, torrent tidy, audit, history pruning) and sleeps 5 s. Every turn also runs automine.send_due and converge.tick.

Triggers installed by jobruns.install copy every claim, requeue, settle and delete of a job row into job_run: one row per attempt with queued, released, started and finished times, lane and final message. Rows older than 30 days are pruned hourly. jobruns.stats summarizes wait and run times per kind.

GET /v1/jobs/active is how the UI shows progress; see HTTP API.

From a watch to an Anki card: watch, fetch, subtitles, timing check, mine, cut and score, queue, Anki

Step What happens Where
1. Report A client posts an event envelope (session.start, position, pause, resume, seek, session.end). The door checks the producer. app.post_event, admission.guard
2. Record The envelope is validated, the source found by alias or created (media, media_alias), the session opened, and the event appended to events with an idempotency key. A position, pause, resume, seek or end recomputes the session’s intervals. ingest.ingest, ledger/intervals.py
3. Dispatch On session.end: if the platform is mined (mine.enabled) and the same title is not already mined as another source, queue mine again for a source that already has lines and mines only what was watched, or else the platform’s fetch job. ingest._dispatch_mining_job, mine.kind_enabled, dedupe.py
4. Fetch For YouTube and Stremio, the shared fetch step learns the language and details, gets the media, and looks for subtitles: the platform’s own, tracks embedded in the file, then outside providers. Lines go into segment. With no usable subtitles it hands off to asr. A Spotify episode’s fetch gets its audio and hands off to asr directly. platforms/, fetch.py, segments.py, asr.py
5. Mine With mine.watched_only on, for a platform that reports positions (YouTube, Spotify), only lines inside watched intervals are mined; otherwise every line is. Each line is tokenized, unknown words are found against the known-word cache, sentences are scored and grouped per word, and one per word is chosen to send (gold, 金). What the mine consumed is recorded. It then queues enrich and starts the 判定. fetch_yt.handle_mine, mine.py, tokenize.py, known.py, mining/, freshness.record_mined
6. 判定 The timing check gathers subtitle candidates, transcribes short audio windows, and asks the judge whether the lines were spoken where each candidate says; it records the verdict and ranks the candidates. Then it measures where each word is spoken. Kinds: subtitles.pool, sync.evidence, sync.judge, sync.words. Details: subtitle sync. subpool.py, judge.py, evidence.py, probe_asr.py, judge_service.py, words.py
7. Enrich and cut Dictionary entries, translation, and the clip (.mp3) and screenshot. Cutting waits for upstream work on the source (WAITS_FOR); clips for cards not about to be sent can be deferred and cut when a card is opened. enrich.py, yomitan.py, translate.py, assets.py, vad.py
8. Score the clip Each cut is scored by the clip model; music-drowned and quiet clips can be held back. verify.py, clipscore.py, music.py
9. Send Cards that pass the gates are queued as automine.push jobs, now or at the daily time. The note’s fields are built, media stored, and the note added or updated through AnkiConnect; the link goes into anki_link. A person can also send from the editor. automine.queue_due, automine.handle_push, push.py, duplicates.py, anki.py

A card’s status is derived, not set: automine.settle computes it from the mined status, the person’s status, Anki links, known words and the send gates.

A source’s results are built from inputs: its subtitles, the known words, the gold settings, the clip offsets, the audio track, the code of each stage. When an input changes, the results built from it are stale. Three modules keep that honest.

versions.py holds one integer per stage (PARSE, JUDGE, WORDS, VERIFY, MINE) and COVERED, the files whose code each stage’s results depend on. Stored results carry the version they were built with, and a different current version makes them stale.

core/tests/test_stage_versions.py hashes each stage’s covered files (comments and docstrings removed) and compares the hash and version with core/tests/stage_versions.json. Any change to a covered file fails the test until you decide: if the stage’s results from the same inputs change, bump its number in versions.py; either way, record the new hash in the JSON.

freshness.record_mined stores what a mine consumed in the setting freshness.mined:<media_id>. freshness.stale_inputs compares that and the other records with the current state and names what moved: gold, known, mine, offset, timeline, clip_offsets, trim_rule, judge, lazy_gold, track, words, sync, parse, parse_lost, subs.

Each name belongs to exactly one stage in freshness.STAGES. A stage has a fixer that queues the work that clears it, the job kinds it watches while that work runs, and the stages it feeds:

Stage Stale names Fix Feeds
parse parse queues subtitles.reload in the press lane mine, sync, words, clips, judge
parse_lost parse_lost starts a 判定 pass that gathers the candidates again mine, words, clips, judge
mine subs, mine queues candidates.recalc (re-mine) sync, clips, judge
sync sync starts a 判定 pass words, clips, judge
words words queues sync.words, or a re-measure when the stored words are outdated clips, judge
known known queues anki.sync clips, judge
gold gold re-picks gold in place and queues cuts for new picks clips, judge
clips offset, timeline, clip_offsets, trim_rule, lazy_gold queues assets.recut judge
track track queues verify.measure for the audio track judge
judge judge queues verify.judge_missing (score unscored clips)

That is the rule: a stale state must be one its Fix clears. test_every_stale_name_has_exactly_one_stage_and_a_node in test_converge.py fails a name with no stage. The one state Fix cannot clear, parse_lost on a source that cannot be judged here, is shown as held with the reason, not as stale.

Pressing Fix (POST /v1/fix) only records intent: converge.press writes fix.press:<media_id> with a generation number and keep_edited, and lifts budget and retry holds on that source’s queued jobs. The worker’s converge.tick, every 5 s, then steps each pressed source:

  1. If any of the source’s stage jobs is running or queued unheld, wait.
  2. Compute the verdict (ledger.stats.source_verdict) and take the first owed stage that can be fixed. If its upstream jobs are held, the phase is waiting, with the hold named (deploy, budget, retry).
  3. If that same stage is still owed after its own run settled, stop as held with the reason: stopped, failed, skipped, refused, outage, or no progress.
  4. Otherwise run its fixer and count a step. After twice as many steps as there are stages it stops as held (a loop); a fixer that raises stops it as failed.
  5. Nothing owed and nothing pending: the press is dropped and the source is fresh. Only an unfixable stage owed: held. Checks still pending (trim measurements) show as checking for up to 2 h, then held.

The run’s state is kept in fix.run:<media_id>. converge.view turns it into the fix object each Sources row carries, and GET /v1/fix/graph returns the node graph the UI draws (freshness.GRAPH). Re-mining and what it keeps: recalculation.

There are three stores. Configuration covers them in full.

  • Installation settings are declared in settings_registry.py: name, type, default, whether it is secret, which feature it belongs to, help. .env.example is generated from it, and every consumer reads through it at call time. Platforms declare their own settings on the Platform.
  • Secrets are files, one per secret, under $AUTOMINER_SECRETS_DIR, written by autominer secret set, autominer setup or Settings. An environment variable of the same name wins over the file, and <NAME>_FILE points at a file elsewhere. They never go into the database. settings_registry.secret(name) reads them.
  • The settings table holds what the web UI edits, and also state the app keeps for itself (Fix runs, clip windows, pass markers and many more). PUT /v1/settings/{key} refuses those app-state keys with 403. A few settings accept a per-source-kind value as key:<kind>, such as automine.threshold:youtube.

Service URLs are both: a saved row and an environment variable. service_urls.resolve decides which wins: the environment, except for Anki’s URL, where the saved row wins. The Settings page itself is described in settings.

SQLite, one file at AUTOMINER_DB (default $AUTOMINER_HOME/autominer.db). db.connect turns on WAL, foreign keys and a 5 s busy timeout. db.init_db creates missing tables from schema.sql, adds missing columns, and installs triggers. schema.sql is not the whole column list: columns added later (for example media.deleted_at, the media.channel_* columns, anki_link.profile) are added by db._COLUMN_MIGRATIONS, so read both.

A database last started before the upgrade commit named in db.UPGRADE_THROUGH is refused at startup with that commit’s name. A request that still meets a locked database gets HTTP 503 with Retry-After: 5.

Table Holds
media One source: platform, title, language, platform IDs, subtitle offset, sync state, retention and QA flags.
media_alias Every <platform>:<id> name of a source, primary or redirect.
session One watch session on one device, open or closed.
events Every accepted event envelope, append-only, with its idempotency key.
interval Watched spans derived from a session’s events.
segment Subtitle lines on the source’s timeline, with their origin and how well each was heard.
segment_word Where each word of a line is spoken.
candidate A mineable sentence for one target word: text, clip, screenshot, scores, decision, status.
clip_feedback Events about a clip: plays, OK and NG checks, saves, sends, with the clip model’s score.
gone_decision The accept or reject of a card that was replaced or deleted, so its day still counts it.
cue_exclusion Lines excluded from mining.
anki_link Which Anki note a candidate became, in which profile, and how.
anki_whole_write The last whole-note write per note and Anki profile.
anki_seen Notes seen per AnkiConnect URL and profile.
anki_note A cache of Anki notes by expression.
known_word Known words, per scope.
known_word_note Which notes made a word known.
job The queue, one row per kind and key.
job_run The history of every job attempt (created by jobruns.install).
settings Key-value settings and app state.
platform_install Installed platforms.
asr_cost_log Paid transcription spend.
translation_cost_log Paid translation spend.
sync_run One timing run of a source: before and after, evidence, undo data.
deploy_admission The deploy barrier’s state (one row).
ingest_client Producers the core admitted, as evidence for the restart gate.
producer_policy The admission mode (one row).
producer_enrollment Producer identities an operator approved.
producer_rejection A bounded count of refused producers.
line_join The judge’s answers on whether two lines are one sentence.
yomitan_answer Cached Yomitan API answers.
dictionary, dictionary_term, dictionary_freq Imported dictionaries, their entries and frequency ranks.
sentence_quality Cached sentence-quality verdicts.
input_gen A change token per source and for clip settings, renewed by triggers (created by db.py).

The core serves the UI from core/static/; there is no build step. Each page is a plain HTML file that loads plain scripts with <script src>, and the scripts share globals. Page routes such as /today and /sources return the HTML; /static/* serves the rest. Both are sent with Cache-Control: no-cache, must-revalidate, so a deploy shows up on reload.

File Role
today.html, queue.html, sources.html, audit.html, clips.html, lines.html, spend.html, verifier.html, settings.html, setup.html The pages (the pages).
shell.js Shared by every page: navigation, api(), t(), patchHtml, job polling, maintenance banner, formatting helpers.
ui.js Shared widgets: chips, tags, column pickers, table headers.
editor.js, player.js, sync.js, neighbors.js The card editor, audio player, subtitle-timing panel, neighbor lines.
motion.js, swipe.js, scroll-keep.js, qtable.js, audit-config.js Animation, touch gestures, scroll keeping, the queue table, the audit settings.
native.js Plays clips through window.AutoMinerNative when the page runs in a host that provides it.
shell.css, editor.css, motion.css, qtable.css Styles.

Helpers every page uses:

  • api(path, opts) fetches, turns an error body (errors, detail or detail.message) into an ApiError, shows a held-for-deploy notice, and marks the pressed control busy while the request runs.
  • patchHtml(el, html) updates a region in place instead of replacing it, so polling does not reset focus or scroll.
  • t(ja, vars, ctx) translates. Japanese strings are the source; English comes from globalThis.I18N_EN, filled by i18n_en.js and the per-page files in i18n/. translateStatic translates the page’s static markup. The language is the setting ui.lang, mirrored in localStorage (autominer_ui_lang).

JavaScript is linted with ESLint (npm run lint, config in eslint.config.js).

extension/ is a Manifest V3 extension. content_video.js (driven by each platform’s Site) and content_spotify.js watch the player and build event envelopes; background.js keeps them in a persistent outbox in chrome.storage.local and posts them to POST /v1/events, oldest first, one at a time. It sends X-AutoMiner-Client: extension, its contract number and build. A refusal with scope: "producer" keeps the outbox and backs off; an envelope the core rejects as bad (400, 404, 422) is moved to a set-aside list. The popup (popup.html) takes the core URL and shows the outbox state. Installing and using it: Chrome extension. Refusals: producer admission.

android/morphe-patches/ is a Morphe patch bundle for the YouTube app, built with Gradle on its own. The patch reports playback (playing, paused, ended with position, duration, title and channel) through a persistent outbox to POST /v1/ingest/youtube-android, with the shared secret in X-AutoMiner-Secret. The core turns each report into an ordinary envelope (revanced.py). Setup: YouTube on Android.

Tests live in core/tests/ and run with pytest from the repository root. Folders are named for behavior:

Folder Covers
adapters/ Trackers, the Stremio and Spotify adapters, anime identity, the extension’s scope, the Android door.
ledger/ Intervals, session sweeps, statistics and Today.
media/ Jobs, assets, clips, 判定, freshness and Fix.
mining/ Candidates, scoring, gold, duplicates, sending to Anki.
sources/ Acquisition, transcription, subtitles and joins, podcasts, recalculation.
operations/ Admission, the deploy guard, audit, CLI, doctor, spend, the desktop launcher.
ui/ The web pages: their scripts run in Node, and static checks of the markup.
root Shared conftest.py, cross-area tests, browser probes, guards.

conftest.py isolates every test: it clears every registry setting from the environment, gives each test its own AUTOMINER_HOME, turns Yomitan off, treats every platform as installed (the platform_installs fixture restores the real check), and blocks program downloads (program_downloads restores them). API tests use FastAPI’s TestClient on autominer.app.app with a temporary database.

Run a targeted test while you work, then the checks CONTRIBUTING.md asks for:

Terminal window
python -m pytest core/tests/media/test_converge.py -q
python -m pytest core/tests -q -k "freshness and not mobile"

Browser tests. UI tests in ui/ cut named functions out of the static scripts (t_prelude.py) and run them in Node. The *_probe.js files at the root drive real pages in Playwright’s Chromium, found through AUTOMINER_CHROMIUM. Without Node, Playwright or Chromium they skip, and a skip is missing coverage, not a pass. Setup for the phone suite (-k mobile) is in CONTRIBUTING.md.

Guards. Some tests check rules rather than behavior: