KB-6635 rev 28

5 Tầng Kiến trúc — Chi tiết

5 min read Revision 28
architecture5-layerfoundationgaps

5 Tầng Kiến trúc — Chi tiết

v2.2 | 2026-03-15 S124 — FIX NỀN. PRs #444→#510. Hiến pháp v3.5 (25 Điều). OR v4.23. MySQL RETIRED → PostgreSQL 16 sole DB. Luật Nhãn v1.3 ĐÓNG BĂNG. 17 TRIGGER realtime. Layer 1-5 navigation. 6 heading nhất quán. AUDIT TOÀN DIỆN: 5 🔴 Critical → DỪNG XÂY MỚI. search_knowledge("5 tầng kiến trúc chi tiết")


TẦNG 1: HẠ TẦNG

Mục đích: Cung cấp nền tảng chạy cho mọi thứ phía trên. Ổn định, bảo mật, có thể phục hồi.

Thành phần hiện có:

Thành phần Công nghệ Trạng thái
Server VPS Contabo 6vCPU 12GB ✅ Ổn định
Container Docker Compose 6 services ✅ Ổn định
Database PostgreSQL 16 (sole DB — MySQL RETIRED S115) ✅ Ổn định
Vector DB Qdrant (Agent Data embeddings) ✅ Ổn định
Reverse Proxy Nginx ✅ Ổn định
CMS Engine Directus v11.5.1 (DB_CLIENT=pg) ✅ Ổn định
Frontend Engine Nuxt 3 + Agency OS template ✅ Ổn định
Knowledge API Agent Data (Python FastAPI + Qdrant) ✅ Ổn định
Monitoring Uptime Kuma + cron health checks ✅ Cơ bản
CI/CD GitHub Actions → SSH → VPS direct deploy ✅ Ổn định
AI Connections Claude Code/Desktop, Codex, GPT, Gemini → MCP/HTTP ✅ Đã kết nối
Multi-domain Nginx multi-server-block + SSL per domain ❌ Chưa có (TD-086)
i18n @nuxtjs/i18n + Directus translations ❌ Chưa cài (TD-087)
Automation Prefect (planned), Playwright (planned) 🔴 Chưa triển khai

Đánh giá: Tầng 1 cơ bản ổn. Thiếu: multi-domain infrastructure, i18n module, orchestration engine (Prefect), browser automation (Playwright).


TẦNG 2: CƠ SỞ (NGUYÊN LIỆU + CÔNG CỤ TẠO CÔNG CỤ) ★ ĐÃ VỮNG

Mục đích: Cung cấp nguyên liệu và cơ chế để Tầng 3 lắp ráp.

Thành phần CẦN CÓ vs HIỆN TRẠNG:

2.1 Registry System

Cần có Hiện trạng Trạng thái
Mọi thực thể có ID duy nhất 13 auto-ID flows, PREFIX chuẩn
Mọi thực thể nằm trong registry 27 meta_catalog entries, 1438 entity codes
Registry đọc = biết toàn bộ Layer 1-5 drill-down UI
Thêm mới = UI tự hiện Auto-ID + DirectusTable + registry pages
% coverage verify_counts()=0 MISMATCH, check_registry_coverage()

2.2 Metadata System

Cần có Hiện trạng Trạng thái
Mỗi field có notes 100% field notes filled
Mỗi collection có phân loại 100% collection notes
Batch update tool dot-metadata-fill

2.3 Entity Lifecycle

Cần có Hiện trạng Trạng thái
Sinh thực thể = tự đăng ký DOT scripts + auto-ID flows + 18 PG triggers
Vòng đời: draft→active→deprecated→retired Status field trên mọi registry collection
Deprecate = cảnh báo nơi đang dùng entity_dependencies 254 records 🟡
SỬA/XOÁ/GỘP scripts ❌ Chưa có 🔴 Gap

2.4 Taxonomy + Labels (S122-S123)

Cần có Hiện trạng Trạng thái
Phân loại đa chiều 5 taxonomy collections, 55 labels, 6 chiều
Tự gán nhãn 18 PG auto-label triggers, 32 rules
Label integrity fn_auto_label_assignment() + entity_labels 1893

2.5 Counting + Integrity

Cần có Hiện trạng Trạng thái
Đếm realtime 17 PG TRIGGER (INSERT/UPDATE/DELETE/TRUNCATE)
Verify verify_counts()=0 MISMATCH
Coverage check_registry_coverage()

2.6 DOT Tools

Cần có Hiện trạng Trạng thái
Mọi thao tác schema = DOT tool 108 tools registered
Duplicate Engine ❌ Chưa có 🔴 TD-083

KẾT LUẬN TẦNG 2: 🟢 VỮNG. Metadata 100%, registries 27 entries, auto-ID 13 flows, 17 triggers realtime, entity_dependencies 254, taxonomy 55 labels, verify_counts()=0. Thiếu: Duplicate Engine, Modify/Delete lifecycle scripts.


TẦNG 3: CƠ BẢN (MODULES NỀN TẢNG)

Module Trạng thái
Comment Module M-001 ✅ Commercial
Workflow Module M-002 🟡 Phase 2A DONE, Phase 2B paused
Table Module M-003 ✅ DirectusTable + tableId pattern
Auto Tester Module M-004 🔴 SSOT only

TẦNG 4: CHUYÊN MÔN (ĐÍCH ĐẾN)

State Machine là mô hình chính. Chưa bắt đầu — đúng vì Tầng 2-3 cần fix nền trước.


TẦNG 5: GIÁM SÁT + CẢI TIẾN

Đã có: verify_counts(), check_registry_coverage(), audit_relationships(), audit_dead_links(), system_issues lifecycle, DOT Scanning song song (Điều 23).

Thiếu: Sync monitor thống nhất, self-healing auto-remediate, Production Truth Gate (TD-168).