Hệ thống gồm 4 thành phần chính + hạ tầng hỗ trợ:
┌──────────────────────┐ ┌───────────────────────────────┐
│ React 18 + TS │ │ FastAPI (3-layer) │
│ Tailwind + shadcn │────▶│ endpoints → services → repos │
│ MapLibre + OSM │ │ + Prisma (payments module) │
└──────────────────────┘ └──────────────┬────────────────┘
│
┌───────────────────────┼───────────────────────┐
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ PostgreSQL │ │ Redis / file │ │ FAISS index │
│ (catalog, │ │ cache (bền │ │ (MiniLM + │
│ orders, │ │ vững qua │ │ CLIP embed- │
│ logistics) │ │ restart) │ │ dings) │
└──────────────┘ └──────────────┘ └──────────────┘
thanglequoc/vietnamese-provinces-database v4.2) → 4 Kho tổng (Hà Nội, Đà Nẵng, TP.HCM, Cần Thơ).tracking_event kèm tọa độ; chế độ demo tăng tốc.sources → nhãn giải thích “Vì sao gợi ý”.all-MiniLM-L6-v2 + FAISS; hybrid score = 0.6×vector + exact-match boost + rating.scraper/ (Playwright, amazon.com, USD cookie + VND fallback, identity rotation)
→ ModelApp/implementation/pre_processing.py → Data/Amazon-Products_processed_03.csv
→ generate_users.py (2000 user VN, ratings tương quan sở thích)
→ association_rules.py (Apriori, 64k rules)
→ generate_reviews.py (66k reviews theo bucket sao — tín hiệu sentiment)
→ Backend/scripts/database/import_new_data.py (auto-backup → PostgreSQL)
→ scripts/ml/embed_products.py (FAISS index)
| Vấn đề | Giải pháp |
|---|---|
| Cache gợi ý mất khi restart | CacheService: Redis hoặc file-persistence (append-only dump + load-on-init) |
| Interest/Trending là dead code | Expose 2 endpoint mới + derive interests từ rating history |
| 17 endpoint admin không có auth | verify_admin_user trên toàn bộ /admin/* |
| Sản phẩm mới làm TF-IDF re-fit chậm | FAISS index build offline; runtime chỉ encode query (~50ms) |