Session 14 (2026-05-07) docs/skill update:
STATUS.md:
- Last updated + Phase summary count (95→96 test, 20 mig, 57 bảng, 41 gotcha)
- Recently Done row Session 14 chi tiết (3-button + Task 2 in-progress + DesignTime/Runtime DB gotcha)
HANDOFF.md:
- TL;DR Session 14 prepend với 1 commit + Task 2 defer
- 5 cảnh báo Session 15+: TraLai phase orphan / Task 2 sample seed / DesignTime
vs Runtime DB / Budget N-stage defer / schema-diagram §17-19 defer
migration-todos.md: Phase 9 + Session 14 block 4 sub-task done + 2 defer task
Session log NEW `2026-05-07-2500-3-button-workflow.md`:
- Bối cảnh + spec 3-button (Duyệt/Trả lại/Từ chối) + implementation chi tiết
(Domain policy expand + Service tách reject + FE button + dialog warning)
- Tests update (95→96 với +1 NEW Reject_To_TuChoi_Locks_Permanently)
- Task 2 in-progress: DesignTime vs Runtime DB gotcha + API exit 255 sớm
- Plan organization sau S14
Skill ef-core-migration:
- description + heading: 17→20 migration
- Bảng migration history thêm Mig 18-19 (PE) + Mig 20 (Contract)
- Section MỚI "N-stage workflow pattern (Mig 18-20)" — architecture decision
với filtered unique trick + per-module migration packaging guideline
- Phase 8 update: 83→96 test breakdown
Skill contract-workflow:
- Section MỚI "Phase 9+ done (Mig 18-20 — Session 12/13/14)":
* N-stage workflow PE + Contract (entity + filtered unique split + service
refactor + tests + FE Designer + UsersPage cấp + API)
* PE 3-button approval (Duyệt/Trả lại/Từ chối) Session 14
* Defer: Budget N-stage / Phase TraLai=98 orphan
CLAUDE.md root: 16→20 migration + 55→57 bảng + 83→96 test
docs/rules.md §7: Phase 9 active 83→96 test
Verify: dotnet test 96 pass + npm build (skip — pure docs/skill update).
🎉 Session 14 wrap-up complete. Pushed 1 task (3-button) + Task 2 defer.
Cumulative since session start (13h17): 13 commit (1 button removal +
6 PE N-stage Chunk A-F + 5 Contract N-stage Chunk A,B,C,D,F + 1 3-button).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
146 lines
8.9 KiB
Markdown
146 lines
8.9 KiB
Markdown
# CLAUDE.md — AI Agent Context
|
||
|
||
> **Full content:** [`docs/CLAUDE.md`](docs/CLAUDE.md)
|
||
|
||
---
|
||
|
||
**SOLUTION_ERP** — Hệ thống Quản lý Hợp đồng Nhà cung cấp / Thầu phụ / Tổ đội + **Phiếu Duyệt NCC tiền-HĐ** cho Công ty TNHH Xây dựng Solutions.
|
||
|
||
Kiến trúc: **.NET 10 Clean Architecture + 2 React FE (admin + user) + SQL Server + IIS**.
|
||
|
||
## 🚀 BẮT ĐẦU SESSION — 5 file đọc trước tiên
|
||
|
||
```
|
||
1. docs/STATUS.md ← Snapshot HIỆN TẠI (phase nào, việc gì đang làm — PE module CÒN CHỈNH NHIỀU)
|
||
2. docs/HANDOFF.md ← Brief 5 phút: session trước làm gì + cảnh báo session tiếp
|
||
3. docs/PROJECT-MAP.md ← Bản đồ toàn cảnh
|
||
4. docs/changelog/migration-todos.md ← Atomic tasks theo phase (Phase 7 PE refinement mới)
|
||
5. docs/workflow-contract.md ← ⭐ State machine 9 phase HĐ — base pattern cho PE workflow
|
||
```
|
||
|
||
## ⚡ Quick Rules
|
||
|
||
### Backend — `.NET 10` Clean Architecture
|
||
|
||
- Solution: `SolutionErp.slnx` ở root, projects ở `src/Backend/`
|
||
- **4 layer:** `Api → Application ← Domain` + `Infrastructure → Application`
|
||
- Pattern: **CQRS + MediatR**, **FluentValidation**, **AutoMapper**
|
||
- Repository qua `IApplicationDbContext` interface (Application layer)
|
||
- Auth: **JWT Bearer + ASP.NET Identity**
|
||
- DB: **SQL Server** (LocalDB dev / SQL Server prod), **EF Core 10 Code-First migrations**
|
||
- Error handling: `GlobalExceptionMiddleware` map exception → HTTP status
|
||
- Commit scope tech stack: `Api` · `App` · `Domain` · `Infra`
|
||
|
||
### Frontend — 2 app React 18 + Vite + TS + shadcn/ui + TanStack Query
|
||
|
||
- `fe-admin/` (port **8082**) · `fe-user/` (port **8080**)
|
||
- Vite proxy `/api → http://localhost:5443` (SolutionErp.Api)
|
||
- **Named export**, không default export (trừ `App`)
|
||
- shadcn/ui copy-paste, **duplicate giữa 2 app là CÓ CHỦ ĐÍCH** (mỗi app UX riêng)
|
||
- Auth context: `solution-erp-admin-token` / `solution-erp-user-token` ở `localStorage`
|
||
- TanStack Query cho data fetching
|
||
- **Node pin `>=20`** trong `engines`; CI pin `20.x` qua `.nvmrc` (bài học NamGroup — KHÔNG dùng Node latest trên CI)
|
||
- UI **100% tiếng Việt**
|
||
|
||
### Database conventions
|
||
|
||
- Schema: `dbo` (single schema)
|
||
- Table: **PascalCase tiếng Anh** (Contracts, Suppliers, Projects, ContractApprovals, PurchaseEvaluations, ...)
|
||
- PK: `Id` (Guid), FK: `{Entity}Id`
|
||
- Audit fields: `CreatedAt`, `UpdatedAt`, `CreatedBy`, `UpdatedBy` (`BaseEntity`)
|
||
- Soft delete: `IsDeleted`, `DeletedAt`, `DeletedBy` (`AuditableEntity`)
|
||
- Migrations: `dotnet ef migrations add <Name> --project src/Backend/SolutionErp.Infrastructure --startup-project src/Backend/SolutionErp.Api`
|
||
- **Hiện có 20 migration → 57 bảng** (Phase 9+ — Mig 18 `AddPeWorkflowInnerStepsAndPositionLevel` + Mig 19 `AlterPeDeptApprovalsUniqueFilteredForInnerSteps` + Mig 20 `AddContractWorkflowInnerStepsAndAlterDeptApprovalUnique`. N-stage workflow approval Phòng × PositionLevel cấu hình động per WorkflowStep cha. Mỗi inner step = 1 cấp duyệt sequential. Backward compat 100% với 2-stage Mig 16 qua filtered unique. PE 3-button Duyệt/Trả lại/Từ chối)
|
||
|
||
### Modules
|
||
|
||
| Module | Namespace | Migration | Trạng thái |
|
||
|---|---|---|---|
|
||
| Contract (HĐ) | `Domain/Contracts/` | 1-11 | Feature-complete (7 ContractType × 9 phase) |
|
||
| PurchaseEvaluation (Duyệt NCC tiền-HĐ) | `Domain/PurchaseEvaluations/` | 12, 13, 15 | Feature-complete — chỉ Export PDF còn pending (không quan trọng) |
|
||
| Budget (Ngân sách dự án) | `Domain/Budgets/` | 14 | **Feature-complete** — BE + FE 3-panel + integration với PE/HD |
|
||
| Master (Supplier/Project/Department) | `Domain/Master/` | 2, 10 | Feature-complete |
|
||
| Identity (User/Role/Permission/MenuItem) | `Domain/Identity/` | 1, 3, 11 | Feature-complete (30 demo user — 16 sample + 14 Solutions thật) |
|
||
| Forms (Template + Clause) | `Domain/Forms/` | 4 | Feature-complete |
|
||
| Notifications | `Domain/Notifications/` | 6 | In-app + SignalR OK, email SMTP TODO |
|
||
| **Tests** | `tests/SolutionErp.{Domain,Infrastructure}.Tests/` | — | **83 test pass** (54 Domain + 29 Infra: 17 codegen + 6 PE WF + 6 PE 2-stage approval) — CI gate + path filter docs-only skip |
|
||
|
||
### Commit convention
|
||
|
||
```
|
||
[CLAUDE] <scope>: <imperative message>
|
||
```
|
||
|
||
**Scope:** `Contract` · `PurchaseEvaluation` · `Budget` · `Form` · `Workflow` · `Supplier` · `Auth` · `Admin` · `Api` · `App` · `Domain` · `Infra` · `FE-Admin` · `FE-User` · `Tests` · `Docs` · `CICD` · `Scripts` · `Skill`
|
||
|
||
## 🧪 Tests (Phase 9 — Session 9 +6)
|
||
|
||
```
|
||
tests/
|
||
├── SolutionErp.Domain.Tests/ (54 test - Phase 1: WorkflowPolicy / PEPolicy / BudgetPolicy)
|
||
└── SolutionErp.Infrastructure.Tests/ (17 + 6 + 6 = 29 test)
|
||
├── Common/ (SqliteDbFixture + TestApplicationDbContext + IdentityFixture S9)
|
||
├── Services/ (17 codegen + 6 PE 2-stage approval S9)
|
||
└── Application/ (6 test - PeWorkflowDefinition versioning)
|
||
```
|
||
|
||
**96 unit test pass** / ~3s (54 Domain + 42 Infra: 17 codegen + 6 PE WF + 6 PE 2-stage + 6 PE N-stage S12 + 6 Contract N-stage S13 + 1 PE Reject Từ chối S14). CI gate + path filter live.
|
||
|
||
```bash
|
||
dotnet test SolutionErp.slnx # chạy cả 2 test project
|
||
```
|
||
|
||
**Quy tắc timing test:** feature mới = test-after (UAT ổn → viết). Bug fix = test-before BẮT BUỘC (reproduce → fix). Critical algorithm (codegen/guard/financial/security) = test-before merge. Spec change = update test cũ + code chung commit. Skip: DTO mapping, CRUD master, FE snapshot. Detail `docs/rules.md §7`.
|
||
|
||
### CI/CD pipeline (3 fix lớn 29/04)
|
||
|
||
- ✅ Manual checkout bypass github.com (fix gotcha #39 TCP timeout)
|
||
- ✅ Path filter docs-only skip — `paths-ignore` (gotcha #41)
|
||
- ⏸️ npm cache (gotcha #40 — failed, rolled back)
|
||
|
||
**Tốc độ:** code commit ~3 phút / docs-only commit **0s** (skip).
|
||
|
||
## 🛠️ Skills (.claude/skills/) — 6 skill PHẢI dùng khi task khớp
|
||
|
||
| Domain (3) | Ops (3) |
|
||
|---|---|
|
||
| `contract-workflow` — state machine + versioned WF | `dependency-audit-erp` — npm/dotnet CVE scan |
|
||
| `form-engine` — render docx/xlsx + PDF | `ef-core-migration` — EF migration + 3-file rule |
|
||
| `permission-matrix` — role × menu × CRUD | `iis-deploy-runbook` — 3 site IIS + win-acme + runner |
|
||
|
||
**Audit định kỳ:** đầu mỗi tháng — combined skill + doc drift audit theo `docs/rules.md §6.4 + §9.4`. Cron `solution-erp-skill-audit-monthly` fire 9:00 ngày 1. Lần kế: **2026-05-01**.
|
||
|
||
Quy tắc:
|
||
- KHÔNG bulk-clone repo skill 3rd party. Chỉ thêm skill PROJECT-SPECIFIC. Xem `docs/rules.md §9` đầy đủ.
|
||
- KHÔNG rewrite toàn bộ MD định kỳ. Chỉ compact + patch drift. Xem `docs/rules.md §6.4` đầy đủ.
|
||
|
||
## 📖 Tài liệu quan trọng
|
||
|
||
| File | Nội dung |
|
||
|---|---|
|
||
| [`docs/STATUS.md`](docs/STATUS.md) | **🔥 Current state** — đọc đầu tiên |
|
||
| [`docs/HANDOFF.md`](docs/HANDOFF.md) | Brief 5 phút: session trước làm gì + next tasks |
|
||
| [`docs/rules.md`](docs/rules.md) | ⭐ Coding conventions (BE Clean Arch, FE React, DB, Git, Docs) |
|
||
| [`docs/architecture.md`](docs/architecture.md) | ⭐ Layered architecture + request lifecycle + deployment |
|
||
| [`docs/PROJECT-MAP.md`](docs/PROJECT-MAP.md) | Bản đồ tổng quan |
|
||
| [`docs/changelog/migration-todos.md`](docs/changelog/migration-todos.md) | Roadmap 5 phase + atomic tasks |
|
||
| [`docs/CLAUDE.md`](docs/CLAUDE.md) | Full context — tech stack chi tiết |
|
||
| [`docs/workflow-contract.md`](docs/workflow-contract.md) | State machine 9 phase HĐ + role matrix |
|
||
| [`docs/forms-spec.md`](docs/forms-spec.md) | Catalog 8 form + quy định mã HĐ RG-001 |
|
||
| [`docs/database/database-guide.md`](docs/database/database-guide.md) | DB conventions + migration workflow + cheatsheet |
|
||
| [`docs/database/schema-diagram.md`](docs/database/schema-diagram.md) | ⭐ ERD + luồng DB + data flow 52 table (+ §11 PE module + §12 Budget module + §13 PEDeptOpinions) |
|
||
| [`docs/flows/README.md`](docs/flows/README.md) | Index 6 flow (auth, permission, contract, form, SLA) |
|
||
| [`docs/gotchas.md`](docs/gotchas.md) | ⭐ 26 bẫy đã gặp — đọc trước khi debug tương tự |
|
||
| [`.claude/skills/`](.claude/skills/README.md) | 6 skill: contract-workflow, form-engine, permission-matrix, dependency-audit-erp, ef-core-migration, iis-deploy-runbook |
|
||
| [`docs/guides/vps-setup.md`](docs/guides/vps-setup.md) | ⭐ Master runbook deploy VPS shared với VIETREPORT |
|
||
|
||
## ⚠️ Kết thúc session
|
||
|
||
1. Update `docs/STATUS.md` (`In Progress` → `Recently Done`)
|
||
2. Tick checklist tương ứng trong `docs/changelog/migration-todos.md`
|
||
3. Tạo session log `docs/changelog/sessions/YYYY-MM-DD-HHMM-{topic}.md` nếu đáng ghi
|
||
4. Commit `[CLAUDE] <scope>: <message>`
|
||
5. ⚠️ **Update `SolutionErp.slnx`** nếu có `.cs/.csproj` mới
|
||
|
||
> Bỏ qua nếu chỉ trả lời câu hỏi, không sửa file nào.
|