Backend cho ứng dụng trust/freshness review giữa người bán và người mua.
Người bán chụp ảnh hàng đang bán, AI chấm điểm chất lượng, rồi tạo cam kết.
Người mua chụp ảnh tại quầy để kiểm tra chất lượng hiện tại và so sánh với cam kết đó.
Hệ thống lưu audit trail, proof, image CID, và integrity anchor để tăng tính minh bạch.
Seller: chụp ảnh, nhận AI score, xác nhận cam kết chất lượngBuyer: chụp ảnh, kiểm tra độ tươi/chất lượng hiện tạiSystem: so sánh kết quả hiện tại với cam kết, lưu proof và history
Go: API, worker, business logicMongoDB: backend lưu trữ duy nhấtVault: lưu private key accountBesu QBFT: anchor integrity hashKubo IPFS: lưu image CIDOpenAI Vision: chấm điểm ảnh
- auth email/password + Google
- shop, product, review, freshness report
- seller score + seller commit
- buyer check + proof view
- signed event log + verify API
- trust score cho shop/seller
- Besu integrity anchoring
- asynchronous Besu anchoring with RPC failover and retry backoff
- IPFS image CID flow
- lọc cửa hàng theo bán kính (
lat/lng/radiusKm), trả kèmdistanceKm - lịch sử thay đổi sản phẩm + chuỗi giá 30 ngày, dựng từ event log đã ký
- Tạo
.env
cp .env.example .env- Điền
JWT_SECRETvàOPENAI_API_KEY
MongoDB là backend duy nhất; thiếu nó Server dừng ngay lúc khởi động:
MONGODB_ENABLED=true
MONGODB_URI=mongodb://127.0.0.1:27017
MONGODB_DATABASE=vngrocery- Chạy stack local
./scripts/vng upAPI nằm ở cổng 5050 của máy host (cổng 5000 bị AirPlay Receiver của macOS
chiếm sẵn). Đổi bằng API_PORT trong .env nếu cần.
-
Nếu Vault chưa init/unseal, làm theo hướng dẫn script in ra
-
Deploy contract Besu
./scripts/deploy-integrity.sh- Cập nhật
.envvớiVAULT_TOKENvàBESU_CONTRACT_ADDRESS, rồi chạy lại:
./scripts/vng up- Test flow:
./test.sh
IMAGE_PATH=/abs/path/to/image.jpg ./scripts/e2e-mobile-flow.shMobile cấu hình Server bằng --dart-define=API_BASE_URL=<server-url>; mặc định là http://10.0.2.2:5050. Các route tích hợp bổ sung gồm GET /v1/me/shop, GET /v1/seller/shops/:shopId/products, GET /v1/shops/:shopId/products/:productId/history, /v1/vouchers/check và /v1/me/vouchers. Contract đầy đủ có tại /docs và /openapi.json khi Server đang chạy.
- setup từ đầu: docs/setup/00-start-here.md
- triển khai một máy, từng bước: docs/HUONG-DAN-TRIEN-KHAI.md
- vận hành: docs/operations.md
- mobile API handoff: docs/mobile-api-playbook.md
make help
./scripts/vng --prod vault-init
./scripts/vng chain-up
make ipfs-up
./scripts/vng up
./scripts/vng seed
./scripts/vng seed-history
./scripts/vng health
make logs service=api
make clean
make clean-all- Nếu backend chạy trong Docker Compose, dùng tên service như
vault,ipfs,besu-validator1 - Nếu backend chạy trên host, dùng
127.0.0.1 - Nếu blockchain ở server khác, dùng private IP hoặc domain nội bộ của RPC endpoint