How vivaswt/notion2anki works
Main Components
• Entry Point (Main) – Represented by src/Main.hs. This module orchestrates the flow of the application.
• Notion Integration Module – Represented by src/NotionFlashCard.hs. It contains logic to interface with the Notion database and extract flashcard properties.
• Anki Integration Module – Represented by src/Anki.hs. It handles the addition of flashcards (with images and audio) to the Anki application.
• Google Text-to-Speech Integration – Represented by src/GoogleAPI.hs. It is used for generating audio from text using the Google TTS API.
• External Systems – Notion API (for fetching flashcard data) and Anki (for flashcard import).
Relationships and Interactions
• Main Module acts as the central controller: it retrieves environment variables (PRIVATE_NOTION_TOKEN and GOOGLE_TTS_API_KEY), initiates the data fetching from the Notion Integration Module, optionally invokes GoogleAPI for audio generation, and finally calls the Anki module to post the flashcards.
• Data Flow: NotionFlashCard.hs fetches and structures flashcard entries → Main.hs processes or augments flashcard content (invoking GoogleAPI.hs where needed) → Passes finalized flashcards to Anki.hs for integration.
Architectural Patterns and Design Choices
• Modular Separation: The project clearly separates concerns by isolating the logic for each external integration into its own module.
• Configuration via Environment Variables: The use of environment variables to manage API tokens indicates that the application is designed for secure and flexible configuration.
Relevant Technologies and Frameworks
• Haskell as the programming language with its build and dependency management handled by Stack (stack.yaml, stack.yaml.lock) and Cabal (notion2anki.cabal).
• External APIs such as Notion’s API and Google Text-to-Speech API.
• Anki (for flashcard management) as the target system.