2.4 KiB
2.4 KiB
Thông số kỹ thuật
File: Zee.md
Function:
Description:
Logic:
Input:
Output:
Error Handling:
Preconditions:
Postconditions:
Internal Dependencies:
Core Technologies
- Backend: Go
- Database: PostgreSQL
- Frontend: HTMX
- Containerization: Docker
- Cloud Hosting: VPS Storage
1. Yêu cầu hệ thống
- Quy mô dự kiến: 20,000+ người tham gia, 5,000 lượt matching
- Hiệu suất: Xử lý đồng thời 100+ request/s
- Độ trễ API: <500ms cho 95% request
- Thời gian matching: <5 phút sau khi đăng ký
2. API Endpoints
Public APIs
GET /campaign/config- Lấy cấu hình campaignPOST /profiles- Đăng ký profile mớiPOST /photos/upload- Upload ảnhPOST /results/access- Truy cập kết quả bằng access codeGET /results/{token}- Xem kết quả matchingPOST /results/select- Chọn matchPOST /results/decline- Từ chối match
Admin APIs
POST /admin/auth/login- Đăng nhập adminGET /admin/reports/summary- Báo cáo tổng quanGET /admin/campaign/status- Trạng thái campaignPOST /admin/campaign/actions/{action}- Thực hiện action campaignGET/POST/PUT/DELETE /admin/gifts- Quản lý quà tặngGET /admin/giveaway/allocations- Danh sách phân bổ quàPOST /admin/giveaway/actions/run-draw- Chạy quay thưởng
3. Transaction Workflows
- UserRegistrationTransaction: Đăng ký → Tạo Profile → Gửi email xác nhận
- MatchingTransaction: Chạy matching → Tạo MatchOutcome
- ResultNotificationTransaction: Gửi thông báo kết quả
- MatchSelectionTransaction: Xử lý lựa chọn/từ chối
- GiftAllocationTransaction: Quay thưởng → Tạo GiftAllocation
- GiftNotificationTransaction: Gửi thông báo trúng thưởng
Error Handling Specification
Error Types:
- UserInputError: Lỗi dữ liệu đầu vào (HTTP 400)
- NotFoundError: Tài nguyên không tồn tại (HTTP 404)
- UnauthorizedError: Truy cập không được phép (HTTP 401)
- InternalServerError: Lỗi hệ thống (HTTP 500)
Logging Requirements:
- Tất cả lỗi phải được ghi lại với context đầy đủ
- Sử dụng structured logging với zap
Overall Flow:
sequenceDiagram