# How it works

### User Workflow: Step-by-Step

Here’s how you typically interact with Ghost for interview preparation:

1. **Launch Ghost:** Start the application. A discreet, minimal window will appear on your screen.
2. **Configure Settings:** The first time you run Ghost (or if you need to change settings), use `Ctrl + Shift + I` (Windows/Linux) or `Cmd + Shift + I` (macOS) to open the settings menu. Here you will:
   * Enter your personal API key (either OpenAI or Google Gemini).
   * Select your preferred AI models for different tasks (e.g., problem extraction, solution generation).
3. **Capture the Problem:** When you encounter a coding problem you want to analyze (e.g., on a web page or in an editor), position the Ghost window if needed and use `Ctrl + H` / `Cmd + H`. Ghost takes screenshots, designed to capture both problem text and code snippets effectively.
4. **Process with AI:** Once screenshots are captured, press `Ctrl + Enter` / `Cmd + Enter`. This action initiates the AI processing sequence using *your* API key.
5. **AI Analysis & Solution:**
   * Ghost sends the captured screenshot data directly to the selected AI provider (OpenAI or Google Gemini).
   * The AI first extracts and understands the coding problem from the visual data.
   * It then generates an optimized solution, often including detailed explanations and time/space complexity analysis.
6. **Review Solution:** The AI-generated solution appears within the Ghost window for you to study and learn from.
7. **Manage the Window:** While using Ghost, you can:
   * Move the window: `Ctrl + Arrow keys` / `Cmd + Arrow keys`
   * Toggle visibility: `Ctrl + B` / `Cmd + B`
   * Adjust opacity: `Ctrl + [` / `Cmd + [` (Decrease) and `Ctrl + ]` / `Cmd + ]` (Increase)
   * *(Resize and Zoom functionality may also be available)*
8. **Start New Problem:** Press `Ctrl + R` / `Cmd + R` to clear the current context and prepare Ghost for a new problem-solving session.

### Core Mechanisms: Under the Hood

Understanding how Ghost operates can help you use it effectively:

* **Stealth Interface:**
  * Ghost is designed with a "Stealth Mode" – an interface intended to be minimally intrusive and bypass *many* screen capture methods during practice sessions.
  * **Invisibility Details (Based on Testing):**
    * **Hidden From:** Zoom (versions older than 6.1.6), browser-based screen recording, Discord (all versions), standard macOS screenshots (`Cmd+Shift+3/4`).
    * **Visible To:** Zoom (versions 6.1.6 and newer), native macOS screen recording (`Cmd+Shift+5`).
  * The exact technical methods aim to prevent the window from being included in the video feed or recording of specific applications, but it's not universally undetectable.
* **Smart Capture & AI Processing:**
  * The screenshot function captures visual information from your screen.
  * When you trigger processing, Ghost sends this visual data directly to the external AI's API endpoint (like GPT-4o Vision or Gemini).
  * **Crucially, this uses your personal API key.** The AI interprets the image, extracts the problem, and generates the solution. Ghost acts as the interface and orchestrator for these API calls.
* **AI Model Integration:**
  * You can choose between supported AI models (currently OpenAI and Google Gemini families) within the settings.
  * This allows flexibility based on cost, performance, or preference for different tasks (extraction vs. solution generation).
* **Debugging Assistance:**
  * Ghost leverages the AI to provide structured feedback and assistance for debugging your own code snippets, helping you identify and fix errors during practice.
* **Privacy:**
  * Your API key is stored locally on your machine and is *only* used to make direct calls to the AI provider (OpenAI/Gemini) when you initiate processing.
  * Ghost does not send your key or problem data to any intermediary servers.
* **Extensibility:**
  * The application is designed to be extensible. Developers can integrate support for other Large Language Models (LLMs) like Claude, Deepseek, etc., by modifying the API handling code found in `/src/main/processor`.

### Tech Stack

Ghost is built using modern web technologies packaged as a desktop application:

* **Framework:** Electron
* **UI:** React, TypeScript, Tailwind CSS, Radix UI Components
* **AI Integration:** Direct API calls to OpenAI and Google Gemini.
