Files
ratebubble/README.md
2026-02-28 02:44:41 +03:00

172 lines
4.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Netflix Scraper API
Netflix içerik sayfalarından film/dizi bilgilerini çeken yüksek performanslı bir backend API servisi.
## Özellikler
- **Scraping**: Netflix URL'lerinden otomatik içerik bilgisi çekme
- **Cache**: Redis ile 7 günlük önbellek (yapılandırılabilir)
- **Kalıcılık**: PostgreSQL ile verilerin kalıcı saklanması
- **Real-time**: Socket.IO ile canlı ilerleme bildirimleri
- **Güvenlik**: API Key authentication ve rate limiting
- **Docker**: Tek komut ile ayağa kalkma
## Hızlı Başlangıç
```bash
# .env dosyasını oluştur
cp .env.example .env
# API key'leri düzenle
nano .env
# Başlat (tek komut!)
docker compose -f docker-compose.dev.yml up --build
```
API şu adreste çalışacak: `http://localhost:3000`
## API Kullanımı
### İstek Örneği
```bash
curl -X POST http://localhost:3000/api/getinfo \
-H "Content-Type: application/json" \
-H "X-API-Key: web-dev-key-change-me" \
-d '{"url": "https://www.netflix.com/tr/title/81616256"}'
```
### Yanıt Örneği
```json
{
"success": true,
"data": {
"title": "Hayata Röveşata Çeken Adam",
"year": 2022,
"plot": "Dünyaya karşı duyduğu öfke...",
"genres": ["18+", "Komedi"],
"cast": ["Tom Hanks", "Mariana Treviño", "Rachel Keller"],
"backdrop": "https://occ-0-7335-..."
}
}
```
## Endpoints
| Method | Endpoint | Açıklama |
|--------|----------|----------|
| `GET` | `/health` | Sağlık kontrolü |
| `GET` | `/ready` | Bağımlılık kontrolü |
| `POST` | `/api/getinfo` | İçerik bilgisi getir |
| `POST` | `/api/getinfo/async` | Asenkron job oluştur |
| `GET` | `/api/jobs/:jobId` | Job durumu sorgula |
## Socket.IO Events
| Event | Yön | Açıklama |
|-------|-----|----------|
| `job:subscribe` | Client → Server | Job'a abone ol |
| `job:progress` | Server → Client | İlerleme güncellemesi |
| `job:completed` | Server → Client | İşlem tamamlandı |
| `job:error` | Server → Client | Hata oluştu |
## Environment Değişkenleri
| Değişken | Açıklama | Varsayılan |
|----------|----------|------------|
| `PORT` | Sunucu portu | `3000` |
| `NODE_ENV` | Ortam | `development` |
| `POSTGRES_*` | PostgreSQL ayarları | - |
| `REDIS_*` | Redis ayarları | - |
| `REDIS_TTL_SECONDS` | Cache süresi | `604800` (7 gün) |
| `RATE_LIMIT_*` | Rate limit ayarları | - |
| `API_KEY_*` | API anahtarları | - |
## Migration
Migration'lar otomatik olarak container başlatılırken çalışır.
```bash
# Manuel migration
docker compose exec app npx prisma migrate deploy
```
## Teknoloji Yığını
| Katman | Teknoloji |
|--------|-----------|
| Runtime | Node.js 20+ |
| Framework | Express.js |
| Database | PostgreSQL 16 |
| Cache | Redis 7 |
| Real-time | Socket.IO 4 |
| Scraper | Cheerio |
| ORM | Prisma |
## Proje Yapısı
```
.
├── src/
│ ├── config/ # Yapılandırma (env, database, redis, socket)
│ ├── middleware/ # Express middleware (auth, rate-limit, validation)
│ ├── routes/ # API rotaları
│ ├── services/ # İş mantığı (scraper, cache, content, job)
│ ├── types/ # TypeScript tipleri
│ └── utils/ # Yardımcı fonksiyonlar
├── prisma/
│ ├── schema.prisma # Veritabanı şeması
│ └── seed.ts # Başlangıç verileri
├── doc/
│ ├── overview.md # Proje özeti
│ ├── api.md # API dokümantasyonu
│ ├── ops.md # Operasyon notları
│ └── socket-events.md # Socket.IO events
├── docker-compose.dev.yml
├── docker-compose.yml
├── Dockerfile
└── package.json
```
## Dokümantasyon
- **Proje Özeti**: [`doc/overview.md`](doc/overview.md)
- **API Dokümantasyonu**: [`doc/api.md`](doc/api.md)
- **Operasyon**: [`doc/ops.md`](doc/ops.md)
- **Socket Events**: [`doc/socket-events.md`](doc/socket-events.md)
## Geliştirme
### Local Development
```bash
# Bağımlılıkları yükle
npm install
# Prisma client oluştur
npx prisma generate
# Development modda çalıştır
npm run dev
```
### Production Build
```bash
npm run build
npm start
```
## Güvenlik
- **API Key Authentication**: Tüm istekler API key gerektirir
- **Rate Limiting**: Dakikada max 30 istek (yapılandırılabilir)
- **Non-root Container**: Production container'ları root olmayan kullanıcı ile çalışır
- **Input Validation**: Tüm girdiler Zod ile doğrulanır
## Lisans
MIT