mirror of
https://github.com/nethunterzist/trendyol-analiz
synced 2026-07-01 09:27:03 +00:00
Ne yaptık:
- data_consolidator.py: Tüm normalizasyon ve hesaplama mantığını main.py'den çıkardık
- Dashboard endpoint 1150 satırdan 25 satıra düştü (main.py -1730/+1880 net)
- Enrichment bitince otomatik konsolide dosya oluşturuluyor (report_{id}_data.json)
- Eski raporlar ilk dashboard isteğinde lazy migration ile konsolide ediliyor
- Trendyol API artık order-count döndürmediği için baskets fallback eklendi
- Inline socialProofs (scrape) > enrichment API öncelik sırası uygulandı
- Frontend KPI başlıkları orders/baskets durumuna göre dinamik değişiyor
- logging_config.py, category_seeder.py, alembic migration eklendi
- Playwright ile 9 tab test edildi, tüm veriler doğru
Neden yaptık:
- 3 farklı kaynaktan her istekte birleştirme yapılması veri tutarsızlığına ve yavaşlığa yol açıyordu
- Tek konsolide JSON dosyası ile dashboard anında yükleniyor
- Trendyol API değişikliği nedeniyle sipariş verisi kayboluyordu, baskets fallback ile çözüldü
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
58 lines
1.6 KiB
Docker
58 lines
1.6 KiB
Docker
FROM python:3.11-slim
|
|
|
|
# Metadata
|
|
LABEL maintainer="Trendyol Product Dashboard"
|
|
LABEL description="FastAPI backend for Trendyol product analytics"
|
|
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies
|
|
# - libpq-dev: PostgreSQL client library for psycopg2
|
|
# - curl: Health check and debugging
|
|
RUN apt-get update && apt-get install -y \
|
|
libpq-dev \
|
|
curl \
|
|
gosu \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements first (Docker layer caching)
|
|
# Build context is repo root, so path is backend/
|
|
COPY backend/requirements.txt .
|
|
|
|
# Install Python dependencies
|
|
RUN pip install --no-cache-dir --upgrade pip && \
|
|
pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code from backend/
|
|
COPY backend/ .
|
|
|
|
# Copy categories data (bundled into image for Coolify deployment)
|
|
COPY categories/ /data/initial-categories/
|
|
|
|
# Create data directories with proper permissions
|
|
RUN mkdir -p /data/categories /data/reports /data/logs && \
|
|
chmod -R 755 /data
|
|
|
|
# Make startup script executable (before switching to non-root user)
|
|
RUN chmod +x startup.sh
|
|
|
|
# Create non-root user for security
|
|
RUN useradd -m -u 1001 appuser && \
|
|
chown -R appuser:appuser /app /data
|
|
|
|
# Expose backend port
|
|
EXPOSE 8001
|
|
|
|
# Health check configuration
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=5 \
|
|
CMD curl -f http://localhost:8001/health || exit 1
|
|
|
|
# Environment variables (can be overridden at runtime)
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
DATABASE_URL=postgresql://postgres:trendyol123@postgres:5432/trendyol_db \
|
|
CATEGORIES_DIR=/data/categories \
|
|
REPORTS_DIR=/data/reports
|
|
|
|
# Start with migration script
|
|
CMD ["./startup.sh"]
|