source: update Base rule Agent

This commit is contained in:
2026-03-09 18:01:01 +07:00
parent 3003a0ff0b
commit fd9f558fa1
22 changed files with 501 additions and 1426 deletions

View File

@@ -1,24 +1,24 @@
# Tài liệu Kiến trúc C4 - Mức 4: Code Documentation (Frontend Store)
# C4 Architecture Document - Level 4: Code Documentation (Frontend Store)
Mô tả chi tiết cấu trúc quản lý dữ liệu (State Management) tại Frontend để phục vụ luồng nghiệp vụ phức tạp.
Detailed description of the state management structure on the Frontend to support complex business flows.
## 1. Global State (Zustand/Context)
Để đảm bảo dữ liệu khách hàng được lưu giữ khi chuyển giữa các trang (Chọn sản phẩm -> Quay lại sửa thông tin -> Xem PDF), sử dụng Global Store.
To ensure customer data is retained when navigating between pages (Selecting Product -> Going back to edit info -> Viewing PDF), a Global Store is utilized.
### `useCustomerStore`
- **State**:
- `personalInfo`: { name, cccd, dob, gender, ... }
- `ocrStatus`: 'idle' | 'scanning' | 'success' | 'error'
- `selectedProduct`: 'UVL-IC' | 'UVL-EL' | null
- `illustrationUrl`: string (Link PDF)
- `illustrationUrl`: string (PDF Link)
- **Actions**:
- `updateInfo(field, value)`
- `setOCRData(data)`
- `resetSession()`
## 2. Sequence Diagram: Luồng OCR & Tạo PDF
## 2. Sequence Diagram: OCR & PDF Generation Flow
```mermaid
sequenceDiagram
@@ -28,21 +28,21 @@ sequenceDiagram
participant OCR as OCR Service
participant PDF as PDF Engine
User->>FE: Upload ảnh CCCD
User->>FE: Upload ID Card image
FE->>BFF: POST /api/ocr (image)
BFF->>OCR: Extract Info
OCR-->>BFF: {name, cccd, dob...}
BFF-->>FE: Return JSON
FE->>FE: Update Store (personalInfo)
FE-->>User: Hiển thị Form (đã điền sẵn)
FE-->>User: Display Form (pre-filled)
User->>FE: Chọn SP & Nhấn "Xem Minh Họa"
User->>FE: Select Product & Click "View Illustration"
FE->>BFF: POST /api/illustration {info, product}
BFF->>PDF: Generate Request
PDF-->>BFF: PDF Stream/URL
BFF-->>FE: Return URL
FE-->>User: Hiển thị PDF Viewer
FE-->>User: Display PDF Viewer
```
---
*Biên soạn bởi: Agent mbl-landing-page-architecture*
*Authored by: Agent mbl-landing-page-architecture*