# VideoStudy.app - Gemini Context

## Project Overview

**VideoStudy.app** is a .NET 8.0 platform designed to analyze YouTube videos using Artificial Intelligence. It leverages Microsoft Semantic Kernel to provide summaries, extract key moments, and generate study materials from video content.

The project is structured as a distributed application with a backend API handling AI processing and a Blazor Hybrid Desktop application for the user interface.

### Key Technologies
*   **Framework:** .NET 8.0
*   **AI Orchestration:** Microsoft Semantic Kernel (v1.70.0)
*   **LLM Providers:** Supports Groq (Cloud), Ollama (Local), and OpenAI.
*   **UI:** Blazor Hybrid (Razor Components) with Bootstrap 5.
*   **Video Processing:** YoutubeExplode (download), FFmpeg (screenshots), Whisper.net (transcription).
*   **Document Generation:** QuestPDF.

## Architecture

The solution (`VideoStudy.sln`) consists of the following key projects:

1.  **`VideoStudy.API`**: ASP.NET Core Web API.
    *   Acts as the central intelligence hub.
    *   Handles interaction with LLM providers via Semantic Kernel.
    *   Exposes endpoints for video analysis (`POST /api/analyze`) and health checks.
    *   Runs on `http://localhost:5000`.

2.  **`VideoStudy.Desktop`**: Blazor Hybrid Desktop Application.
    *   **Server Project:** `VideoStudy.Desktop` (Hosts the app, runs on `http://localhost:5001`).
    *   **Client Project:** `VideoStudy.Desktop.Client` (Wasm/UI logic).
    *   Provides the user interface for inputting URLs, viewing progress, and displaying results.
    *   Communicates with `VideoStudy.API` via HTTP.

3.  **`VideoStudy.Shared`**: Class Library.
    *   Contains shared data models (`AnalysisRequest`, `AnalysisResponse`, `KeyMoment`) ensuring type safety between API and Desktop.

## Development & Usage

### Prerequisites
*   .NET 8.0 SDK
*   FFmpeg (required for advanced processing features like screenshots)
*   An LLM Provider (Ollama running locally or an API Key for Groq/OpenAI)

### Building the Project
To build the entire solution:
```bash
dotnet build VideoStudy.sln
```

### Running the Application
The application requires **two separate terminals** running simultaneously.

**Terminal 1: Start the API**
```bash
cd VideoStudy.API
dotnet run
# Listens on http://localhost:5000
```

**Terminal 2: Start the Desktop App**
```bash
cd VideoStudy.Desktop/VideoStudy.Desktop
dotnet run
# Listens on http://localhost:5001
```

### Accessing the UI
Open your browser to `http://localhost:5001` to use the application.

## Configuration

Configuration is managed via `appsettings.json` files in the respective projects.

**LLM Configuration (`VideoStudy.API/appsettings.json`):**
To change the AI provider (e.g., switching from Groq to Ollama), update the `LlmSettings` section or modify the dependency injection in `Program.cs`.

**Desktop Configuration (`VideoStudy.Desktop/VideoStudy.Desktop/appsettings.json`):**
Ensure the `BaseUrl` points to the running API instance (default: `http://localhost:5000`).

## Project Structure

*   `VideoStudy.API/Controllers/`: API Endpoints.
*   `VideoStudy.Desktop/Components/Pages/`: Blazor UI Pages (e.g., `Home.razor`).
*   `VideoStudy.Desktop/Services/`: Client-side logic for FFmpeg, YouTube download, etc.
*   `VideoStudy.Shared/Models.cs`: Core data contracts.

## Current Status (Phase 2)

*   **Completed:** Basic API structure, UI layout (Bootstrap), Semantic Kernel integration, YoutubeExplode integration.
*   **In Progress:** Advanced transcription (Whisper.net), PDF generation, robust error handling, and persistence.

## Common Issues
*   **Connection Refused:** Ensure the API is running *before* trying to analyze a video in the Desktop app.
*   **Port Conflicts:** If ports 5000 or 5001 are in use, modify `launchSettings.json` or use `dotnet run --urls`.
