diff --git a/gitpodcast-analysis- b/gitpodcast-analysis- new file mode 100644 index 0000000..4cbe4f3 --- /dev/null +++ b/gitpodcast-analysis- @@ -0,0 +1,388 @@ +# GitPodcast 项目深度分析 + +## 1. 项目概述 + +**GitPodcast** 是一个将任意 GitHub 仓库转换为播客(podcast)的 Web 应用。用户输入 GitHub 仓库 URL,系统会自动分析仓库结构、关键文件和 README,利用大语言模型生成 SSML(语音合成标记语言)格式的播客脚本,再通过 Azure Speech Service 将其转换为带有字幕的音频播客。此外还支持生成基于 Marp 格式的幻灯片演示。 + +- **官网**: [https://gitpodcast.com](https://gitpodcast.com) +- **GitHub**: [https://github.com/BandarLabs/gitpodcast](https://github.com/BandarLabs/gitpodcast) +- **许可证**: MIT +- **灵感来源**: [Gitingest](https://gitingest.com/) 和 [Gitdiagram](https://gitdiagram.com/) + +--- + +## 2. 整体架构 + +项目采用 **前后端分离** 架构: + +``` +┌─────────────────────────────────────────────────────────┐ +│ 用户浏览器 │ +│ Next.js 前端 (Vercel/localhost:3000) │ +│ ┌──────────┐ ┌──────────────┐ ┌───────────────────┐ │ +│ │ 页面组件 │ │ Server Actions│ │ Drizzle ORM/PG │ │ +│ │ (React) │ │ (缓存逻辑) │ │ (数据库缓存) │ │ +│ └────┬─────┘ └──────┬───────┘ └───────────────────┘ │ +│ │ │ │ +│ └───────┬───────┘ │ +│ │ HTTP API 调用 │ +└───────────────┼─────────────────────────────────────────┘ + │ + ▼ +┌───────────────────────────────────────────────────────────┐ +│ FastAPI 后端 (EC2 Docker/localhost:8000) │ +│ ┌────────────┐ ┌──────────────┐ ┌───────────────────┐ │ +│ │ GitHub │ │ LLM 服务层 │ │ Azure Speech │ │ +│ │ Service │ │ (OpenAI/ │ │ Service │ │ +│ │ (获取仓库) │ │ Gemini/ │ │ (SSML→MP3+VTT) │ │ +│ │ │ │ Claude) │ │ │ │ +│ └────────────┘ └──────────────┘ └───────────────────┘ │ +└───────────────────────────────────────────────────────────┘ + │ │ │ + ▼ ▼ ▼ + GitHub API Azure OpenAI / Azure Cognitive + (仓库数据) Gemini Flash / Services Speech + Anthropic Claude (TTS Batch API) +``` + +--- + +## 3. 核心处理流程 + +### 3.1 播客生成主流程 + +``` +用户输入 GitHub URL + │ + ▼ +① GitHubService: 获取仓库数据 + ├── get_default_branch() → 仓库默认分支 + ├── get_github_file_paths_as_list() → 文件树(过滤掉 node_modules 等) + ├── get_github_readme() → README 内容 + └── get_github_file_content() → OpenAI 筛选的重要文件内容(≤10个文件) + │ + ▼ +② OpenAIService.get_important_files() → 从文件树中筛选最关键的 ≤10 个文件 + │ + ▼ +③ 组装内容 + 发送给 LLM 生成 SSML + ├── 短播客 (~5min): 单次调用 → PODCAST_SSML_PROMPT + └── 长播客 (~10min): 并发两次调用 + ├── 线程1: file_tree + readme → PODCAST_SSML_PROMPT_BEFORE_BREAK(上半场) + └── 线程2: important files → PODCAST_SSML_PROMPT_AFTER_BREAK(下半场) + → 合并两个 SSML 片段为完整播客 + │ + ▼ +④ SpeechService: SSML → 音频 + 字幕 + ├── text_to_mp3() → Azure Batch Synthesis API → MP3 字节 + ├── ssml_to_webvtt() → 根据语速估算时间戳 → WebVTT 字幕 + └── 返回 MP3 + base64(VTT) 在 HTTP 响应头中 + │ + ▼ +⑤ 前端缓存 + 播放 + ├── audioBlob →