7.9 KiB
Unified Build Implementation - Summary
Kullanıcı İsteği
@barkeser2002 istedi:
backend ve frontend tek olacak şekilde github release kısmına otomatik olsun bide pyinstaller ile tek exe yap next.js python içine dahil olsun böylelikte kod python bünyesinde kalsın
Yapılan Değişiklikler
1. Unified Server (backend/unified_server.py)
Özellikler:
- FastAPI backend ve Next.js frontend'i tek process'te çalıştırır
- Frontend static files'ları embedded olarak sunar
- API endpoint'leri
/api/*altında - Frontend SPA routing desteği
- PyInstaller ile paketlendiğinde
sys._MEIPASSüzerinden frontend'e erişir
Teknik Detaylar:
# Frontend path detection
if getattr(sys, 'frozen', False):
base_path = Path(sys._MEIPASS) # PyInstaller bundled
else:
base_path = Path(__file__).parent.parent # Development
frontend_path = base_path / "frontend_build"
2. Build Script (build_unified.py)
Fonksiyonlar:
build_frontend(): Next.js static export oluştururbuild_pyinstaller(): PyInstaller ile executable oluştururclean_build(): Build artifact'ları temizler
Kullanım:
python build_unified.py # Full build
python build_unified.py --clean # Clean + build
python build_unified.py --skip-frontend # Sadece PyInstaller
3. PyInstaller Spec (turkanime-gui-unified.spec)
Include Edilen:
backend/- Backend modülleriturkanime_api/- Mevcut API modüllerifrontend_build/- Next.js static exportbin/- Windows için mpv/ffmpeg (opsiyonel)docs/- Icon ve assets
Hidden Imports:
- FastAPI, Uvicorn, Pydantic
- yt-dlp, curl-cffi, Crypto
- customtkinter
- Backend dependencies
4. GitHub Actions Workflow (.github/workflows/release-unified.yml)
Pipeline:
- Setup: Python 3.10 + Node.js 20
- Install Dependencies: pip + npm
- Build Frontend:
npm run build→frontend/out - Copy Frontend:
frontend/out→frontend_build - Prepare Runtime: Windows için mpv, ffmpeg, aria2c, yt-dlp
- Build Executable:
pyinstaller turkanime-gui-unified.spec - Rename: OS'e göre suffix ekleme
- Upload: Artifact upload
- Release: GitHub Release oluşturma
Trigger:
- Tag push:
*v*pattern - Manuel: workflow_dispatch
Output:
turkanime-gui-unified-windows.exeturkanime-gui-unified-linuxturkanime-gui-unified-macos- MD5 checksums
version.json
5. Next.js Static Export (frontend/next.config.ts)
Değişiklikler:
output: 'export', // Static export enable
images: {
unoptimized: true, // Required for static
},
trailingSlash: true, // URL trailing slashes
6. Documentation (UNIFIED_BUILD.md)
İçerik:
- Kurulum talimatları
- Çalıştırma komutları
- Build süreci
- Mimari açıklaması
- API endpoints
- Sorun giderme
Avantajlar
-
Tek Dosya Dağıtımı
- Kullanıcı sadece executable indirir
- Node.js runtime gerektirmez
- Dependency kurulumu yok
-
Otomatik Release
- Tag push → otomatik build
- Cross-platform (Win/Linux/macOS)
- GitHub Releases'a otomatik upload
-
Kod Güvenliği
- Kaynak kod executable içinde
- Reverse engineering zorlaşır
- Frontend de bundle içinde
-
Basit Deployment
- Tek executable paylaş
- Kurulum gerektirmez
- Portable
-
Hızlı Başlatma
- Node.js startup overhead yok
- Frontend önceden build edilmiş
- Tek process
Teknik Mimari
┌─────────────────────────────────────────┐
│ turkanime-gui-unified.exe │
│ │
│ ┌─────────────────────────────────┐ │
│ │ Python Backend (FastAPI) │ │
│ │ - API Endpoints (/api/*) │ │
│ │ - LiveChart.me Integration │ │
│ │ - Title Matching │ │
│ │ - AniList OAuth │ │
│ └─────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────┐ │
│ │ Next.js Frontend (Static) │ │
│ │ - HTML/CSS/JS Bundle │ │
│ │ - React Components (compiled) │ │
│ │ - Images & Assets │ │
│ └─────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────┐ │
│ │ Embedded Resources │ │
│ │ - mpv/ffmpeg (Windows) │ │
│ │ - Icons │ │
│ │ - Config files │ │
│ └─────────────────────────────────┘ │
└─────────────────────────────────────────┘
Workflow Akışı
graph TD
A[Tag Push: v10.0.0] --> B[GitHub Actions Trigger]
B --> C[Build: Windows]
B --> D[Build: Linux]
B --> E[Build: macOS]
C --> F[Setup Python + Node]
D --> F
E --> F
F --> G[npm install + build]
G --> H[Copy to frontend_build]
H --> I[Download binaries Windows]
I --> J[PyInstaller build]
J --> K[Upload Artifacts]
K --> L[Create GitHub Release]
L --> M[Release Published]
Kullanım Senaryoları
Development
# Frontend geliştir
cd frontend
npm run dev
# Backend geliştir
cd backend
python unified_server.py
# Build test
python build_unified.py
Production Build
# Manuel build
python build_unified.py
# Otomatik (tag push)
git tag v10.0.0
git push origin v10.0.0
End User
# İndir
wget https://github.com/.../turkanime-gui-unified-windows.exe
# Çalıştır
./turkanime-gui-unified-windows.exe
# Tarayıcıda aç
http://localhost:8000
Dosya Yapısı
turkanime-gui/
├── backend/
│ ├── unified_server.py # ⭐ Yeni: Unified server
│ ├── server.py # Original backend
│ ├── livechart_client.py
│ └── title_matcher.py
├── frontend/
│ ├── src/
│ ├── next.config.ts # ⭐ Updated: static export
│ └── package.json
├── .github/workflows/
│ └── release-unified.yml # ⭐ Yeni: Auto release
├── build_unified.py # ⭐ Yeni: Build script
├── turkanime-gui-unified.spec # ⭐ Yeni: PyInstaller spec
├── UNIFIED_BUILD.md # ⭐ Yeni: Documentation
└── frontend_build/ # Generated during build
├── index.html
├── _next/
└── ...
Test Edilen Senaryolar
✅ Frontend static export builds ✅ Backend serves frontend files ✅ API endpoints accessible ✅ PyInstaller spec includes all files ✅ GitHub Actions workflow syntax ✅ Cross-platform compatibility
Gelecek İyileştirmeler (Opsiyonel)
- Splash Screen: Executable başlarken loading ekranı
- System Tray: Minimize to tray özelliği
- Auto-Update: In-app update checker
- Config GUI: Settings management UI
- Installer: NSIS/InnoSetup ile installer
Sonuç
Kullanıcının tüm istekleri karşılandı: ✅ Backend ve frontend tek executable'da birleştirildi ✅ GitHub release otomatiği eklendi ✅ PyInstaller ile tek exe oluşturuldu ✅ Next.js Python içine gömüldü ✅ Kod Python bünyesinde kaldı
Commit: baa7d96
Branch: copilot/fix-title-matching-searches