Appearance
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)
| Layer | Header | Used By | File |
|---|---|---|---|
| JWT Auth | Authorization: Bearer <token> | Admin, Portal, Affiliate | auth.js |
| API Key | X-API-Key: sk_live_xxx | Landing pages, external systems | auth.js |
| Agent Token | X-Agent-Token: agent_xxx | AI Agent via MCP | agent-auth.js |
| RBAC | (JWT payload) | Admin/Owner/Collaborator/Agent | roles.js |
Multi-Auth JWT Flows
Backend Route Map (23 files)
| Nhóm | Files | Auth | Endpoints |
|---|---|---|---|
| Auth | auth, auth-advanced | JWT | ~15 (login, register, OAuth, OTP, team) |
| CRM | leads-v2, customers, bookings | JWT | ~25 (CRUD, pipeline, assign) |
| Telesales | call-logs, call-scripts | JWT | ~8 (call tracking) |
| Catalog | catalog, services-list | JWT | ~16 (categories, services, products, packages) |
| Payments | payments | JWT | ~5 (payments, bank, VietQR) |
| Reports | dashboard, reports, activities | JWT | ~10 (funnel, cohort, export) |
| AI (New) | ai-assistant, ai-admin | JWT | ~10 (suggest, skills, usage, control) |
| Public | public-leads, public-pages, queue, reviews | API Key | ~10 (lead intake, booking) |
| Agent | agent-api, agent-tokens, webhooks | Agent Token | ~10 (7 tools + management) |
| Resources | resources | JWT | ~3 |
Frontend Architecture
Cả 4 frontend apps đều dùng cùng stack:
| Tech | Version | Purpose |
|---|---|---|
| React | 18+ | UI framework |
| Vite | 5+ | Build tool |
| TailwindCSS | v4 | Styling |
| react-router-dom | 6+ | Routing |
Admin Pages (16 + settings + landing)
| Category | Pages |
|---|---|
| CRM Core | Dashboard, Leads, LeadDetail, Customers, Bookings |
| Telesales | CallScripts |
| Operations | Queue, Reviews, Payments |
| AI Assistant | AIAssistantPanel, AISkillsLibrary |
| Reports | Reports |
| Public | PublicPages |
| Affiliate | Affiliates, AffiliatePayouts, AffiliateReports |
| Settings | Profile, Team, Queue, Bank, Appearance, Catalog |
| Landing | 13 pages (Main, 8 industries, AI Agent, Public, Share) |
Webhook System
| Feature | Detail |
|---|---|
| Events | lead.created, lead.updated, booking.created, booking.updated, call.completed, review.created, * |
| Security | HMAC-SHA256 signature |
| Retry | 3 attempts, exponential backoff (1s → 4s → 16s) |
| Logging | Full delivery log in webhook_delivery_log |
Xem API: Webhooks
MCP Server
7 tools expose qua Model Context Protocol:
| Tool | Chức năng |
|---|---|
crm_search_leads | Tìm kiếm leads |
crm_create_lead | Tạo lead mới |
crm_update_lead | Cập nhật lead |
crm_search_customers | Tìm customers |
crm_log_call | Ghi call log |
crm_send_message | Gửi tin nhắn |
crm_get_analytics | Lấy analytics/pipeline |
Xem chi tiết: MCP Server