How ecuidev/obsidian-quiz-generator works
Main Components
• UI Layer:
• Located in the src/ui directory (with subdirectories for components, quiz, and selectors).
• Contains interactive components (e.g., AnswerInput.tsx, QuizModal.tsx, ModalButton.tsx) that enable users to interact with the quiz generator (e.g., generating questions, reviewing quizzes, and selecting folders/notes).
• Generator Modules (Business Logic):
• Found under src/generators, where each subdirectory (openai, google, anthropic, etc.) implements a provider-specific generator along with its corresponding models.
• A generator factory (generatorFactory.ts) encapsulates the logic to choose the appropriate generator for the configured provider.
• Settings and Configuration:
• Organized in src/settings with subdivisions for general settings, generation settings, saving settings, and model-specific settings.
• These modules define configuration parameters such as API keys, generation rules, file paths for saving quizzes, and provider-specific configurations.
• Services:
• In src/services, with modules like quizReviewer.ts and quizSaver.ts, which are responsible for processing quiz data, handling reviews, and persistence.
• Utilities:
• Helper functions and type guards in src/utils (e.g., helpers.ts, markdownCleaner.ts) that provide support across various parts of the system.
• External API Integrations:
Relationships and Interactions
• The UI components trigger quiz generation (via button interactions or command palette triggers).
• The UI layer calls into the generator modules (using a factory pattern from generatorFactory.ts) to create the quiz data.
• Generator modules use settings (built out from the src/settings directory) to determine how to interact with the specific provider’s API.
• Once a request is processed, the generators return question data that flows back to the UI for rendering and may also be handled by the quizSaver service to persist the quizzes locally in Markdown format.
• Helper utilities and type-check functions support these modules by ensuring data integrity and proper formatting.
Architectural Patterns and Design Principles
• Modular Design: Each provider’s generator is implemented in its own subdirectory, allowing easy extension for new providers.
• Factory Pattern: The generatorFactory.ts centralizes the creation logic for different quiz generators.
• Separation of Concerns: Clear division between UI, business logic (generators), settings/configuration, and persistence (services).
• External Service Integration: Well-defined interfaces between the internal application and external provider APIs.
• Configurability: The settings module ensures that end-users can adjust the behavior of the plugin without changing core logic.
Final Detailing
• That every major file or directory in the file tree that plays a role in the architecture is conceptually represented.