Project Brief: AI Model Switching and Backend Optimization Background: Our AI-powered application uses an Apollo/GraphQL backend and multiple integrated AI models for reasoning, judgment, transcription, and OCR. The previous developer managed model setups manually. I now need the system restructured so that I (the client) can switch models directly in the backend, once properly trained. Objectives Backend Model Switching: Implement a modular setup so models can be switched or added easily by editing backend configuration (e.g., .env or MySQL model table). No hard-coded parameters — the system should pull model settings dynamically (model name, endpoint, temperature, token limits, etc.). After setup, provide me a short walkthrough or documentation on how to: Switch model providers (OpenAI, Gemini, Granite, etc.) Add new ones in the future Restart or reload the backend to apply changes File Audit and Refactor: Review and document the following files that define or call AI models: src/Helpers/AskAI.ts src/Helpers/AITools.ts src/cron/AIJudgement.ts src/cron/AITasks.ts Ensure model calls are handled via a single central function or model loader, to make switching consistent across the app. GraphQL Backend Integration: Add a mutation for restarting failed judgment processes. Integrate it into the admin-back-office: Create a secure endpoint for restart Add mutation under the graphql folder Modify components/documents.tsx to use it for the “Restart” button Include input sanitization and permissions. Recommended Models to Test/Integrate: Google Gemini 2.5 Pro – general reasoning, strong context handling IBM Granite 4.0 – fast, lightweight, cost-effective, low resource use Qwen3-VL 4B – for vision/OCR acceleration, smaller and faster DeepSeek OCR – advanced lightweight vision-language model DeepSeek OCR Paper Performance & Security Guidelines: Use indexed fields for any database status checks. Keep API keys and endpoints in .env or a secured config file. Sanitize all GraphQL inputs and ensure permissions for admin-only actions. Comment your code well to help future edits. Deliverables Modular backend model configuration system Working GraphQL restart mutation Documentation or short training session (to show me how to switch models manually) Optional: a summary table or JSON config listing all available models and their parameters