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)
- Navigate to a deck’s show page
- Click the “Export Anki” button
- The Anki package will be generated and emailed to you as an attachment
Batch Export (Admin)
- Navigate to the Admin panel:
/admin/decks - Select the decks you want to export using the checkboxes
- From the “Batch Actions” dropdown, select “Download for Anki”
- 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:
- Calls
Decks::Anki::AttachServiceto generate and attach the Anki package - The package is attached to the deck’s
anki_deckActiveStorage 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
Related Files
app/services/decks/anki/download_service.rb- Batch download serviceapp/services/decks/anki/attach_service.rb- Single deck attach serviceapp/services/decks/anki/package_service.rb- Anki package generation serviceapp/admin/decks/decks.rb- Admin batch action