# VideoStudy.app - FASE 1 Setup Guide ## ✅ Estrutura Base Criada ``` VideoStudy.app/ ├── VideoStudy.API/ # ✅ Web API (port 5000) │ ├── Program.cs # Endpoints + Semantic Kernel config │ ├── appsettings.json # LLM provider configuration │ └── bin/Debug/... # Compiled binaries │ ├── VideoStudy.Desktop/ # ✅ Blazor Hybrid Desktop App │ ├── VideoStudy.Desktop/ # Server │ │ ├── Program.cs # App setup + HttpClient │ │ ├── appsettings.json # API base URL config │ │ └── Components/Pages/Home.razor # Main UI with form │ └── VideoStudy.Desktop.Client/ # WebAssembly client │ ├── VideoStudy.Shared/ # ✅ Shared Models │ └── Models.cs # AnalysisRequest, AnalysisResponse, etc. │ ├── REFERENCES.md # Análise de projetos referência ├── README.md # Project documentation ├── SETUP.md # Este arquivo └── VideoStudy.sln # Solution file ``` ## 🚀 Como Iniciar ### Terminal 1: Executar a API ```bash cd /mnt/c/vscode/VideoStudy.app/VideoStudy.API dotnet run ``` **Output esperado:** ``` Building... Built successfully. info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:5000 Press CTRL+C to quit ``` **Testar Health Check:** ```bash curl http://localhost:5000/health ``` Resposta esperada: ```json {"status":"ok","timestamp":"2026-02-06T10:00:00Z"} ``` ### Terminal 2: Executar Desktop App ```bash cd /mnt/c/vscode/VideoStudy.app/VideoStudy.Desktop/VideoStudy.Desktop dotnet run ``` **Output esperado:** ``` Building... Built successfully. info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:5001 Press CTRL+C to quit ``` **Acesso:** Abra browser em http://localhost:5001 ## 🎯 Como Testar a Integração ### 1. Abrir a Interface Web - URL: http://localhost:5001 - Você verá um formulário com: - Campo de URL do YouTube - Seletor de idioma - Opções: Modo Fast vs Advanced - Botão "Analyze Video" ### 2. Enviar Requisição de Teste Preencha no formulário: - **YouTube URL:** `https://www.youtube.com/watch?v=dQw4w9WgXcQ` - **Language:** English - **Mode:** Fast - Clique em **"Analyze Video"** ### 3. Verificar Resposta Você deve ver: - ✅ Barra de progresso - ✅ Debug logs mostrando cada etapa - ✅ Resultado com: - Video Title - Transcript Summary - Analysis - Key Moments ### 4. Testar via API diretamente (curl) ```bash curl -X POST http://localhost:5000/api/analyze \ -H "Content-Type: application/json" \ -d '{ "videoUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ", "language": "en", "mode": "fast" }' ``` Resposta esperada: ```json { "videoTitle": "Example Video: dQw4w9WgXcQ", "transcript": "This is a simulated transcript. Mode: fast, Language: en", "analysis": "This is a simulated analysis of the video content...", "keyMoments": [ { "timestamp": "00:00:15", "description": "Introduction", "startSeconds": 15 }, { "timestamp": "00:02:30", "description": "Main topic", "startSeconds": 150 }, { "timestamp": "00:05:00", "description": "Conclusion", "startSeconds": 300 } ], "status": "success", "errorMessage": null } ``` ## 🔧 Configuração de Providers ### Usar Ollama (Local) 1. Instale Ollama: https://ollama.ai 2. Inicie: `ollama serve` 3. Puxe modelo: `ollama pull llama2` 4. Edite `VideoStudy.API/Program.cs` (linha 32): ```csharp builder.Services.AddOpenAIChatCompletion(modelId, new Uri(endpoint), apiKey); ``` Comente e descomente a linha 23: ```csharp builder.Services.AddOllamaChatCompletion("llama2", new Uri("http://localhost:11434")); ``` ### Usar Groq (Cloud, Grátis) 1. Crie conta: https://console.groq.com/ 2. Gere API Key 3. Configure em `VideoStudy.API/appsettings.json`: ```json "LlmSettings": { "ApiKey": "gsk_your_actual_key_here" } ``` ## 🏗️ Estrutura de Arquivos Criados ### VideoStudy.Shared/Models.cs ```csharp - AnalysisRequest (input) - AnalysisResponse (output) - KeyMoment (timestamp + description) - ProgressUpdate (for future streaming) ``` ### VideoStudy.API/Program.cs - GET `/health` - Health check - POST `/api/analyze` - Main endpoint (atualmente retorna mock data) - Semantic Kernel registrado (pronto para FASE 2) - CORS habilitado - LLM provider configurable ### VideoStudy.Desktop/Home.razor - URL input - Language selector - Mode selector (Fast/Advanced) - Progress bar - Results display - Debug logs - Error handling ## 📋 Portas Utilizadas | Aplicação | Porta | URL | |-----------|-------|-----| | API | 5000 | http://localhost:5000 | | Desktop | 5001 | http://localhost:5001 | ⚠️ Se as portas estiverem em uso: ```bash # Encontrar processo usando porta 5000 netstat -ano | findstr :5000 # Windows lsof -i :5000 # Linux/Mac # Mudar porta no appsettings.json ou: dotnet run --urls "http://localhost:5100" ``` ## ✨ O que Funciona - ✅ Build da solução - ✅ API respondendo em `/health` e `/api/analyze` - ✅ Desktop conectando à API - ✅ Formulário web funcional - ✅ Debug logs mostrando fluxo - ✅ Tratamento de erros básico - ✅ Semantic Kernel integrado (ready for FASE 2) ## ⏭️ Próximos Passos (FASE 2) - [ ] Integrar YouTubeService (download de vídeos) - [ ] Integrar yt-dlp para extração de legendas - [ ] Integrar Whisper.NET para transcrição - [ ] Integrar FFmpeg para screenshots - [ ] Implementar WebSocket para progress real-time - [ ] Adicionar persistência (MongoDB) - [ ] Implementar modos Fast/Advanced completos ## 🐛 Troubleshooting ### "Cannot connect to API" - Verifique se API está rodando em outro terminal - Verifique que porta 5000 está aberta - Verifique `appsettings.json` do Desktop ### "Build failed" ```bash dotnet clean dotnet restore dotnet build ``` ### "Semantic Kernel errors" - Verifique versão: `dotnet package search Microsoft.SemanticKernel` - Atualize: `dotnet package update` ## 📞 Informações de Compilação - **Framework:** .NET 8.0 - **Último Build:** ✅ Sucesso (0 erros, 0 warnings) - **Projetos:** 4 (Shared, API, Desktop, Desktop.Client) - **Tamanho solução:** ~50MB (depois de compilada) --- **Status FASE 1:** ✅ COMPLETO E FUNCIONANDO