1. Business | Logic
Domain Tool
  • Tổng quan
  • Business | Logic
    • Admin Business Logic
    • Worker & Automation Business
    • Integration & Reliability Business
    • API INTERFACE & TASK MANAGEMENT
    • SYSTEM BUSINESS OVERVIEW
  • Project
    • ADMIN
      • Tổng quan
      • Architecture
        • Database Schema
        • System Architecture
        • Code Structure
      • Deployment
        • Local
        • Staging
        • Product
      • Hướng dẫn sử dụng
        • Tổng quan
        • Đăng nhập
        • Kiểm tra tự động
        • Kiểm tra thủ công
        • Xếp hạng thủ công
        • Xác nhận kiểm tra
        • Xếp hạng tự động
        • Quản lý từ khóa xếp hạng
        • Kiểm tra whitelist
        • Quản lý từ khóa
        • Truy vết tên miền
        • Quản lý volume từ khóa
        • Kiểm tra domain sở hữu
        • Lịch sử check domain
        • Kiểm tra và view source
        • Kiểm tra thương hiệu tên miền
        • Quản lý người dùng
        • Server
    • API
      • Tổng quan
      • Architecture
        • Database Schema
        • System Architecture
        • Code Structure
      • Deployment
        • Staging
        • Product
        • Local
      • API Interface
        • Public API
          • Xác thực
            • login
            • refresh token
          • Thông tin đăng nhập
            • get current user
            • changePasswordUser
          • Quản lý người dùng
            • getUserList
            • createUser
            • getUserItem
            • updateUser
            • deleteUser
            • updateActive
            • Update FCM Token
          • Quản lý từ khóa
            • Get list of Keywords
            • createKeyword
            • getKeywordItem
            • updateKeyword
            • deleteKeyword
            • deleteKeyword
            • totalKeywordBranchGroup
          • Quản lý Proxy
            • Get all Proxies
            • createProxy
            • getProxyItem
            • updateProxy
            • deleteProxy
            • getActiveProxyList
          • Branch
            • getBranchList
            • createBranch
            • getBranchItem
            • updateBranch
            • deleteBranch
          • Check Brand Domain Histories
            • Get list of Check Brand Domain Histories
            • export Check Brand Domain Histories Data
            • checkBrandDomainHistoriesCopy
            • Import data from Excel
            • exportSampleImportFile
          • Check Confirm
            • List Check Confirms
            • Create Check Confirm
            • Bulk create Check Confirms
            • Show Check Confirm
            • Approve or update confirm detail
            • Delete Check Confirm
            • Approve Check Confirm
            • Approve or Reject Check Confirm
            • List approvers
          • Check Owned Domain
            • Check owned domain
          • Check View Source
            • List current user's check view source histories
            • Check view source for domains
            • Delete all histories of current user
          • Tên Miền Công Ty
            • Get a list of company domains
            • Create a new company domain
            • Get a specific company domain
            • Update a specific company domain with tags
            • Delete a specific company domain
            • Import Whitelist Domains from Excel
            • deleteBulkWhitelistDomain
            • Delete company domains by tag ID
          • Xuất dữ liệu excel
            • Export company domains
            • autoCheckDomainRdrExport
            • exportExcelHistoryCheck
            • exportExcelHistoryRecord
            • autoCheckHistoryDomainRecordExport
            • AutoCheckHistoryDomainCheckExport
            • export Keyword Data
            • autoCheckKeywordExport
            • exportKeywordVolumes
            • exportTrackingDomain
            • exportExcelManualRankingKeywordHistory
            • exportExcelManualSessionHistoryCheck
            • exportExcelRankingDomainHistory
            • exportCompareProxies
            • export Ranking Keyword Data
            • autoCheckRankingKeywordExport
            • exportSampleImportFile
            • exportExcelRankingKeywordHistory
            • exportExcelRankingHistory
            • exportExcelDomainRankingHistory
            • exportExcelWhiteListDomainBlock
            • WhitelistBlockExportSampleImportFile
            • exportSampleImportFile
            • ExportWhitelistByTag
          • Copy
            • Copy company domains
            • autoCheckDomainRdrCopy
            • autoCheckHistoryDomainRecordCopy
            • autoCheckHistoryDomainCheckCopy
            • autoCheckKeywordCopy
            • copyKeywordVolumes
            • copyTrackingDomain
            • copyManualRankingKeywordHistory
            • copySessionHistory
            • copySessionHistory
            • manualUploadFileCopy
            • copyRankingDomainHistory
            • autoCheckRankingKeywordCopy
            • copyRankingKeywordHistory
            • copyRankingHistory
            • copyWhiteListDomainBlock
            • copyWhitelistByTag
          • Nhà cung cấp proxy
            • getDataUsageHistory
            • getProxyProviderList
            • createProxyProvider
            • getProxyProviderItem
            • updateProxyProvider
            • deleteProxyProvider
            • updateSortProxyProvider
            • getProviderProxyCombine
            • createProxyProvider
            • detailProviderProxyCombine
            • updateProxyProvider
            • deleteProviderProxyCombine
          • Quản lý Domain
            • getDomainList
            • createDomain
            • getDomainItem
            • updateDomain
            • deleteDomain
          • Chạy thủ công
            • Run Manual Domain
            • Run Manual Check Domain
            • Run Retry Record Domain
            • Run Retry check Domain
            • Run Manual Domain By Type
            • Run Manual Keyword
          • Domain Check Redirect
            • createDomainCheckRDR
            • getDomainCheckRDRItem
            • updateDomainCheckRDR
            • deleteDomainCheckRDR
            • createHistoryDomainCheck
            • updateHistoryDomainCheck
            • deleteHistoryDomainCheck
            • getListWebByKeyword
            • getListAppByKeyword
            • getListAdsByKeyword
            • getDomainCheckRDRList
          • Quản lý summary
            • Get Domain Wiki Statistics
            • Get Domain Wiki Details
            • Export Domain Wiki Data
            • Copy Domain Wiki List
            • Get Domain Wiki Chart Data
            • Get Summaries
            • Get Auto Summaries
            • Get ranking Summaries
          • External API
            • Create external record domain task
          • Flow
            • stop current flow search domain
            • start current flow search domain
            • get metric flow
            • Get domain RDR processing metrics
            • Get keyword processing metrics
            • Get status auto
          • Group
            • getGroupList
            • createGroup
            • getGroupItem
            • updateGroup
            • deleteGroup
          • Lấy lịch sử check domain
            • getHistoryDomainCheckList
            • getHistoryDomainRecordList
            • getHistoryDomainCheckItem
            • getHistoryDomainRecordItem
            • getHistoryDomainChart
            • getHistoryDomainRecordListV2
          • Ranking Keyword
            • setTimeToRunAutoKeyword
            • postRankingDomainHistory
            • compareProxiesDomainHistory
            • compareProxiesDomainHistoryCopy
            • getChartRankingDomainHistory
            • restartRankingDomainHistory
            • Get list of Ranking Keywords
            • createRankingKeyword
            • getRankingKeywordItem
            • updateRankingKeyword
            • deleteRankingKeyword
            • deleteRankingKeyword
            • totalRankingKeywordBranchGroup
            • Get keyword ranking metric
            • retryRankingKeyword
            • Update Order
            • Import data from Excel
            • Update Order by filter
            • deleteAllRankingKeyword
            • getRankingKeywordHistory
            • setTimeToRunAutoRanking
            • getTimeRunAutoRanking
            • Get ranking group list
          • Quản lý Keyword volume
            • 8ceaf215c302596b08d25b1e12e7ab45
            • Get maximum search volume
          • Quản lý Activities
            • getLogs
            • getLogs
            • trackingDomain
          • Manual Ranking Keyword
            • Get manual ranking keyword histories
            • Get manual ranking keyword history metric
            • GetJsonFileRanking
            • Get ranking group list
          • Quản lý Manual
            • Get list of Manual session domain
            • create manual session domain
            • Get Manual session domain
            • Update list manual session history by manual_sessions_id
            • deleteSession
            • Get list session history
            • Update manual session history by id
            • deleteSessionHistory
            • Get process of Process Manual session domain
            • Get session histories
            • Get statistics session history records
            • Get detailed session history records
            • Get Manual upload files
            • Create Manual upload files
            • Delete Manual upload files
            • deleteBulkManualUploadFiles
          • Ranking Branch
            • getRankingBranchList
            • createRankingBranch
            • getRankingBranchItem
            • updateRankingBranch
            • deleteRankingBranch
          • Ranking Group
            • getRankingGroupList
            • createRankingGroup
            • detailRankingGroup
            • updateRankingGroup
            • deleteRankingGroup
          • Reported Domains
            • getReportedDomainList
            • createReportedDomain
            • getReportedDomainItem
            • updateReportedDomain
            • deleteReportedDomain
            • deleteReportedDomain
            • deleteBulkReportedDomain
          • SearchEngine
            • getSearchEngineList
            • createSearchEngine
            • getSearchEngineItem
            • updateSearchEngine
            • deleteSearchEngine
          • Quản lý cụm Server
            • getServerList
            • createServer
            • getServerItem
            • updateServer
            • deleteServer
          • Statistics
            • getStatistics
          • Tag
            • getTagList
            • createTag
            • getTagItem
            • updateTag
            • deleteTag
            • deleteBulkTag
          • Webhook
            • Execute updateAfterRecordDomain action
            • Execute updateAfterRecordDomain action
            • Execute updateAfterRecordDomain action
            • Handle check confirm capture webhook
            • Execute updateAfterRecordDomain action
            • Execute externalRecordDomainSuccess action
            • Execute updateAfterRecordDomain action
            • Execute updateAfterRecordDomain action
            • Execute updateAfterCheckRankingDomain action
            • Execute updateDomainSearchRanking action
            • Execute updateDomainSearchRankingManual action
          • Quản lý whitelist domain block từ hệ thống
            • getWhiteListDomainBlockApiList
            • createWhiteListDomainBlockApi
            • getWhiteListDomainBlockApiItem
            • updateWhiteListDomainBlockApi
            • deleteWhiteListDomainBlockApi
            • deleteBulkWhiteListDomainBlockApi
          • Quản lý whitelist domain
            • getWhitelistDomainList
            • createWhitelistDomain
            • getWhitelistDomainList
            • getWhitelistDomainItem
            • updateWhitelistDomain
            • deleteWhitelistDomain
            • deleteWhitelistDomain
            • Import Whitelist Domains from Excel
            • deleteBulkWhitelistDomain
    • Tool Check
      • Tổng quan
      • Architecture
        • Database Schema
        • System Architecture
        • Code Structure
      • Deployment
        • Local
        • Staging
        • Product
      • API Interface
        • Public API
          • Public API
    • Tool Record
      • Tổng quan
      • Architecture
        • Database Schema
        • System Architecture
        • Code Structure
      • Deployment
        • Local
        • Staging
        • Product
      • API Interface
        • Public API
          • Task System
            • Get All Tasks
            • Create Task (List)
            • Create Task (Single)
            • Update Task
            • Delete Tasks
            • Count Processing Tasks
            • Get System Logs
            • Send single Task to Webhook
            • Send multiple Tasks to Webhooks
          • System Info
            • Root Details
            • Health Check
  1. Business | Logic

