Skip to content

Kiến trúc Hệ thống

Thông tin nhanh

  • Mô hình: Multi-App Platform, 100% Serverless Edge Computing
  • 5 Frontends: Admin, Landing, Portal, Affiliate — React SPA trên Cloudflare Pages
  • Backend: Cloudflare Workers API (25+ route files)
  • Database: Neon PostgreSQL (30 migrations, Multi-tenant)
  • AI: AI Assistant Panel + Skill Library + MCP Server

Xem thêm: Phân tích hệ thống · Database · Affiliate · Catalog

Sơ đồ Kiến trúc Tổng quan

Các lớp Xác thực (4 layers)

LayerHeaderUsed ByFile
JWT AuthAuthorization: Bearer <token>Admin, Portal, Affiliateauth.js
API KeyX-API-Key: sk_live_xxxLanding pages, external systemsauth.js
Agent TokenX-Agent-Token: agent_xxxAI Agent via MCPagent-auth.js
RBAC(JWT payload)Admin/Owner/Collaborator/Agentroles.js

Multi-Auth JWT Flows

Backend Route Map (23 files)

NhómFilesAuthEndpoints
Authauth, auth-advancedJWT~15 (login, register, OAuth, OTP, team)
CRMleads-v2, customers, bookingsJWT~25 (CRUD, pipeline, assign)
Telesalescall-logs, call-scriptsJWT~8 (call tracking)
Catalogcatalog, services-listJWT~16 (categories, services, products, packages)
PaymentspaymentsJWT~5 (payments, bank, VietQR)
Reportsdashboard, reports, activitiesJWT~10 (funnel, cohort, export)
AI (New)ai-assistant, ai-adminJWT~10 (suggest, skills, usage, control)
Publicpublic-leads, public-pages, queue, reviewsAPI Key~10 (lead intake, booking)
Agentagent-api, agent-tokens, webhooksAgent Token~10 (7 tools + management)
ResourcesresourcesJWT~3

Frontend Architecture

Cả 4 frontend apps đều dùng cùng stack:

TechVersionPurpose
React18+UI framework
Vite5+Build tool
TailwindCSSv4Styling
react-router-dom6+Routing

Admin Pages (16 + settings + landing)

CategoryPages
CRM CoreDashboard, Leads, LeadDetail, Customers, Bookings
TelesalesCallScripts
OperationsQueue, Reviews, Payments
AI AssistantAIAssistantPanel, AISkillsLibrary
ReportsReports
PublicPublicPages
AffiliateAffiliates, AffiliatePayouts, AffiliateReports
SettingsProfile, Team, Queue, Bank, Appearance, Catalog
Landing13 pages (Main, 8 industries, AI Agent, Public, Share)

Webhook System

FeatureDetail
Eventslead.created, lead.updated, booking.created, booking.updated, call.completed, review.created, *
SecurityHMAC-SHA256 signature
Retry3 attempts, exponential backoff (1s → 4s → 16s)
LoggingFull delivery log in webhook_delivery_log

Xem API: Webhooks

MCP Server

7 tools expose qua Model Context Protocol:

ToolChức năng
crm_search_leadsTìm kiếm leads
crm_create_leadTạo lead mới
crm_update_leadCập nhật lead
crm_search_customersTìm customers
crm_log_callGhi call log
crm_send_messageGửi tin nhắn
crm_get_analyticsLấy analytics/pipeline

Xem chi tiết: MCP Server

SaleHay CRM Documentation