Streamlit dashboard วิเคราะห์ข้อมูลยอดขาย/ซื้อ/สต็อกจาก PEAK Account ของ Smart Solution Computer พร้อมรายงานผ่าน Telegram; ถอดแชต AI บนเว็บแล้ว
72.62.79.218 → /opt/peak-dashboard)~/Desktop/Claude Code/peak-dashboard/./deploy.sh (หรือ ./deploy.sh --creds-only เมื่อ token หมด)┌─────────────────────────────────────────────────────────────┐
│ Mac (local) │
│ └─ push_token_mac.sh (ดึง token ใหม่ จาก Chrome cookies) │
│ └─ rsync → VPS /opt/peak-dashboard/data/ │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ VPS — Docker Container (peak-dashboard) │
│ │
│ ├─ cron │
│ │ ├─ 03:00 UTC daily_fetch.py → build_features.py │
│ │ └─ 07:00 UTC daily_fetch.py → build_features.py (retry)│
│ │ │
│ ├─ daily_fetch.py → pull sale/purchase/inventory API │
│ │ → master_*.parquet │
│ │ │
│ ├─ build_features.py → pre-compute feature store │
│ │ → ai_customer_360.parquet │
│ │ → ai_product_360.parquet │
│ │ → ai_daily_kpi.parquet │
│ │ → ai_brand_metrics.parquet │
│ │ → ai_schema.json │
│ │ │
│ ├─ FastAPI (:8000) → REST endpoints │
│ └─ Streamlit (:8501) → Dashboard + AI Chat │
│ └─ ai_chat.py → OpenRouter (Claude Haiku 4.5) │
│ └─ ai_tools.py (15 tools, fast-path via FS) │
└─────────────────────────────────────────────────────────────┘
| File | หน้าที่ |
|---|---|
app.py |
Streamlit main dashboard |
api.py |
FastAPI endpoints |
daily_fetch.py |
ดึงข้อมูลจาก PEAK API → master_*.parquet |
build_features.py |
Pre-compute feature store (ai_*.parquet) |
fetch_ar.py |
ดึง AR (ลูกหนี้คงค้าง) → master_ar.parquet — ExportInvoice + financeType=1 + tableStatus=3 |
ai_chat.py |
Orchestrator — OpenRouter + tool-calling loop |
ai_tools.py |
15 tools + fast-path feature store |
shared_utils.py |
Loaders, brand detection, classification, payment score |
token_refresher.py |
PEAK token management |
Dockerfile |
Python 3.11 + Playwright + Thai fonts |
entrypoint.sh |
cron + FastAPI + Streamlit boot |
crontab.txt |
daily_fetch + build_features schedule |
deploy.sh |
rsync + docker compose build + health check |
🎯 Phase 2 — Strategic Insights (2026-04-28 eve):
get_customer_profitability — ranking by est. profit (× brand-margin), ไม่ใช่ revenueget_channel_profitability — Net contribution per channel หลังหักต้นทุนช่องทางget_vendor_risk — HHI concentration index + risk levelget_forecast — seasonal projection (จาก 5+ ปีข้อมูล)🎨 Phase 2 Pages (premium dark theme):
12_🎯_Customer_Profit.py — Revenue vs Profit bubble + rank-shift table