API INTERFACE & TASK MANAGEMENT

SYSTEM BUSINESS LOGIC: API INTERFACE & TASK MANAGEMENT#

Phân hệ API (được xây dựng trên nền tảng ElysiaJS và Bun) đóng vai trò là Cổng giao tiếp trung tâm (API Gateway). Đây là điểm chạm duy nhất để các hệ thống bên ngoài (như CMS Admin Frontend) giao tiếp, phân phối lệnh và giám sát hệ thống Worker chạy ngầm.

1. Nghiệp vụ Tiếp nhận và Khởi tạo Tác vụ (Task Ingestion Business)#

Tiếp nhận Đơn lẻ & Hàng loạt (Single vs. Bulk Ingestion): - Hệ thống cung cấp hai luồng khởi tạo riêng biệt: POST /api/task cho các yêu cầu kiểm tra tức thời (thủ công) và POST /api/task/list để nạp dữ liệu hàng loạt từ các chiến dịch quét quy mô lớn (auto-cronjob từ CMS).
Nghiệp vụ này giúp giảm thiểu số lượng kết nối HTTP (TCP Handshake) khi cần đẩy hàng nghìn tên miền vào hệ thống cùng lúc, tối ưu hóa băng thông và tài nguyên máy chủ.
Kiểm soát tính toàn vẹn dữ liệu: Mọi tác vụ khi được nạp vào qua API đều mang trạng thái mặc định là Khởi tạo (0 - Pending) để đảm bảo quy trình đưa vào Hàng đợi (Queue) phía sau diễn ra tuần tự, tránh tình trạng Race Condition (xung đột luồng).
Cập nhật & Thu hồi Tác vụ (Update & Delete): Thông qua PUT /api/task/:id và DELETE /api/task, hệ thống cho phép các hệ thống ngoại vi can thiệp vào vòng đời tác vụ. Ví dụ: Hủy bỏ hàng loạt các tác vụ đang chờ nếu chiến dịch quét bị tạm dừng, giúp giải phóng hàng đợi.

