ShellRS
ShellRS is a free, open-source SSH client written in Rust: host management, terminals, WinSCP-style SFTP and port forwarding in one GPU-rendered window, for macOS, Windows and Linux.
Convert documents into Anki flashcards using AI
Developer toolsPython · JavaScriptGitHub @fjacquetOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
Owners of public repositories under a personal GitHub account can sign in to verify ownership and manage the introduction themselves. No administrator approval is needed.
Sign in, generate a verification file, and commit it to this repository’s default branch within 30 minutes. Files on other branches or forks do not count. Then check the file below to manage the project without administrator approval. Keep the file to retain your access.
If needed, you will go to sign-in. After signing in, return here and press your chosen verification button again.
Run /nomorevibe verify in your project folder to verify ownership and manage the introduction yourself.
Verify in one minuteAsk about other verification options
convert a document to anki using AI
Translation pending
Loading the full README.
Read the full README ↗Convert documents to Anki flashcards using AI-powered content analysis.
Document to Anki CLI is a comprehensive tool that transforms various document formats (PDF, DOCX, PPTX, TXT, MD) into high-quality Anki flashcards using Google's Gemini AI models. The application provides both CLI and web interfaces, allowing users to upload documents, preview and edit generated flashcards, and export them as Anki-compatible CSV files.
# Clone the repository
git clone <repository-url>
cd document-to-anki-cli
# Install dependencies using uv
uv sync
# Install in development mode (includes testing tools)
uv sync --all-extras
# Using pip (if uv is not available)
pip install -e .
# Install development dependencies
pip install -e ".[dev]"
The application requires configuration through environment variables. Create a .env file in the project root:
# Required: Gemini API Configuration
GEMINI_API_KEY=your-gemini-api-key-here
# Language Configuration (New Feature)
CARDLANG=english # Language for generated flashcard content
# Optional: Logging Configuration
LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERROR
LOGURU_LEVEL=INFO
# Optional: Model Configuration
MODEL=gemini/gemini-2.5-flash # Default model (see supported models below)
OPENAI_API_KEY=your-openai-api-key-here # Required for OpenAI models
# Optional: LLM Configuration
LITELLM_TIMEOUT=300 # Request timeout in seconds
# Supported Models:
# Gemini models (require GEMINI_API_KEY):
# - gemini/gemini-2.5-flash (default, fastest)
# - gemini/gemini-2.5-pro (more capable)
# OpenAI models (require OPENAI_API_KEY):
# - openai/gpt-4o (latest GPT-4)
# - openai/gpt-4 (standard GPT-4)
# - openai/gpt-3.5-turbo (faster, lower cost)
# Optional: Web Interface Configuration
WEB_HOST=127.0.0.1 # Web server host
WEB_PORT=8000 # Web server port
The application now supports configurable language output for flashcard generation. This allows you to generate flashcards in your preferred language regardless of the source document language.
| Language | Full Name | ISO Code | Example Setting |
|---|---|---|---|
| English | english | en | CARDLANG=english or CARDLANG=en |
| French | french | fr | CARDLANG=french or CARDLANG=fr |
| Italian | italian | it | CARDLANG=italian or CARDLANG=it |
| German | german | de | CARDLANG=german or CARDLANG=de |
# Generate flashcards in English (default)
CARDLANG=english
# Generate flashcards in French
CARDLANG=french
# or
CARDLANG=fr
# Generate flashcards in Italian
CARDLANG=italian
# or
CARDLANG=it
# Generate flashcards in German
CARDLANG=german
# or
CARDLANG=de
The language configuration affects:
Note: The source document can be in any language - the AI will read and understand it, then generate flashcards in your configured target language.
.env file as GEMINI_API_KEY.env file as OPENAI_API_KEY# Convert a single document
document-to-anki input.pdf
# Specify output location
document-to-anki input.pdf --output my-flashcards.csv
# Process a folder of documents
document-to-anki documents/ --output folder-flashcards.csv
# Process a PowerPoint presentation
document-to-anki lecture-slides.pptx --output lecture-flashcards.csv
# Process a ZIP archive
document-to-anki archive.zip --output archive-flashcards.csv
# Generate flashcards in French from an English document
CARDLANG=french document-to-anki english-textbook.pdf --output french-cards.csv
# Generate flashcards in German using ISO code
CARDLANG=de document-to-anki scientific-paper.pdf --output german-cards.csv
# Generate flashcards in Italian from multiple documents
CARDLANG=italian document-to-anki documents/ --output italian-study-cards.csv
# Use environment variable for consistent language across sessions
export CARDLANG=french
document-to-anki lecture1.pdf --output lecture1-fr.csv
document-to-anki lecture2.pdf --output lecture2-fr.csv
# Skip interactive preview (batch mode)
document-to-anki input.pdf --no-preview --batch
# Enable verbose logging
document-to-anki input.pdf --verbose
# Batch process multiple files
document-to-anki batch-convert file1.pdf file2.docx lecture.pptx folder/ --output-dir ./outputs/
# Show help
document-to-anki --help
When processing documents, the CLI provides an interactive menu for flashcard management:
# Start the web interface
document-to-anki-web
# Or specify host and port
uvicorn document_to_anki.web.app:app --host 0.0.0.0 --port 8080
The web interface includes comprehensive API documentation powered by FastAPI:
These endpoints provide complete documentation of all REST API endpoints, request/response schemas, and allow you to test the API directly from your browser.
Upload Documents: Drag and drop files or click to browse
Monitor Processing: View real-time progress and status updates
Manage Flashcards: Interactive flashcard editing interface
Export Results: Download Anki-compatible CSV files
from document_to_anki.core.document_processor import DocumentProcessor
from document_to_anki.core.flashcard_generator import FlashcardGenerator
# Initialize components
doc_processor = DocumentProcessor()
flashcard_gen = FlashcardGenerator()
# Process documents
result = doc_processor.process_upload("path/to/document.pdf")
# Generate flashcards
flashcards_result = flashcard_gen.generate_flashcards([result.text_content], result.source_files)
# Export to CSV
success, summary = flashcard_gen.export_to_csv("output.csv")
from pathlib import Path
from document_to_anki.core.llm_client import LLMClient
from document_to_anki.models.flashcard import Flashcard
# Custom LLM configuration with language support
llm_client = LLMClient(
model="gemini/gemini-2.5-flash",
timeout=300,
language="french", # Generate flashcards in French
)
# Generate flashcards directly from text
text = "Your educational content here..."
flashcard_data = llm_client.generate_flashcards_from_text_sync(text)
# Create flashcard objects
flashcards = []
for data in flashcard_data:
flashcard = Flashcard.create(
question=data["question"], answer=data["answer"], card_type=data["card_type"], source_file="manual_input"
)
flashcards.append(flashcard)
# Validate and export
valid_cards = [card for card in flashcards if card.validate_content()]
from document_to_anki.core.document_processor import DocumentProcessor
from document_to_anki.core.flashcard_generator import FlashcardGenerator
from document_to_anki.config import Settings
# Process the same document in multiple languages
languages = ["english", "french", "italian", "german"]
document_path = "scientific-paper.pdf"
for lang in languages:
# Create settings with specific language
settings = Settings(cardlang=lang)
# Initialize components with language-specific settings
doc_processor = DocumentProcessor()
flashcard_gen = FlashcardGenerator(language=lang)
# Process document
result = doc_processor.process_upload(document_path)
# Generate flashcards in the specified language
flashcards_result = flashcard_gen.generate_flashcards([result.text_content], result.source_files)
# Export with language-specific filename
output_file = f"flashcards_{lang}.csv"
success, summary = flashcard_gen.export_to_csv(output_file)
print(f"Generated {summary.total_cards} flashcards in {lang}")
| Format | Extension | Description |
|---|---|---|
.pdf | Portable Document Format files (with enhanced malformed PDF support) | |
| Word Document | .docx | Microsoft Word documents |
| PowerPoint | .pptx | Microsoft PowerPoint presentations |
| Text File | .txt | Plain text files |
| Markdown | .md | Markdown formatted files |
| ZIP Archive | .zip | Archives containing supported formats |
The application includes advanced PDF processing capabilities:
MAX_FILE_SIZE_MB)Configuration: File size limits can be adjusted using the MAX_FILE_SIZE_MB environment variable, which is automatically converted to bytes internally for validation.
This project maintains strict alignment between local development commands and CI pipeline execution. The GitHub Actions workflow uses the same Makefile targets that developers use locally, ensuring consistent behavior.
| CI Job | Makefile Target | Purpose |
|---|---|---|
| Setup | make install-dev | Install dependencies with all extras |
| Test | make test-cov | Run tests with coverage reporting |
| Quality | make ci-quality | Run all quality checks with CI-friendly output |
| Integration | make ci-test-integration | Run integration tests in CI mode |
| Validation | make validate | Validate configuration and environment |
| Build | make ci-build | Build package with CI-friendly output |
uv sync --all-extras for complete setupYou can run the exact same commands locally that run in CI:
# Test the complete CI pipeline locally
make ci-setup && make ci-quality && make ci-test && make ci-validate && make ci-build
# Individual CI steps
make ci-setup # Set up CI environment
make ci-quality # Quality checks with GitHub Actions format
make ci-test # Tests with CI-friendly output
make ci-validate # Configuration validation
make ci-build # Package build
If CI fails but local tests pass, check:
make ci-setup locally to match CI environmentmake ci-quality to see GitHub Actions formatted outputFor detailed troubleshooting, see CI-Makefile Troubleshooting.
document-to-anki-cli/
├── src/document_to_anki/ # Main package
│ ├── cli/ # Command-line interface
│ │ └── main.py # CLI entry point
│ ├── web/ # Web interface
│ │ ├── app.py # FastAPI application
│ │ ├── templates/ # HTML templates
│ │ └── static/ # CSS, JS, assets
│ ├── core/ # Core business logic
│ │ ├── document_processor.py # Document handling
│ │ ├── flashcard_generator.py# Flashcard management
│ │ └── llm_client.py # AI integration
│ ├── models/ # Data models
│ │ └── flashcard.py # Pydantic models
│ └── utils/ # Utility modules
│ ├── file_handler.py # File operations
│ └── text_extractor.py # Text extraction
├── docs/ # Documentation
│ ├── API.md # API reference
│ ├── CONFIGURATION.md # Configuration guide
│ ├── EXAMPLES.md # Usage examples
│ └── TROUBLESHOOTING.md # Troubleshooting guide
├── tests/ # Test suite
├── test_integration_check.py # Integration test for model configuration
├── pyproject.toml # Project configuration
└── README.md # This file
The project uses a Makefile-based development workflow that ensures consistency between local development and CI environments.
# Run all tests
make test
# Run tests with coverage report
make test-cov
# Run tests with fail-fast (stops on first failure)
make test-fast
# Run integration tests only
make test-integration
# Run integration tests with coverage
make test-integration-cov
# CI-specific test execution (used in GitHub Actions)
make ci-test
make ci-test-integration
# Run integration test for model configuration
python test_integration_check.py
# Run web app startup validation test
python test_startup_validation.py
Note: All test commands use the uv run prefix internally for consistent virtual environment handling.
The project includes enhanced testing infrastructure for reliable web integration testing:
web_client pytest fixture that properly initializes the FastAPI app state for testingDocumentProcessor, FlashcardGenerator, and SessionManager are available during testsTestClient doesn't run automaticallyThis ensures web integration tests run reliably with properly initialized dependencies, preventing common test failures related to missing app state.
The project uses Makefile targets that match the CI pipeline for consistent code quality checks:
# Run all quality checks (includes automatic formatting)
make quality
# Individual quality checks
make lint # Run linting and auto-fix issues
make format # Format code with ruff
make format-check # Check formatting without changes
make type-check # Run mypy type checking
make security # Run bandit security scan
make audit # Run dependency vulnerability check
# CI-specific quality checks (used in GitHub Actions)
make ci-quality
# Fix all auto-fixable issues
make fix
CI Alignment: The make ci-quality target uses GitHub Actions output format and is identical to what runs in CI, ensuring local and CI results match exactly.
The project uses a Makefile-based workflow that ensures consistency between local development and CI:
Setup Development Environment
make setup # Basic setup
make setup-full # Full setup with samples and environment
# Or manually:
make install-dev # Install with all development dependencies
Make Changes
Test Changes
make test # Run all tests
make quality # Run all quality checks (includes auto-formatting)
make pre-commit # Run full pre-commit validation
CI-Compatible Commands
# These commands match exactly what runs in GitHub Actions:
make ci-setup # CI environment setup
make ci-test # CI test execution
make ci-quality # CI quality checks
make ci-validate # CI configuration validation
make ci-build # CI package build
Submit Changes
make testmake qualityCI Alignment: All make ci-* targets use identical logic to GitHub Actions, ensuring local testing matches CI behavior exactly.
Handles document upload, validation, and text extraction.
Key Methods:
process_upload(upload_path): Process files, folders, or ZIP archivesvalidate_upload_path(path): Check if a path can be processedget_supported_formats(): Get list of supported file extensionsManages flashcard creation, editing, and export functionality.
Key Methods:
generate_flashcards(text_content, source_files): Generate flashcards from textpreview_flashcards(console): Display rich-formatted flashcard previewedit_flashcard(id, question, answer): Edit existing flashcarddelete_flashcard(id): Remove flashcard by IDadd_flashcard(question, answer, type): Add new flashcard manuallyexport_to_csv(output_path): Export flashcards to CSV formatHandles communication with Gemini LLM through litellm.
Key Methods:
generate_flashcards_from_text(text): Async flashcard generationgenerate_flashcards_from_text_sync(text): Synchronous flashcard generationchunk_text_for_processing(text, max_tokens): Split large text into chunksPydantic model representing a single flashcard.
Fields:
id: Unique identifierquestion: Question textanswer: Answer textcard_type: "qa" or "cloze"source_file: Original file namecreated_at: Creation timestampMethods:
create(question, answer, card_type, source_file): Class method to create new flashcardto_csv_row(): Convert to Anki-compatible CSV formatvalidate_content(): Check if flashcard content is validFor detailed information, see the comprehensive documentation in the docs/ folder:
If you're upgrading from a version that had hardcoded French flashcard generation, here's what you need to know:
For users who want to keep French flashcards:
# Add this to your .env file
CARDLANG=french
For users who want English flashcards (new default):
# No action needed - English is now the default
# Or explicitly set:
CARDLANG=english
For users who want other languages:
# Italian flashcards
CARDLANG=italian
# German flashcards
CARDLANG=german
The new language system provides:
Problem: "My flashcards are now in English instead of French"
# Solution: Add French language configuration
echo "CARDLANG=french" >> .env
Problem: "Error: Unsupported language 'francais'"
# Solution: Use supported language codes
CARDLANG=french # or CARDLANG=fr
Problem: "I want to switch between languages for different documents"
# Solution: Use environment variables per command
CARDLANG=french document-to-anki french-doc.pdf
CARDLANG=german document-to-anki german-doc.pdf
Error: Failed to generate flashcards: API key not found
Solution: Ensure GEMINI_API_KEY is set in your .env file or environment variables.
Error: Unsupported file type: .xyz
Solution: Check that your files are in supported formats (PDF, DOCX, TXT, MD, ZIP).
Error: Memory allocation failed
Solutions:
Error: Failed to connect to AI service
Solutions:
Error: Unsupported language 'spanish'. Supported languages: english, en, french, fr, italian, it, german, de
Solution: Use one of the supported language codes:
# Correct language settings
CARDLANG=english # or en
CARDLANG=french # or fr
CARDLANG=italian # or it
CARDLANG=german # or de
Warning: Generated flashcards may not be in the correct language
Solutions:
Error: Language validation failed for generated content
Solutions:
For complete troubleshooting information, see docs/TROUBLESHOOTING.md.
If you encounter issues with CI-Makefile alignment:
# Test CI pipeline locally
make ci-setup && make ci-quality && make ci-test && make ci-validate && make ci-build
# Debug environment differences
make debug-env
make check-env
# Use CI-equivalent commands
make ci-quality # Instead of individual quality tools
make ci-test # Instead of direct pytest
See the CI-Makefile Troubleshooting section for detailed guidance.
We welcome contributions! Please follow these guidelines:
git clone https://github.com/yourusername/document-to-anki-cli.gituv sync --all-extrasgit checkout -b feature/amazing-featureuv run pytestuv run ruff check && uv run mypy src/git push origin feature/amazing-featureThis project is licensed under the MIT License. See the LICENSE file for details.
make install-dev to use --all-extras for complete dependency installationmake quality, , and now automatically apply formatting fixesThis project maintains strict consistency between local development and CI environments through:
make test → CI: make test-covmake quality → CI: make ci-qualitymake validate → CI: make validatemake build → CI: make ci-builduv run prefix and error handling# Test the complete CI pipeline locally
make ci-setup && make ci-quality && make ci-test && make ci-validate && make ci-build
For detailed information, see the CI-Makefile Integration section and CI-Makefile Troubleshooting.
make formatmake lintdocs/ folder
ci-setup, ci-test, ci-quality, ci-validate, ci-build) for optimized CI executionuv run usage throughout all commands