📐 ADR-003: Chọn pgvector cho embedding storage (thay Pinecone)
Decision: pgvector extension trong PostgreSQL 16. Cost reduction 60%, latency tương đương trong workload hiện tại.
Engineering📅 Updated 18 Mar 2026
CT
CTO Agent
System Architecture
Tổng quan kiến trúc hệ thống Hyper Commerce — multi-tenant SaaS, 4 modules tích hợp. Đây là tài liệu reference chính cho mọi quyết định kỹ thuật.
Architecture Overview
Hyper Commerce được xây dựng theo kiến trúc monorepo modular với 4 domain chính. Mỗi domain có backend API riêng nhưng chia sẻ common infrastructure (auth, DB, Redis).
ℹ️
Tenant Isolation — CRITICAL
Mọi DB query PHẢI có WHERE tenant_id = :tid. Middleware tự động inject ctx.tenant_id. Service layer KHÔNG nhận tenant_id từ user input.
Tech Stack
Layer
Technology
Version
Purpose
Frontend
React + Vite + Ant Design
18 / 5.x / 5.x
SPA, route-based code splitting
Backend
Python + FastAPI
3.11 / 0.110
Async REST API
Database
PostgreSQL + pgvector
16
Multi-tenant, vector search
Cache
Redis
7
Session, Celery broker, rate limit
Queue
Celery
5.x
Background tasks, scheduled jobs
Workflow
N8N self-hosted
Latest
Shopify ↔ Zalo ↔ Odoo automation
Storage
MinIO / S3
—
File uploads, exports
AI/LLM
OpenAI + LangChain
GPT-4o-mini
Agent, embeddings, RAG
Module Architecture
Backend tổ chức theo domain, không theo layer. Mỗi domain chứa: router.py → service.py → repository.py → schemas.py
Module CRM quản lý khách hàng, sản phẩm, sales pipeline và khuyến mãi. Tích hợp Odoo 17 qua XML-RPC.
Customer CRUD với full-text search (PostgreSQL GIN index)
Consequences: Cần enable CREATE EXTENSION IF NOT EXISTS vector; trước migration. IVFFlat index cho HNSW-level performance.
ADR-002: FastAPI + async SQLAlchemy over Django ORM▾
Decision: FastAPI với async SQLAlchemy và Alembic migrations.
Rationale: Native async support cho high-concurrency workload. Type safety với Pydantic v2. Auto OpenAPI docs. Django ORM blocking I/O không phù hợp với Celery + async pattern.
ADR-003: Shopify GraphQL Admin API 2026-01 (bỏ REST)▾
Decision: Chuyển toàn bộ Shopify integration sang GraphQL Admin API version 2026-01.
Rationale: Shopify REST Admin API deprecated từ 01/10/2024. Mọi app mới từ 01/04/2025 bắt buộc GraphQL. Version 2024-01 đã hết vòng đời hỗ trợ.
Impact: ECOM-001 cần refactor. +3 ngày dev. Tránh 5-7 ngày tech debt sau go-live.
✅ Done — Sprint 1–4📅 Updated 22 Mar 2026
CRM Module
Quản lý khách hàng, sản phẩm, sales pipeline, khuyến mãi và tích hợp Zalo ZNS. 6 features hoàn chỉnh — Sprint 1, 2, 4.
Feature Overview
Feature ID
Tên
Sprint
SP
Status
CRM-001
Customer Profile CRUD + Search
1
16
Done
CRM-002
CSV Import Bulk Upload
1
13
Done
CRM-003
Product & Inventory Management
1
13
Done
CRM-004
Sales Pipeline Kanban
2
13
Done
CRM-005
ZNS Notification Integration
4
11
Done
CRM-006
Promotions & Coupon Engine
4
10
Done
Key API Endpoints
# Customers
GET /api/v1/customers?page=1&size=20&search=nguyen
POST /api/v1/customers
PATCH /api/v1/customers/{id}
DELETE /api/v1/customers/{id} # soft delete
# Products
GET /api/v1/products
POST /api/v1/products
POST /api/v1/customers/import/csv # bulk import
# Pipeline
GET /api/v1/pipeline/stages
POST /api/v1/pipeline/deals
PATCH /api/v1/pipeline/deals/{id}/move
# Promotions
GET /api/v1/promotions
POST /api/v1/promotions
# ZNS
POST /api/v1/zalo/zns/send # rate limit: 10 msg/s
GET /api/v1/zalo/zns # message history
Architecture Notes
ℹ️
3-Layer: Router → Service → Repository
Mọi query phải có WHERE tenant_id = :tid. Soft delete bắt buộc — không hard delete customers/products. Audit log cho mọi thay đổi quan trọng.
Demo Data
Dataset
Số lượng
Ghi chú
Khách hàng
50 profiles
Faker data tiếng Việt
Sản phẩm
10 SKUs
Thời trang, 150k–890k VND
Pipeline deals
6 stages
Prospecting → Closed Won
Khuyến mãi
3 active
Demo cho AI Agent tool calling
🔴 Updated — Breaking Change📅 20 Mar 2026
Shopify OAuth & Product Sync
ECOM-001 — Hướng dẫn tích hợp Shopify theo chuẩn tháng 3/2026. Bắt buộc dùng GraphQL Admin API 2026-01. REST API đã bị deprecated.
⛔
Breaking Change — REST API Deprecated
Shopify REST Admin API là legacy từ 01/10/2024. Mọi code dùng shopifyapi Python library hoặc REST endpoints /products.json phải được migrate sang GraphQL ngay. Xem CTO Decision Memo.
OAuth Setup
Authorization Code Grant với offline access token — phù hợp cho background sync. Chỉ thay đổi API version string.
pythonrouter.py — OAuth config
SHOPIFY_API_VERSION = "2026-01"# ← Luôn dùng version này
REQUIRED_SCOPES = "read_products,write_products,read_orders,read_inventory"# Redirect URL cho OAuth
auth_url = (
f"https://{shop_domain}/admin/oauth/authorize"f"?client_id={settings.SHOPIFY_CLIENT_ID}"f"&scope={REQUIRED_SCOPES}"f"&redirect_uri={settings.SHOPIFY_REDIRECT_URI}"f"&state={state}"f"&access_mode=offline"# offline = permanent token
)
GraphQL Client
💡
Dùng httpx + gql, KHÔNG dùng shopifyapi library
Library shopifyapi là REST wrapper. Dùng httpx async HTTP client + raw GraphQL queries để có full control và async compatibility với FastAPI.
Product Sync — productSet Mutation
Operation
Old (REST)
New (GraphQL)
Create product
POST /products.json
productSet mutation
Update product
PUT /products/{id}.json
productSet mutation (same)
Delete product
DELETE /products/{id}.json
productDeleteAsync mutation
List products
GET /products.json?limit=250
products query + cursor pagination
Bulk sync
REST pagination loop
bulkOperationRunQuery async
Webhooks
POST /webhooks.json
webhookSubscriptionCreate mutation
Implementation Checklist
#
Task
Owner
Status
1
Rewrite client.py → ShopifyGraphQLClient
Tech Lead
In Progress
2
Create queries.py — all GQL queries/mutations
Tech Lead
Todo
3
Migrate service.py → use productSet
Tech Lead
Todo
4
Implement bulkOperationRunQuery for initial sync
Tech Lead
Todo
5
Update webhook subscription to GraphQL
Tech Lead
Todo
6
Write integration tests (mock GraphQL responses)
TL + QA
Todo
7
Update CLAUDE.md spec — version & library
PO
Todo
✅ Done — Sprint 3 + 5📅 Updated 22 Mar 2026
CDP Engine
Customer Data Platform: thu thập sự kiện, dedup, phân khúc khách hàng và analytics. 4 features hoàn chỉnh — Sprint 3 & 5.
Feature Overview
Feature ID
Tên
Sprint
SP
Status
CDP-001
Data Ingestion Pipeline
3
11
Done
CDP-002
Deduplication & Data Cleansing
3
10
Done
CDP-003
Segmentation Engine
3
13
Done
CDP-004
CDP Analytics & Export
5
8
Done
Architecture
ℹ️
Event-driven via Redis Stream
Events được push vào cdp:events::{tenant_id} Redis Stream. Celery consumer group grp xử lý async — không block request chính. Dead letter sau 3 lần retry.
Key API Endpoints
# Ingestion
POST /api/v1/cdp/events # push event vào Redis Stream
GET /api/v1/cdp/events # list events với filter
# Deduplication
GET /api/v1/cdp/dedup/candidates # list duplicate pairs
POST /api/v1/cdp/dedup/merge # merge 2 customer profiles
POST /api/v1/cdp/dedup/dismiss # bỏ qua cặp trùng
# Segments
GET /api/v1/cdp/segments # list segments
POST /api/v1/cdp/segments # tạo segment mới
GET /api/v1/cdp/segments/{id}/members
POST /api/v1/cdp/segments/{id}/refresh
# Analytics (Sprint 5)
GET /api/v1/cdp/analytics?period=30d
GET /api/v1/cdp/analytics/export/customers # CSV StreamingResponse
Zalo OA Management, ZNS/ZBS Campaign, AI Agent (RAG + Tool Calling) và Knowledge Base. 4 features hoàn chỉnh — Sprint 4 & 5.
Feature Overview
Feature ID
Tên
Sprint
SP
Status
PT-001
Zalo OA Management
4
11
Done
PT-002
ZBS Broadcast Campaign
4
13
Done
PT-003
AI Agent Core (RAG + Tool Calling)
5
16
Done
PT-004
Knowledge Base & AI Analytics
5
10
Done
Zalo OA Integration
ℹ️
OA "Lã Vọng fishing" — Live (22/03/2026)
OA ID: 3665862159615576892 · Verified OA · Gói Nâng cao (99k/tháng) — hiệu lực đến 21/09/2026
Access token hết hạn sau 1 giờ. Celery beat tự động refresh mỗi 45 phút. Refresh token hết hạn sau 3 tháng.
Gói dịch vụ OA
Thông tin
Giá trị
Tên gói
Nâng cao
Giá
99.000đ/tháng (594.000đ/6 tháng)
Hiệu lực
21/09/2026
Tin tư vấn ngoài khung
2.000 tin/kỳ
Broadcast lượt miễn phí
4 lượt/kỳ
Tổng đài viên
5 người
ZNS
Hỗ trợ (cần đăng ký template riêng)
Zalo API v3 — Thay đổi quan trọng
⛔
API lấy danh sách followers đã bị xóa khỏi V3
v2.0/oa/getfollowers → tắt từ 06/2024 v3.0/oa/user/getlist → Zalo xác nhận không còn hỗ trợ Không thể chủ động lấy danh sách followers. Thay bằng Webhook event-driven.
💡
Cách lấy user_id trong V3 — Webhook
Khi user follow OA / nhắn tin / click → Zalo POST event vào Webhook URL → hệ thống lưu user_id vào DB → dùng user_id để gửi tin sau này.
Events cần bật: follow, unfollow, user_send_text
# Chạy Cloudflare tunnel (dev environment)
cloudflared tunnel --url http://localhost:8000
# Webhook URL format
https://{tunnel-domain}/api/v1/zalo/webhook/3665862159615576892
# Khi domain lavongfishing.vn verified → dùng subdomain cố định
https://api.lavongfishing.vn/api/v1/zalo/webhook/3665862159615576892
ZNS — Trạng thái
⏳
ZNS chưa có template — cần đăng ký riêng
ZNS API endpoint hoạt động (token hợp lệ). Hiện có 0 templates được duyệt.
Cần làm: Vào business.zalo.me → ZNS → Tạo template → Submit để Zalo duyệt (1–3 ngày làm việc).
Chi phí ZNS tính riêng theo tin (~100–300đ/tin tùy loại template).
Key API Endpoints
# Zalo OA
POST /api/v1/zalo/oa/connect # kết nối OA với OAuth code
GET /api/v1/zalo/oa # xem OA info
POST /api/v1/zalo/oa/send # gửi OA message
# ZNS
POST /api/v1/zalo/zns/send # gửi ZNS (rate: 10 msg/s)
GET /api/v1/zalo/zns # history
# Campaigns
GET /api/v1/campaigns # list với filter status/type
POST /api/v1/campaigns # tạo campaign
POST /api/v1/campaigns/{id}/launch # kích hoạt gửi
POST /api/v1/campaigns/{id}/cancel # hủy
# AI Agent
POST /api/v1/agent/chat # chat với AI Agent
# Knowledge Base
GET /api/v1/knowledge/documents
POST /api/v1/knowledge/documents # upload PDF/DOCX/TXT (max 20MB)
DELETE /api/v1/knowledge/documents/{id}
GET /api/v1/knowledge/analytics
Chính sách đổi trả, hướng dẫn size, loyalty program
Campaigns
Demo data
ZNS / ZBS / Email types
Zalo OA
1 OA live
"Lã Vọng fishing" — verified OA
Processes📅 Updated 22 Mar 2026
Sprint Workflow
Quy trình Scrum của Hyper Commerce: 2-tuần sprints, 6 sprints để MVP. Ceremonies, DoD, và velocity tracking.
🎉
Phase 1 MVP Complete — v1.1.1 · 22/03/2026
264/272 Story Points · 224/224 tests passing · Zalo OA live · Tag: v1.1.1
Sprint Overview
Sprint
Focus
Key Features
SP
Status
Sprint 0
Infrastructure
Auth, DB, N8N, CI/CD
48/48
Done
Sprint 1
CRM Core
Customer CRUD, CSV Import, Products
42/42
Done
Sprint 2
Commerce
Pipeline Kanban, Shopify OAuth, Orders
42/42
Done
Sprint 3
CDP
Inventory Sync, Ingest, Dedup, Segments
44/44
Done
Sprint 4
Engagement
ZNS, Promotions, Zalo OA, ZBS
44/44
Done
Sprint 5
AI & Analytics
Analytics, CDP Dashboard, AI Agent, KB
44/52
Done (96%)
Ceremonies
1
Sprint Planning — Monday (2h)
PO + PM + TL. Review backlog, estimate story points, set sprint goal. Output: Sprint backlog confirmed.
2
Daily Standup — Every day (15 min)
What did I do? What will I do? Any blockers? PM facilitates. Blockers resolved < 2 hours.
3
Sprint Review — Friday (1h)
Demo completed features to CEO. PO signs off on DoD. Velocity measured.
4
Retrospective — Friday (45 min)
What went well? What to improve? Action items for next sprint. Team only (no CEO).
Definition of Done
⚠️
Tất cả tiêu chí DoD phải đạt trước khi chuyển feature sang Done
Không có exception. Feature chưa đủ DoD = không được demo trong Sprint Review.
✅ Code viết xong — 0 TODO/FIXME chưa xử lý
✅ Unit tests pass — coverage ≥ 70% service layer
✅ Integration tests pass — bao gồm cross-tenant isolation
✅ black, isort, flake8, mypy pass (0 errors)
✅ bandit scan: 0 High/Critical issues
✅ Swagger docs generate đúng cho endpoint mới
✅ PR với title format [FDD-ID] feat/fix: mô tả
✅ Code review approved bởi ≥ 1 người
✅ Deploy Dev thành công, smoke test pass
✅ Wiki đã cập nhật — trang module liên quan reflect thay đổi, sync sang wiki-deploy
Wiki Update Protocol
📖
Quy trình bắt buộc — PM Agent tự động cập nhật, CEO không cần nhắc
Mọi thay đổi kiến thức, kỹ thuật, quy trình đều phải được phản ánh vào wiki ngay khi hoàn thành. Wiki là nguồn sự thật duy nhất (Single Source of Truth) cho toàn công ty.
Trigger
Trang wiki cập nhật
Thời điểm
CTO ra quyết định / breaking change
Trang module + Architecture
Ngay khi quyết định
Bug fix ảnh hưởng API / DB / external service
Trang module liên quan
Sau khi fix xong
External API thay đổi rule (Zalo, Shopify, OpenAI)
Private Traffic / eCommerce
Ngay khi phát hiện
Feature mới DoD passed
Trang module + Sprint Tracker
Khi merge PR
QA full test pass — số liệu mới
Key Metrics + Sprint
Sau mỗi test run
Config / env / credentials thay đổi
Trang module liên quan
Ngay khi thay đổi
Deploy / release tag mới
Sprint page callout
Sau khi deploy
Onboarding steps thay đổi
Dev Guide / Onboarding
Ngay khi thay đổi
Quy trình deploy wiki sau mỗi lần cập nhật
# 1. Sync file sang deploy directory
cp wiki/index.html wiki-deploy/src/index.html
# 2. Rebuild container (nếu chưa dùng volume)
cd wiki-deploy && docker compose up -d --build
# 3. Verify wiki đang chạy
curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/
# Kết quả phải là: 200
💡
Wiki = Single Source of Truth
Toàn bộ team — Dev, QA, PM, CTO, CEO — đều đọc wiki tại http://localhost:8080 để nắm trạng thái hệ thống.
Wiki lỗi thời = thông tin sai = rủi ro vận hành. PM Agent chịu trách nhiệm đảm bảo wiki luôn cập nhật.
People📅 Updated 19 Mar 2026
Team & AI Agent Roles
12 AI Agents tổ chức theo 5 lớp. CEO là trung tâm điều phối. Mỗi Agent có KPI riêng và SKILL.md định nghĩa behavior.
Organization Layers
👤
CEO
Đoàn Đình Tỉnh — Điều phối chiến lược, quyết định cuối cùng
Layer 0
💻
CTO
Tech Strategy, Security, AI/LLM Platform
L1 — C-Suite
💰
CFO
Finance, Runway, Fundraising, Unit Economics
L1 — C-Suite
💼
Business Manager
GTM, Pricing, Partnership, P&L
L2 — Commercial
📢
Marketing Mgr
Demand Gen, Content, Community, Brand
L2 — Commercial
🤝
Customer Success
Onboarding, Retention, NRR, Upsell
L2 — Commercial
📅
Project Manager
Timeline, Risk, Sprint Ceremonies
L3 — Product
📋
Product Owner
Backlog, User Story, Scope, Sign-off
L3 — Product
📊
Business Analyst
Functional Spec, Business Rules, Flows
L4 — Delivery
🎨
UI/UX Designer
Wireframe, Design System, Handoff
L4 — Delivery
🏗️
Tech Lead
Architecture, Code Review, ADR
L5 — Engineering
⚙️
DevOps
CI/CD, Docker, Infrastructure, Uptime
L5 — Engineering
🧪
Tester / QA
Test Cases, E2E, DoD Verification
L5 — Engineering
Xem chi tiết sơ đồ tổ chức, gap analysis và communication matrix tại PROCESS-MAP.html.
Company📅 2026
Mission & Vision
Lý do Hyper Commerce tồn tại và hướng đi dài hạn của công ty.
🎯
Mission
Trao quyền cho 800,000 SME Việt Nam sở hữu data khách hàng của mình — không bị phụ thuộc vào platform của bên thứ ba.
🔭
Vision 2028
Trở thành nền tảng CDP + Private Traffic hàng đầu Đông Nam Á cho SME — 50,000 merchants, ARR $10M, NRR ≥ 120%.
Core Values
Merchant First: Mọi quyết định sản phẩm đều đặt lợi ích merchant lên đầu tiên
Data Ownership: Merchant sở hữu 100% data — không bán, không chia sẻ với đối thủ
Ship Fast, Fix Faster: MVP trong 3 tháng, iterate dựa trên feedback thực
AI-Native: AI không phải tính năng add-on — AI là kiến trúc cốt lõi
Company📅 Updated 22 Mar 2026
Key Metrics & KPIs
North star metrics và KPI của từng layer trong tổ chức.
MVP Status — 22/03/2026
Metric
Giá trị
Features delivered
23/24 (96%)
Story Points
264/272 (97%)
Tests passing
224/224 (100%)
API routes
73 endpoints
Git tag
v1.1.1
Demo orders
348 đơn · ~1.05B VND (90 ngày)
CDP events
500 events · 4 nguồn
Zalo OA
Lã Vọng fishing (verified ✅)
North Star Metric
⭐
Monthly Active Merchants (MAM) generating revenue events
Merchant được tính là active khi có ≥ 1 CDP event hoặc ≥ 1 campaign sent trong tháng. Target Q2/2026: 200 MAM.
KPIs by Layer
Agent
Primary KPI
Target
CTO
API p95 latency
< 500ms
CFO
Runway
≥ 12 tháng
Business Manager
MRR Growth
≥ 20%/tháng
Marketing Manager
CAC
< 1.5M VNĐ
Customer Success
NRR
≥ 110%
Project Manager
Sprint Velocity
≥ 85% planned SP
Product Owner
Feature Adoption
≥ 70% in 30 days
Tech Lead
Test Coverage
≥ 70%
DevOps
Uptime
≥ 99.5%
Tester / QA
Bug Escape Rate
< 5%
📚 All Resources📅 Updated 20 Mar 2026 · 24 documents
Resource Library
Toàn bộ tài liệu của Hyper Commerce được tổ chức theo phòng ban. Tìm kiếm nhanh hoặc duyệt theo danh mục.
{
"code": "EMAIL_DUPLICATE",
"message": "Email đã tồn tại trong tenant này",
"details": {}
}
HTTP Status
Code
Meaning
400
VALIDATION_ERROR
Request body invalid
401
UNAUTHORIZED
Token missing / expired
403
FORBIDDEN
Insufficient role permissions
404
NOT_FOUND
Resource không tồn tại
422
DOMAIN_ERROR
Business rule violation
429
RATE_LIMITED
Too many requests
502
EXTERNAL_API_ERROR
Shopify / Zalo / Odoo lỗi
⚙️ Engineering📅 18 Mar 2026
Deploy Process
CI/CD pipeline với GitHub Actions. 10 stages từ lint đến production. Zero-downtime deployment với Docker Compose.
Environments
Env
URL
Branch
Trigger
Approval
Dev
dev.hypercommerce.vn
develop
Auto on push
—
Staging
staging.hypercommerce.vn
release/*
Auto on merge
—
Prod
app.hypercommerce.vn
main
Manual
CEO ✅
CI/CD Pipeline — 10 Stages
1Lintblack · isort · flake8 · mypy
2Unit Testspytest · coverage ≥ 70%
3Integration TestsDocker services · full API
4Security Scanbandit · 0 High/Critical
5Build Dockertag with commit SHA
6Deploy Devauto · docker compose up
7Smoke TestGET /health = 200
8Deploy Stagingrelease/* branch
9E2E TestsPlaywright · 5 critical flows
10Deploy Prodmanual · CEO approve
Deploy Commands
bashVPS — zero-downtime
# Production deploy
./scripts/deploy.sh v1.0.0
# Manual rollback
docker compose up -d --no-deps api # restart với image cũ# Health check sau deploy
curl https://api.hypercommerce.vn/health
# Expected: {"status":"ok","timestamp":"..."}
⚠️
Không bao giờ deploy thẳng lên production
Mọi deploy production phải qua Staging + E2E tests. PR title phải theo format [FDD-ID] feat: description. CEO approval bắt buộc.
🖥️ InfrastructureCEO ✅ Approved📅 22 Mar 2026
VPS Deploy Plan — Phase A / B / C
Kế hoạch triển khai hạ tầng VPS theo 3 giai đoạn tăng trưởng. Phê duyệt bởi CEO ngày 22/03/2026. Version 1.0 — Final.
✅
CEO Approved — 22/03/2026
Tài liệu này đã được CEO Đoàn Đình Tỉnh phê duyệt. Mọi thay đổi kiến trúc VPS phải được CTO đề xuất và CEO duyệt trước khi thực hiện.
1. Tổng Quan Chiến Lược
Hyper Commerce triển khai hạ tầng VPS theo mô hình tiến hoá dần — bắt đầu đơn giản, scale khi cần. Ba phương án A/B/C tương ứng ba ngưỡng tăng trưởng:
Bước đầu tiên khi nhận VPS: Kiểm tra Vietnix có hỗ trợ private LAN giữa các VPS cùng datacenter không. Nếu có → dùng trực tiếp. Nếu không → setup WireGuard VPN (thêm ~1 ngày).
bashWireGuard Setup (fallback nếu Vietnix không có private LAN)
# Cài WireGuard trên cả 3 VPS
apt install wireguard -y
# Phân bổ IP private:# VPS-1 (Web/API): 10.0.0.1# VPS-2 (Worker): 10.0.0.2# VPS-3 (DB): 10.0.0.3# Chỉ expose public: port 80/443 trên VPS-1# PostgreSQL bind: 10.0.0.3 (KHÔNG bind 0.0.0.0)# Redis bind: 10.0.0.1 (KHÔNG bind 0.0.0.0)
6. Backup Strategy (Bắt buộc từ Phase A)
🔴
Không có backup = Không được onboard real tenant
DevOps phải setup daily backup trước khi onboard khách hàng đầu tiên có dữ liệu thật.
Áp dụng Claude đúng cách giúp một software company tiết kiệm đáng kể thời gian và chi phí, đồng thời nâng cao chất lượng code và tài liệu.
−70%
Thời gian viết boilerplate code
3×
Tốc độ viết tài liệu kỹ thuật
−90%
Chi phí API nhờ Prompt Caching
+40%
Tăng coverage test tự động
Nguyên tắc cốt lõi: Claude không thay thế developer — Claude nhân bản năng lực của developer. Một senior dev dùng Claude đúng cách tương đương 2–3 developer thông thường.
✅ Setup Checklist (10 Bước)
Thực hiện theo thứ tự khi thành lập company mới hoặc onboard team mới vào hệ thống Claude.
1
Tạo CLAUDE.md 7 tầng — File hướng dẫn cho Claude ở root project. Định nghĩa rõ stack, conventions, business rules.
2
Setup MCP Server nội bộ — FastAPI + JSON-RPC 2.0 tại port 8099. Triển khai 5 Critical Tools ban đầu.
3
Cấu hình .claude/settings.json — Đăng ký MCP Server, set permission mode, định nghĩa allowed tools.
4
Tạo .claude/specs/ folder — Feature specs trích từ FDD/SRS. Mỗi sprint có 1 file spec tương ứng.
5
Onboard team với Role-Based Usage Guide — CEO/PM dùng Claude Chat & Cowork; Dev dùng Claude Code + MCP; QA dùng test generation prompts.
6
Enable Prompt Caching — Đưa CLAUDE.md + static context vào cache prefix để tiết kiệm −90% token cost.
7
Thiết lập Audit Log — Mọi AI action phải ghi vào /logs/ai-audit.json với FDD Feature ID.
8
Định nghĩa Forbidden Actions — List các lệnh không bao giờ chạy: DROP, TRUNCATE, rm -rf, git reset --hard (không confirm).
9
Training Prompt Templates — Chuẩn hoá 3 loại prompt: Feature Build, Bug Fix, Code Review. Lưu tại .claude/prompts/.
10
Đo KPIs hàng tháng — Track: % task hoàn thành AI-assisted, coverage delta, audit log entries, cost per feature.
🏗️ CLAUDE.md — Cấu Trúc 7 Tầng
CLAUDE.md không phải chỉ là README — đây là Enterprise DNA của công ty bạn, được Claude đọc đầu mỗi session. Cấu trúc 7 tầng đảm bảo Claude luôn hành động đúng với business context.
TẦNG 0
Enterprise Governance — Luật bất biến: không truy cập prod DB, không hardcode credentials, mọi query phải có tenant_id, mọi action phải ghi audit log.
TẦNG 1
Corporate Policy — AI-First Development Policy: 4 nguyên tắc, 7-step workflow bắt buộc, danh sách Forbidden Actions.
Thay thế: [COMPANY_NAME], [TECH_STACK], business rules đặc thù. Giữ nguyên Tầng 0 & Tầng 6.
🔧 MCP Server Nội Bộ
Model Context Protocol (MCP) là giao thức mở của Anthropic cho phép Claude gọi tools tùy chỉnh. Hyper Commerce chạy MCP Server riêng tại port 8099 để thay thế raw Bash commands bằng các tools có safety gates.
edit_fileD1 Critical
Sửa file an toàn: exact chunk match 100%, path traversal protection, tự động ghi audit log.
run_pytestD1 Critical
Chạy pytest với coverage report. Trả về pass/fail count + coverage % + failed tests list.