How shobhits7/gemini_craft works
Main components
• GeminiCraft Core: Represented by the central module (lib/gemini_craft.rb) that ties all subcomponents together.
• Configuration Module: (lib/gemini_craft/configuration.rb) Handles setting API keys, model selection, caching options, timeout configurations, and retry attempts.
• Client Module: (lib/gemini_craft/client.rb) The main interface that the user interacts with. It accepts prompts and optional system instructions along with additional options, and it orchestrates generating content.
• Cache Module: (lib/gemini_craft/cache.rb) Manages caching logic when enabled.
• Error Handling: (lib/gemini_craft/error.rb) Captures and defines custom errors related to API calls or configuration issues.
• Versioning: (lib/gemini_craft/version.rb) Manages gem versioning.
• External Service: Google’s Gemini API – note that although it isn’t part of the gem’s file structure, it is the external endpoint/service that the Client interacts with.
Relationships and interactions
• A user application configures GeminiCraft using the Configuration Module. This sets up parameters like API keys and caching preferences.
• The Client module (GeminiCraft.client) is then used to call the generate_content method. This call internally utilizes the configuration settings.
• The Client sends requests to the external Gemini API. If caching is enabled, requests/responses flow through the Cache Module, which may store and retrieve responses to optimize performance.
• Any issues encountered during API calls are managed by the Error Handling Module.
• Overall, the core module (gemini_craft.rb) acts as the entry point and integrates these various submodules cohesively.
Architectural patterns and design principles
• Modularity: The gem is designed in clearly separated modules (configuration, client, caching, error) which are independently managed and tested.
• Separation of concerns: Each module is responsible for a specific task, enabling easier maintenance and extensibility.
• Configurability: The use of a configuration block to adjust behaviors shows that the design focuses on flexible and customizable usage.
Final checklist
• Component (GeminiCraft core, Configuration, Client, Cache, External API, Error Handling).