T4 — Phân tích yêu cầu hệ thống - congsinhv/fluxion GitHub Wiki

Phân Tích Yêu Cầu Hệ Thống Fluxion MDM

Numbering chính thức: Mục 3.1 theo Master TOC

Issue: #20 — Phân tích yêu cầu hệ thống (FR + NFR) Tuần: 4 | 14/04 – 20/04/2026


3.1.1 Actors (Tác Nhân)

Actor Vai trò Hành động chính
Admin Quản trị viên cấp cao Toàn quyền: quản lý user, cấu hình policy, tất cả device actions
Operator Quản trị viên vận hành Lock, unlock, send message, release, query devices, dùng chatbot
Device Thiết bị iOS được quản lý Check-in định kỳ, nhận lệnh qua APNS, báo cáo trạng thái, gửi callback
System Hệ thống tự động Scheduled tasks, DLQ processing

3.1.2 Yêu Cầu Chức Năng (Functional Requirements)

FR1: Quản lý vòng đời thiết bị (Device Lifecycle Management)

ID Yêu cầu Mô tả
FR1.1 Enrollment Đăng ký thiết bị iOS qua ADE/DEP (Apple Business Manager), zero-touch
FR1.2 State Management Quản lý 6 trạng thái FSM: idle → registered → enrolled → active ↔ locked → released
FR1.3 Remote Lock Admin/Operator gửi lệnh khóa thiết bị từ xa
FR1.4 Remote Unlock Admin/Operator gửi lệnh mở khóa thiết bị
FR1.5 Remote Send Message Gửi thông báo push tới thiết bị (internal transition — không đổi state, chỉ khi device active)
FR1.6 Remote Lock Message Gửi message hiển thị trên lock screen của thiết bị đang locked (internal transition — không đổi state, chỉ khi device locked)
FR1.7 Device Release Khách hoàn tất hợp đồng trả góp → unenroll MDM, máy trở thành 100% sở hữu khách (graduation). Data của khách giữ nguyên, chỉ bỏ MDM profile. Trigger từ active/lockedreleased (terminal)
FR1.8 Device Query Truy vấn thông tin thiết bị theo ID, trạng thái, hoặc điều kiện lọc
FR1.9 Device Inventory Thu thập và hiển thị thông tin: serial, OS version, model, last check-in

FR2: Command Pipeline (Xử lý lệnh phân tán)

ID Yêu cầu Mô tả
FR2.1 Command Dispatch Gửi lệnh qua GraphQL mutation → SNS/SQS → Lambda processing
FR2.2 APNS Delivery Gửi push notification tới thiết bị qua Apple Push Notification Service
FR2.3 Command Tracking Theo dõi trạng thái lệnh theo action_executions FSM: ACTION_PENDINGACTION_SENTACTION_COMPLETED / ACTION_FAILED
FR2.4 Retry Mechanism Tự động retry lệnh thất bại (SQS maxReceiveCount=3)
FR2.5 DLQ Handling Lệnh thất bại sau 3 retries → Dead Letter Queue → alert
FR2.6 Bulk Commands Gửi lệnh đồng thời cho nhiều thiết bị (fan-out qua SNS)
FR2.7 Command History Xem lịch sử lệnh theo thiết bị hoặc theo thời gian

FR3: Dashboard Real-time

ID Yêu cầu Mô tả
FR3.1 Device Overview Dashboard tổng quan: số thiết bị theo trạng thái, biểu đồ
FR3.2 Real-time Updates Cập nhật tức thì khi device state thay đổi (AppSync Subscriptions)
FR3.3 Command Status Hiển thị real-time trạng thái thực thi lệnh
FR3.4 Device Detail Xem chi tiết từng thiết bị: info, state history, command history
FR3.5 Responsive UI Dashboard hoạt động trên desktop và tablet browsers

FR4: NLP Chatbot (Trợ lý thông minh)

ID Yêu cầu Mô tả
FR4.1 Natural Language Nhận lệnh bằng ngôn ngữ tự nhiên (tiếng Việt + tiếng Anh)
FR4.2 Intent Recognition Nhận dạng intents theo actions có trong Fluxion: lock, unlock, send_message, lock_message, release, query devices, device stats, command history
FR4.3 Function Calling LLM gọi tools qua structured JSON: query_devices, get_device, send_device_command, get_command_history, get_device_stats
FR4.4 Action Confirmation Tất cả actions gửi lệnh tới thiết bị đều yêu cầu xác nhận rõ ràng từ user trước khi thực thi
FR4.5 Conversation Memory Giữ 10 messages gần nhất cho multi-turn conversation
FR4.6 Chat History Lưu trữ và xem lại lịch sử hội thoại

