Anki Deck Export

This document describes the workflow for exporting Immersive decks as Anki packages.

Overview

The Anki export feature allows users to export individual decks via email, and admins to batch export multiple public decks. Exported decks are packaged as .apkg files that can be directly imported into Anki.

Usage

Single Deck Export (User)

  1. Navigate to a deck’s show page
  2. Click the “Export Anki” button
  3. The Anki package will be generated and emailed to you as an attachment

Batch Export (Admin)

  1. Navigate to the Admin panel: /admin/decks
  2. Select the decks you want to export using the checkboxes
  3. From the “Batch Actions” dropdown, select “Download for Anki”
  4. Click “OK” to confirm

The Anki packages will be generated and attached to each deck’s anki_deck ActiveStorage attachment. You can download them from the admin deck show page.

How It Works

The Decks::Anki::DownloadService performs these steps for each deck:

  1. Calls Decks::Anki::AttachService to generate and attach the Anki package
  2. The package is attached to the deck’s anki_deck ActiveStorage attachment

Architecture

Single Deck Export Flow

User clicks "Export Anki"
    │
    ▼
Decks::AnkiExportMailer.email
    │
    ▼
Decks::Anki::PackageService
    │
    ├─ Generates Anki deck using genanki-ruby
    ├─ Collects audio files from cards
    ├─ Creates .apkg package file
    │
    ▼
Email sent with .apkg attachment

Admin Batch Export Flow

Admin selects decks → Batch Action
    │
    ▼
Decks::Anki::DownloadService
    │
    ├─ For each deck:
    │   │
    │   ▼
    │   Decks::Anki::AttachService
    │       │
    │       ├─ Decks::Anki::PackageService (generates .apkg)
    │       │
    │       ▼
    │   Attach .apkg to deck.anki_deck (ActiveStorage)
    │
    ▼
Admin can download from deck show page
  • app/services/decks/anki/download_service.rb - Batch download service
  • app/services/decks/anki/attach_service.rb - Single deck attach service
  • app/services/decks/anki/package_service.rb - Anki package generation service
  • app/admin/decks/decks.rb - Admin batch action

This site uses Just the Docs, a documentation theme for Jekyll.