How obsidiantoanki/obsidian_to_anki works
Main components
• Python Script: The standalone command-line utility (obsidian_to_anki.py and obstoanki_setup.py) that can be run outside Obsidian to scan files, generate configuration (obsidian_to_anki_config.ini), and interact with the file system.
• Communication with Anki: Both the plugin and the script use the AnkiConnect RESTful API. Show this as an external Anki component (with details like API key setup and port 8765 as specified in the README).
• Configuration & Settings: Include the default configuration files, defaults in “root/defaults”, and the extensive support for custom syntax defined via configuration (using matcher files, regex, and settings interfaces in “src/interfaces”). This represents the customization layer.
• Testing/CI Components: The “tests” directory and GitHub workflows indicate automated testing (including integration tests for various flashcard styles and folder scanning) that ensure functionality.
• Build & Deployment Artifacts: Build scripts like rollup.config.js and Dockerfile illustrate that the code is bundled and containerized; these should be represented as the build/deployment support layer.
Relationships and interactions
• The scanned files are parsed by the front-end module or processing scripts (using the logic in “src” and helper modules) that convert markdown to Anki-ready notes.
• Additionally, configuration management is done via local config files (ini, JSON, or via defaults) and is read/written by both the plugin and the script.
• The testing suite simulates both file input scenarios and API interactions to verify correct processing.
Important architectural patterns & design principles
• Separation of Concerns: There are clearly separated modules for parsing/formatting (e.g., format.ts, file.ts), configuration (settings.ts and interfaces), and integration with external systems (AnkiConnect).
• Dual Usage Path: The architecture supports two modes (GUI integration as an Obsidian plugin, and CLI usage as a Python script) while sharing common processing logic (custom syntax for flashcards) and configuration mechanisms.
• Extensibility: The extensive use of custom syntax configuration (regular expressions, support for many markdown styles) underlines a plugin/extensible design.
Relevant technologies, frameworks, or libraries
• TypeScript/JavaScript: For the Obsidian plugin code (located in “src”), which transforms markdown input.
• Python: For the command-line version of the tool.
• AnkiConnect: For communication with Anki.
• Docker & CI/CD: Dockerfile for containerization and GitHub workflows for continuous integration.
• Testing Frameworks: The “tests” directory indicates a combination of e2e tests and unit tests (some written in Python, some in TypeScript as indicated by .ts files).
• Labels: Name each component clearly – e.g., “Obsidian Plugin (UI & Processing)”, “Python CLI Utility”, “Anki (with AnkiConnect API)”, “Configuration Manager”, “Test Suite / CI”.