FR5: Quản lý người dùng và phân quyền (RBAC)

ID Yêu cầu Mô tả
FR5.1 Authentication Xác thực user qua AWS Cognito (email/password)
FR5.2 Role-based Access 2 roles: Admin (toàn quyền bao gồm quản lý user), Operator (tất cả device actions nhưng không quản lý user)
FR5.3 JWT Authorization Mỗi API request mang JWT token; Lambda validate role trước thực thi
FR5.4 User Management Admin tạo, sửa, vô hiệu hoá tài khoản user

FR6: Cấu hình hệ thống (Configuration)

ID Yêu cầu Mô tả
FR6.1 States Config Admin cấu hình states theo từng service type
FR6.2 Actions Config Admin quản lý actions, transitions giữa states
FR6.3 Policy Config Admin quản lý policies (name, color, state, service)
FR6.4 Service Config Admin bật/tắt service types
FR6.5 Message Templates Admin tạo, sửa, xóa message templates (notification type: FULLSCREEN/POPUP; 3 icon slots; soft delete)
FR6.6 TAC Management Admin quản lý Type Allocation Codes (tac, provisioning type, brand, model, marketing name) phục vụ device identification
FR6.7 Action Logs Admin xem batch action execution logs (batchId, status, error count); download pre-signed S3 CSV error report

3.1.3 Yêu Cầu Phi Chức Năng (Non-Functional Requirements)

NFR1: Hiệu năng (Performance)

ID Chỉ số Mục tiêu
NFR1.1 API response time (GraphQL query) < 200ms p95
NFR1.2 Command delivery (dispatch → APNS) < 5s p95
NFR1.3 Chatbot response time < 3s (bao gồm LLM API call)
NFR1.4 Dashboard load time < 2s initial load
NFR1.5 Real-time update latency < 1s (AppSync subscription push)

NFR2: Khả năng mở rộng (Scalability)

ID Chỉ số Mục tiêu
NFR2.1 Concurrent devices Hỗ trợ 1.000+ devices (thesis scope: 100–500)
NFR2.2 Lambda concurrency Auto-scaling, reserved concurrency cho critical paths
NFR2.3 SQS throughput Xử lý burst 1.000 messages/phút
NFR2.4 Database connections RDS Proxy connection pooling cho Lambda

NFR3: Bảo mật (Security)

ID Yêu cầu Mô tả
NFR3.1 Authentication AWS Cognito + JWT; token expiry 1h, refresh 30 ngày
NFR3.2 Authorization RBAC enforcement tại Lambda layer (không chỉ frontend)
NFR3.3 Data encryption TLS 1.2+ in transit; AES-256 at rest (RDS, S3)
NFR3.4 OWASP compliance Tuân thủ OWASP API Security Top 10
NFR3.5 Input validation Validate tất cả input tại API layer; sanitize trước DB query
NFR3.6 Chatbot safety Tất cả command actions cần confirmed=true; role check trước execution

NFR4: Độ tin cậy (Reliability)

ID Yêu cầu Mô tả
NFR4.1 Message durability SQS message retention 4 ngày; DLQ cho failed messages
NFR4.2 Retry policy 3 retries với exponential backoff trước DLQ
NFR4.3 Data backup RDS automated backup 7 ngày; point-in-time recovery
NFR4.4 Idempotency Command execution idempotent (duplicate SQS messages safe)

NFR5: Chi phí vận hành (Cost Efficiency)

ID Yêu cầu Mô tả
NFR5.1 Pay-per-use Lambda + SQS + AppSync pay-per-invocation/message/query
NFR5.2 Fixed cost control RDS db.t3.micro (~$25/tháng) + ECS Fargate minimal
NFR5.3 LLM cost control GPT-4o mini ~$0,20–0,50 cho thesis scope (~10K messages)
NFR5.4 Cost target < $50/tháng cho 100-device fleet (không gồm LLM)

NFR6: Khả năng bảo trì (Maintainability)

