tool-traffic-tools (cấu hình qua DB_MONGO_DATABASE).| Collection | Model Class | Mô tả |
|---|---|---|
task_groups | TaskGroup | Nhóm tác vụ traffic, mỗi group chứa nhiều tasks |
tasks | Task | Tác vụ traffic riêng lẻ (embedded trong task_groups) |
proxies | Proxy | Proxy records trong vòng đời rotation |
search | Search | Tác vụ quét thứ hạng từ khóa |
report_tasks | ReportTask | Tác vụ báo cáo bảo mật |
^8.12.1: ODM chính, quản lý connection và queries.^12.13.0: Decorator-based schema definition trên TypeScript classes.@modelOptions: Cấu hình collection name, timestamps, allowMixed.@prop: Định nghĩa từng field với type, default, required, enum.TimeStamps: Base class tự động thêm createdAt và updatedAt.PROCESSING được reset về PENDING để retry.| Field | Type | Required | Default | Mô tả |
|---|---|---|---|---|
_id | string | auto | ObjectId hex | ID duy nhất, tự sinh từ ObjectId |
proxy_webhook | string | yes | — | URL để lấy proxy cho task group này |
status | number | no | 0 (PENDING) | Trạng thái: 0=PENDING, 1=PROCESSING, 2=COMPLETED |
proxy | object | no | null | Proxy đang dùng: {host, port, username?, password?, type?} |
proxy_id | string | no | null | ID của proxy record |
user_agent | string | no | null | User agent string của phiên Chrome |
geolocation | object | no | null | Vị trí địa lý: {lat, lng} |
tasks | Task[] | yes | — | Mảng các Task objects (embedded) |
retries_total | number | no | 0 | Số lần đã retry |
createdAt | Date | auto | — | Thời điểm tạo |
updatedAt | Date | auto | — | Thời điểm cập nhật cuối |
{
"_id": "507f1f77bcf86cd799439011",
"proxy_webhook": "https://traffic-api.longtu.club/webhook/proxy/get-proxy",
"status": 0,
"proxy": null,
"proxy_id": null,
"user_agent": null,
"geolocation": null,
"tasks": [
{
"_id": "507f1f77bcf86cd799439012",
"id": "task-abc-123",
"project_id": 42,
"traffic_type": {
"method": 1,
"only_ads": true,
"is_kill": false,
"organic_engine": 0,
"search_keyword": "mua laptop gaming",
"links": ["https://example.com"]
},
"traffic_device": 0,
"result_status": 0
}
],
"retries_total": 0,
"createdAt": "2026-03-26T09:00:00.000Z",
"updatedAt": "2026-03-26T09:00:00.000Z"
}_id.taskRequestService.requestAndCreateTaskGroups() nhận tasks từ Go API.PENDING → PROCESSING khi cron bắt đầu thực thi.PROCESSING → COMPLETED khi task hoàn thành.task-group-cleanup-cron lúc 00:30 hàng ngày (xóa tasks tạo trước 00:00 hôm nay).retries_total > TASK_RETRY_LIMIT.Task là model embedded trong TaskGroup.tasks[]. Mỗi task đại diện cho một hành động cụ thể trên một thiết bị cụ thể. Một task group thường chứa nhiều tasks cho các nền tảng khác nhau (Windows, Mac, Android, iOS).| Field | Type | Required | Default | Mô tả |
|---|---|---|---|---|
_id | string | auto | ObjectId hex | ID duy nhất |
id | string | yes | — | ID từ Go API Backend |
project_id | number | yes | — | ID của project/chiến dịch |
proxy_url | string | yes | — | URL để lấy proxy riêng cho task này |
webhook_url | string | yes | — | URL để gửi kết quả về Go API |
call_webhook_count | number | no | 0 | Số lần đã gọi webhook |
page_view | object[] | no | — | Cấu hình thời gian ở lại trang: [{time_min, time_max}] |
traffic_type | object | yes | — | Cấu hình loại traffic (xem chi tiết bên dưới) |
traffic_device | number | yes | — | Loại thiết bị: 0=Desktop, 1=Mobile |
device_os | number | no | null | OS: Desktop(0=Windows, 1=Mac), Mobile(0=Android, 1=iOS) |
result_status | number | no | 0 | Kết quả: 0=UNKNOWN, 1=SUCCESS, -1=ERROR, -2=NOT_FOUND, -3=CAPTCHA |
result_error | string | no | null | Thông báo lỗi nếu thất bại |
ip_public | string | no | null | IP public đã dùng |
rank | number | no | null | Thứ hạng tìm thấy trong SERP |
execution_time | number | no | 0 | Thời gian thực thi (giây) |
user_agent | string | no | null | User agent đã dùng |
geolocation | object | no | null | Vị trí địa lý: {lat, lng} |
ads_relations | object[] | no | [] | Ads relations cho click tracking |
resolved_projects | object[] | no | null | Projects đã resolve |
screenshot_url | string | no | null | URL ảnh bằng chứng trên cloud |
screenshot_key | string | no | null | Storage key của ảnh |
profile_id | string | no | null | ID của browser profile đã dùng |
retry_count | number | no | 0 | Số lần đã retry task này |
| Điều kiện | Flow |
|---|---|
method=0 | Home Traffic Flow (Direct) |
method=1, only_ads=false, is_kill=false | Search Flow (Organic) |
method=1, only_ads=true | Ads Flow (Google Ads click) |
method=1, is_kill=true | Kill Flow (Negative SEO) |
organic_engine=2, only_ads=false, is_kill=false | CocCoc Flow |
| Field | Type | Required | Default | Mô tả |
|---|---|---|---|---|
_id | string | auto | ObjectId hex | ID duy nhất |
ip | string | yes | — | IP address của proxy |
port | number | yes | — | Port kết nối |
username | string | yes | — | Username xác thực |
password | string | yes | — | Password xác thực |
ip_public | string | yes | — | IP public sau khi rotate |
rotate_url | string | yes | — | URL để gọi khi cần rotate (lấy IP mới) |
webhook_url | string | yes | — | URL để callback khi proxy sẵn sàng |
auth_token | string | no | null | Bearer token cho rotate_url |
status | number | no | 0 (PENDING) | 0=PENDING, 1=PROCESSING, 2=COMPLETED |
status_code | number | no | undefined | HTTP status code từ rotate response |
response | string | no | undefined | Response body từ rotate (khi lỗi) |
is_error | boolean | no | false | Có lỗi trong lần rotate gần nhất |
is_success | boolean | no | false | Rotation thành công |
is_captcha | boolean | no | false | Proxy bị CAPTCHA |
is_active | boolean | no | true | Proxy đang active |
in_use | number | no | 0 | Số tasks đang dùng proxy này |
error_count | number | no | 0 | Tổng số lần lỗi |
used_count | number | no | 0 | Tổng số lần đã dùng |
last_used_at | Date | no | null | Lần cuối được dùng |
expired_at | Date | no | null | Thời điểm hết hạn |
area | string | no | "" | Khu vực địa lý |
package_name | string | no | "" | Tên gói proxy |
proxy_price | number | no | 0 | Giá proxy |
domain_used | any[] | no | null | Danh sách domains đã dùng |
domain_blocks | string[] | no | [] | Danh sách domains bị block |
region | string | no | "" | Region của proxy |
call_webhook_count | number | no | 0 | Số lần đã gọi webhook |
retry_count | number | no | 0 | Số lần rotation thất bại |
disable_auto_rotate | boolean | no | false | Tắt auto rotation |
created_at | Date | auto | — | Thời điểm tạo |
updated_at | Date | auto | — | Thời điểm cập nhật |
Go API tạo record (PENDING)
→ proxy-cron-direct rotate proxy (PENDING → COMPLETED)
→ proxy-cron-webhook-direct gọi webhook_url
→ Xóa record sau khi webhook thành côngcall_webhook_count tăng. Sau 3 lần thất bại, record bị xóa.retry_count tăng. Sau PROXY_RETRY_LIMIT lần, record bị xóa.{
"_id": "507f1f77bcf86cd799439020",
"ip": "1.2.3.4",
"port": 8080,
"username": "user123",
"password": "pass456",
"ip_public": "5.6.7.8",
"rotate_url": "https://proxy-provider.com/rotate/abc123",
"webhook_url": "https://traffic-api.longtu.club/webhook/proxy/callback",
"auth_token": null,
"status": 2,
"is_error": false,
"is_success": true,
"retry_count": 0,
"call_webhook_count": 0,
"disable_auto_rotate": false,
"region": "VN",
"created_at": "2026-03-26T09:00:00.000Z",
"updated_at": "2026-03-26T09:00:05.000Z"
}| Field | Type | Required | Default | Mô tả |
|---|---|---|---|---|
_id | string | auto | ObjectId hex | ID duy nhất |
keyword | string | yes | — | Từ khóa cần tìm kiếm |
device | number | yes | — | Loại thiết bị: 0=Desktop, 1=Mobile |
device_os | number | no | null | OS của thiết bị |
result_num | number | yes | — | Số kết quả cần lấy |
web_hook_url | string | yes | — | URL để gửi kết quả về Go API |
web_hook_sent | number | no | 0 | Số lần đã gửi webhook |
proxy_url | string | yes | — | URL để lấy proxy |
engine | number | yes | — | Search engine: 0=GOOGLE_VN, 1=GOOGLE, 2=COCCOC |
status | number | no | 0 (PENDING) | 0=PENDING, 1=RUNNING, 2=COMPLETED |
search_data | object | no | null | Kết quả tìm kiếm (xem bên dưới) |
proxy | any | no | null | Proxy đang dùng |
geolocation | object | no | null | Vị trí địa lý: {lat, lng} |
createdAt | Date | auto | — | Thời điểm tạo |
updatedAt | Date | auto | — | Thời điểm cập nhật |
{
"_id": "507f1f77bcf86cd799439030",
"keyword": "mua laptop gaming giá rẻ",
"device": 0,
"device_os": null,
"result_num": 10,
"web_hook_url": "https://traffic-api.longtu.club/webhook/keyword-result",
"web_hook_sent": 0,
"proxy_url": "https://traffic-api.longtu.club/webhook/proxy/get-proxy",
"engine": 0,
"status": 2,
"search_data": {
"ads": [
{ "url": "https://advertiser1.com", "rank": 1 },
{ "url": "https://advertiser2.com", "rank": 2 }
],
"search": [
{ "url": "https://organic1.com", "rank": 1 },
{ "url": "https://organic2.com", "rank": 2 },
{ "url": "https://organic3.com", "rank": 3 }
]
},
"proxy": { "host": "1.2.3.4", "port": 8080 },
"geolocation": { "lat": 10.7769, "lng": 106.7009 },
"createdAt": "2026-03-26T09:00:00.000Z",
"updatedAt": "2026-03-26T09:05:00.000Z"
}| Field | Type | Required | Default | Mô tả |
|---|---|---|---|---|
_id | string | auto | ObjectId hex | ID duy nhất |
domain | string | yes | — | Domain cần báo cáo |
keyword | string | yes | — | Từ khóa liên quan đến domain |
platform | string | yes | — | Tên nền tảng báo cáo (xem ReportPlatform enum) |
reportType | string | yes | — | "BROWSER_BASED" hoặc "EMAIL_BASED" |
platformUrl | string | no | null | URL của form báo cáo trên nền tảng |
status | string | yes | "PENDING" | Trạng thái (xem ReportTaskStatus) |
priority | number | no | 1 | Ưu tiên thực thi (cao hơn = ưu tiên hơn) |
reportDomainId | string | no | null | ID tham chiếu đến report domain trên Go API |
| Field | Type | Required | Default | Mô tả |
|---|---|---|---|---|
assignedAccountId | string | no | null | ID tài khoản được gán |
assignedProxyId | string | no | null | ID proxy được gán |
assignedProfileId | string | no | null | ID profile được gán |
proxyUrl | string | no | null | Webhook URL để lấy proxy |
profileUrl | string | no | null | Webhook URL để lấy profile |
profileCountry | string | no | "Vietnam" | Quốc gia của profile (dùng cho email origin) |
domainType | string | no | "normal" | Loại domain: "google_ads" hoặc "normal" |
| Field | Type | Required | Default | Mô tả |
|---|---|---|---|---|
reportDate | string | yes | — | Ngày báo cáo dạng YYYY-MM-DD |
uniqueKey | string | yes, unique | — | Composite key: domain+proxyId+profileId+reportDate+platform |
| Field | Type | Required | Default | Mô tả |
|---|---|---|---|---|
scheduledFor | Date | yes | — | Thời điểm dự kiến thực thi |
retryCount | number | no | 0 | Số lần đã retry |
maxRetries | number | no | 3 | Số lần retry tối đa |
startedAt | Date | no | null | Thời điểm bắt đầu thực thi |
completedAt | Date | no | null | Thời điểm hoàn thành |
executionTime | number | no | null | Thời gian thực thi (ms) |
| Field | Type | Required | Default | Mô tả |
|---|---|---|---|---|
result | object | no | null | Kết quả chi tiết (xem ReportTaskResult) |
error | string | no | null | Thông báo lỗi nếu thất bại |
| Field | Type | Required | Default | Mô tả |
|---|---|---|---|---|
proxySnapshot | object | no | null | Snapshot trạng thái proxy tại thời điểm tạo |
useProxySnapshot | boolean | no | true | Dùng snapshot thay vì live proxy |
fallbackProxyId | string | no | null | Proxy dự phòng nếu proxy chính thất bại |
| Field | Type | Required | Default | Mô tả |
|---|---|---|---|---|
callbackSent | boolean | no | false | Đã gửi callback về Go API chưa |
callbackSentAt | Date | no | null | Thời điểm gửi callback |
callbackResponse | string | no | null | Response từ Go API khi callback |
callbackRetryCount | number | no | 0 | Số lần retry callback |
webhook_url | string | no | null | URL để gửi callback khi hoàn thành |
apiTaskId | string | no | null | Task ID gốc từ Go API |
| Field | Type | Required | Default | Mô tả |
|---|---|---|---|---|
server | string | no | null | Server IP thực thi task |
gptRawPrompt | string | no | null | Raw GPT prompt response để debug |
imageUrls | string[] | no | [] | Image URLs từ domain |
videoUrls | string[] | no | [] | Video URLs từ domain |
platformType | string | no | null | Loại platform: "browser" hoặc "email" |
uniqueKey có constraint unique: true. Composite key được tạo từ:{domain}_{proxyId}_{profileId}_{reportDate}_{platform}{
"_id": "507f1f77bcf86cd799439040",
"domain": "malicious-domain.com",
"keyword": "mua hàng online",
"platform": "GOOGLE_SAFE_BROWSING",
"reportType": "BROWSER_BASED",
"platformUrl": "https://safebrowsing.google.com/safebrowsing/report_phish/",
"status": "COMPLETED",
"priority": 1,
"reportDate": "2026-03-26",
"uniqueKey": "malicious-domain.com_proxy123_profile456_2026-03-26_GOOGLE_SAFE_BROWSING",
"scheduledFor": "2026-03-26T09:00:00.000Z",
"retryCount": 0,
"maxRetries": 3,
"startedAt": "2026-03-26T09:00:00.000Z",
"completedAt": "2026-03-26T09:02:30.000Z",
"executionTime": 150000,
"result": {
"success": true,
"message": "Report submitted successfully to GOOGLE_SAFE_BROWSING",
"platform": "GOOGLE_SAFE_BROWSING",
"reportType": "BROWSER_BASED",
"submittedAt": "2026-03-26T09:02:25.000Z",
"url": "https://safebrowsing.google.com/safebrowsing/report_phish/",
"screenshotUrl": "https://tools-greeting1073.sgp1.cdn.digitaloceanspaces.com/screenshots/abc123.png",
"aiMetadata": {
"model": "gpt-4o-mini",
"promptTokens": 450,
"completionTokens": 280,
"totalTokens": 730,
"estimatedCost": 0.000146,
"generatedAt": "2026-03-26T09:00:05.000Z"
}
},
"callbackSent": true,
"callbackSentAt": "2026-03-26T09:02:35.000Z",
"server": "77.37.47.88",
"createdAt": "2026-03-26T08:59:00.000Z",
"updatedAt": "2026-03-26T09:02:35.000Z"
}| Enum Value | Mô tả |
|---|---|
SPAMHAUS | Báo cáo spam infrastructure và malware hosting |
GOOGLE_SAFE_BROWSING | Báo cáo phishing và malware đến Google |
MOZILLA_FIREFOX | Báo cáo đến Mozilla Firefox |
MOZILLA_WEBCOMPAT | Báo cáo website không tương thích Firefox |
ADGUARD | Báo cáo quảng cáo độc hại đến AdGuard |
GOOGLE_ADS | Báo cáo vi phạm chính sách Google Ads |
GOOGLE_ADS_THIRDPARTY | Báo cáo quảng cáo bên thứ ba vi phạm |
GOOGLE_LEGAL_TROUBLESHOOTER | Báo cáo vi phạm pháp lý qua troubleshooter |
GOOGLE_LEGAL_SPECIFIC | Báo cáo vi phạm pháp lý cụ thể |
GOOGLE_LEGAL_CATEGORY2 | Báo cáo vi phạm pháp lý danh mục 2 |
CLOUDFLARE | Báo cáo lạm dụng dịch vụ Cloudflare |
GOOGLE_PLAY | Báo cáo ứng dụng vi phạm Google Play |
US_CERT | Báo cáo đến US-CERT |
ESET | Báo cáo malware đến ESET |
MICROSOFT_SMARTSCREEN | Báo cáo website nguy hiểm cho SmartScreen |
MICROSOFT | Báo cáo đến Microsoft Security |
NETCRAFT | Báo cáo phishing đến Netcraft |
FORTINET | Báo cáo đến Fortinet |
CISA | Báo cáo đến CISA (US Cybersecurity Agency) |
NCSC | Báo cáo đến NCSC (UK National Cyber Security Centre) |
| Enum Value | Địa chỉ email |
|---|---|
GOOGLE_EMAIL | Địa chỉ abuse chung của Google |
GOOGLE_CLOUD_COMPLIANCE_EMAIL | Google Cloud compliance |
GOOGLE_SPAM_GMAIL_EMAIL | Báo cáo spam Gmail |
GOOGLE_ADS_ABUSE_EMAIL | Google Ads abuse |
GOOGLE_ADS_NOREPLY_EMAIL | Google Ads noreply |
GOOGLE_PLAY_ABUSE_EMAIL | Google Play abuse |
GOOGLE_YOUTUBE_ABUSE_EMAIL | YouTube abuse |
GOOGLE_GMAIL_ABUSE_EMAIL | Gmail abuse |
| Enum Value | Tổ chức |
|---|---|
VIETTEL_VTI_SUPPORT | Viettel VTI Support |
VIETTEL_CSKH | Viettel CSKH |
VNPT_HOTRO | VNPT Hỗ trợ |
VNPT_CSKH | VNPT CSKH |
FPT_HOTROKHACHHANG | FPT Hỗ trợ khách hàng |
FPT_SECURITY | FPT Security |
MOBIFONE_KHACHHANG | Mobifone Khách hàng |
CMCTELECOM_INFO | CMC Telecom |
MPS_TIEPNHANTOGIACTOIPHAM | Bộ Công an - Tiếp nhận tố giác tội phạm |
CHINHPHU_DICHVUCONG | Chính phủ - Dịch vụ công |
THANHTRA_CUCCHONGTHAMNHUNG | Thanh tra - Cục chống tham nhũng |
MPS_A05_CONTACT | Bộ Công an A05 |
AIS_NCSC | AIS NCSC |
MIC_AIS | Bộ TT&TT AIS |
VNCERT_IR | VNCERT Incident Response |
| Enum Value | Tổ chức |
|---|---|
THAICERT_REPORT | ThaiCERT |
AUSCERT_REPORT | AusCERT (Australia) |
SPAMHAUS_REPORT | Spamhaus |
CERT_IN_REPORT | CERT-In (India) |
CERT_EU_REPORT | CERT-EU |
SINGCERT_REPORT | SingCERT (Singapore) |
JPCERT_REPORT | JPCERT (Japan) |
OPENDNS_REPORT | OpenDNS |
MYCERT_REPORT | MyCERT (Malaysia) |
tasks là embedded array trong task_groups. Không có collection riêng cho tasks — chúng luôn tồn tại trong context của task group.proxy_webhook URL:task_groups.proxy_webhook là URL để lấy proxy.proxies.task_groups.proxy._id cho tất cả collections.report_tasks có unique index trên uniqueKey:allowMixed: Severity.ALLOW. Điều này cho phép Mongoose lưu mixed types trong schema mà không báo lỗi. Cần thiết vì một số fields như proxy, search_data, result có cấu trúc động.required và unique constraints.proxies dùng custom timestamp names:createdAt và updatedAt.string cho _id thay vì MongoDB ObjectId:toHexString() convert ObjectId thành 24-character hex string. Điều này giúp dễ dàng serialize/deserialize qua JSON mà không cần special handling.