2. Nghiệp vụ Kiểm soát Tải và Đồng thời (Concurrency & Load Control)#

Giám sát Khối lượng công việc (Workload Monitoring): Endpoint GET /api/task/count-processing thực thi nghiệp vụ đếm số lượng tác vụ đang ở trạng thái 1 - Running.
Cân bằng Tải (Load Balancing/Throttling): Dữ liệu từ endpoint đếm này được sử dụng làm chỉ báo (metric) quan trọng. Nếu số lượng task đang xử lý vượt quá ngưỡng chịu tải của Server (dựa trên PROCESS_LIMIT), hệ thống nguồn (CMS) có thể quyết định tạm dừng đẩy thêm task mới, giúp bảo vệ Worker Server khỏi tình trạng cạn kiệt bộ nhớ (OOM - Out of Memory) hoặc sập CPU.

3. Nghiệp vụ Điều phối Dữ liệu Nội bộ & Dự phòng (Fallback Webhook Business)#

Về cơ bản, hệ thống tự động trả kết quả về hookUrl khi Worker chạy xong. Tuy nhiên, trong thực tế vận hành có thể xảy ra tình trạng rớt mạng nội bộ (Network Partition) đúng thời điểm trả kết quả.
Kích hoạt Webhook Thủ công (Manual Dispatch): Hệ thống API cung cấp các endpoint POST /api/task/sendToWebhook và POST /api/task/sendToWebhooks để thực thi nghiệp vụ Dự phòng (Fallback). Quản trị viên hoặc các script sửa lỗi có thể gọi API này để ép hệ thống đóng gói và gửi lại (Retry) kết quả của một hoặc nhiều tác vụ về CMS mà không cần phải chạy lại toàn bộ tiến trình quét trình duyệt (vốn tốn rất nhiều thời gian).

