# Flows — SOLUTION_ERP

> Document các luồng (process / sequence) chính của hệ thống. Mỗi flow có mermaid sequence diagram + API calls + side effects + edge case.

## Index

| Flow | Phase | Trạng thái | Doc |
|---|---|---|---|
| **Authentication** — login, refresh, logout, /me | 1 | ✅ Implemented | [`auth-flow.md`](auth-flow.md) |
| **Permission resolution** — resolve menu + CRUD cho user (inherit Contracts/Workflows/PurchaseEvaluations/PeWorkflows roots) | 1 | ✅ Implemented | [`permission-flow.md`](permission-flow.md) |
| **Contract creation** — tạo HĐ draft + fill form template + 7 per-type Details | 2-3 | ✅ Implemented | [`contract-creation-flow.md`](contract-creation-flow.md) |
| **Contract approval** — state machine 9 phase + versioned workflow per ContractType | 3 | ✅ Implemented | [`contract-approval-flow.md`](contract-approval-flow.md) |
| **Form render** — template engine OpenXml/ClosedXML + LibreOffice PDF | 2 | ✅ Implemented | [`form-render-flow.md`](form-render-flow.md) |
| **SLA expiry auto-approve** — hosted service 15-min check + warning 20% | 3 | ✅ Implemented | [`sla-expiry-flow.md`](sla-expiry-flow.md) |
| **Purchase Evaluation** — phiếu duyệt NCC tiền-HĐ + kế thừa HĐ | 6 | ✅ Implemented (UX iter 2) | (xem `architecture.md §9` + `database/schema-diagram.md §11`) |

## Quy ước đọc

- **Actor:** vai trò khi thực hiện (user role hoặc system)
- **Entry point:** ai/gì trigger
- **API calls:** controller + endpoint (hoặc internal service)
- **Side effects:** DB writes, file writes, notifications
- **Edge cases:** các path lỗi / alternate

Tất cả mermaid sequence/state/flowchart có thể render ở VS Code (extension Markdown Preview Mermaid), GitHub, Gitea, Gitea MD preview.

## Liên quan

- [`../workflow-contract.md`](../workflow-contract.md) — spec 9 phase + role matrix (domain-centric)
- [`../forms-spec.md`](../forms-spec.md) — 8 form + mã HĐ format
- [`../database/database-guide.md`](../database/database-guide.md) — schema chi tiết