ID Yêu cầu Mô tả
NFR6.1 Infrastructure as Code Terraform 9 modules; toàn bộ hạ tầng reproducible
NFR6.2 CI/CD GitHub Actions: lint → test → deploy
NFR6.3 Code structure Monorepo; mỗi Lambda handler < 200 LOC
NFR6.4 Logging & Monitoring CloudWatch Logs cho tất cả Lambda/ECS; CloudWatch Metrics cho alerting

3.1.4 Mapping FR → Architecture Components

FR Frontend (React) AppSync Lambda Resolvers SNS/SQS Lambda Workers RDS External
FR1 Device Lifecycle Device list, detail views Queries, Mutations, Subscriptions device-resolver, action-resolver action-trigger-sqs checkin-handler devices, action_executions APNS
FR2 Command Pipeline Command status UI Mutations (sendCommand) action-resolver → action-trigger SNS fan-out → SQS checkin-handler (callback) action_executions APNS
FR3 Dashboard React + Tailwind Subscriptions (onStateChange) All resolvers All tables
FR4 NLP Chatbot Chat UI component Mutation (sendChatMessage) chat-handler Lambda chat_sessions, chat_messages LLM API (GPT-4o mini)
FR5 RBAC Login, user management Cognito authorizer All (JWT validation) users AWS Cognito
FR6 Configuration Configuration page Queries, Mutations platform-resolver, message-template-resolver, tac-resolver, action-log-resolver states, policies, actions, services, message_templates, brands, tacs, batch_actions, batch_device_actions S3 (error report CSV)

3.1.5 Priority Matrix

FR Ưu tiên Lý do
FR1 Device Lifecycle P0 — Critical Core MDM functionality; thesis foundation
FR2 Command Pipeline P0 — Critical Demonstrates EDA + Saga patterns
FR3 Dashboard P1 — High Demo requirement; real-time showcase
FR5 RBAC P1 — High Security foundation; enables FR4 safety
FR4 NLP Chatbot P1 — High Thesis differentiator (AI module)
FR6 Configuration P2 — Medium Admin operational tool; enables dynamic FSM config

3.1.6 Danh Sách Actions Trong Fluxion

Action FSM Trigger Source State Dest State Mô tả
lock lock active locked Khóa thiết bị
unlock unlock locked active Mở khóa thiết bị
send_message send_message active active (internal) Gửi push message, không đổi state
lock_message lock_message locked locked (internal) Gửi message hiển thị trên lock screen, không đổi state
release release active, locked released Khách hoàn tất hợp đồng — unenroll MDM, máy thành sở hữu 100% khách (graduation)

Kết Luận

Chương phân tích yêu cầu đã xác định đầy đủ phạm vi hệ thống Fluxion MDM thông qua 4 tác nhân (Admin, Operator, Device, System) và 6 nhóm yêu cầu chức năng (FR1–FR6) bao phủ toàn bộ vòng đời thiết bị, pipeline lệnh phân tán, dashboard thời gian thực, trợ lý NLP, phân quyền RBAC, và cấu hình hệ thống. Ma trận mapping FR → Architecture Component làm rõ sự phân công trách nhiệm giữa các lớp: UI, AppSync, Lambda resolvers, SNS/SQS workers, và RDS.

Sáu nhóm yêu cầu phi chức năng (NFR1–NFR6) thiết lập các ngưỡng định lượng cụ thể: API response < 200ms p95, command delivery < 5s, chatbot < 3s, đồng thời đặt nền móng cho các quyết định kiến trúc như SQS retry/DLQ, RDS Proxy, và Terraform Infrastructure as Code. Ma trận ưu tiên (Priority Matrix) xác định FR1 và FR2 là P0-Critical — hai nhóm yêu cầu nền tảng phải hoàn thành trước khi triển khai các tính năng phụ trợ.

Kết quả phân tích này tạo cơ sở trực tiếp cho các chương thiết kế tiếp theo: DeviceFSM (FR1.2), Command Pipeline (FR2), GraphQL Schema (tất cả FR), và module NLP Chatbot (FR4). Toàn bộ 35 yêu cầu chức năng và 20 chỉ số phi chức năng đều có thể truy vết ngược về các use case cụ thể trong sơ đồ Use Case Diagram.

Tài Liệu Tham Khảo

[1] IEEE. IEEE Recommended Practice for Software Requirements Specifications (IEEE 830). 1998.

[2] Sommerville, I. Software Engineering, 10th ed. Pearson, 2015.

[3] OWASP. API Security Top 10. 2023. https://owasp.org/API-Security/

[4] AWS. Well-Architected Framework — Serverless Lens. 2023.