4. Nghiệp vụ Giám sát Vận hành & Tra cứu (Observability & Audit Business)#

Truy xuất Nhật ký Tập trung (Centralized Log Access): Nghiệp vụ yêu cầu quản trị viên có thể theo dõi tình trạng sức khỏe của ứng dụng mà không cần quyền truy cập SSH trực tiếp vào Server vật lý.
Khai thác Log qua API: Endpoint GET /api/task/getLogs cho phép ứng dụng bên thứ ba truy xuất, lọc và đọc nội dung trực tiếp từ các tệp tin log vật lý lưu tại storage/log/. Việc này hỗ trợ đội ngũ kỹ thuật phát hiện sớm các vấn đề kẹt luồng, lỗi Proxy hay lỗi crash của FFmpeg một cách trực quan trên giao diện Admin.

5. Nghiệp vụ Tiêu chuẩn hóa Giao thức (API Standardization Business)#

Để đảm bảo khả năng tích hợp mở rộng (Scalability) với nhiều hệ thống đối tác trong tương lai, toàn bộ hệ thống API được đặc tả và tự động sinh tài liệu chuẩn Swagger/OpenAPI.
Bất kỳ dịch vụ nào khi truy cập vào http://localhost:8080/swagger đều nắm được chính xác cấu trúc DTO (Data Transfer Object), Payload cần gửi và định dạng Response trả về, giúp chuẩn hóa quá trình giao tiếp giữa các Microservices.
Modified at 2026-03-28 02:53:55
Previous
Integration & Reliability Business
Next
SYSTEM BUSINESS OVERVIEW
Built with