Files
solution-erp/docs/CLAUDE.md
pqhuy1987 57e672f71f
Some checks failed
Deploy SOLUTION_ERP / build-deploy (push) Has been cancelled
[CLAUDE] Docs: S179 closeout — va doi STYLE 2 vong (C7 bat 2 MAJOR trong chinh ban va) + H24 9 FLAG + drift-audit thang
SUA-1..6b tron 6/6, acceptance C1-C6b 12/12. Vong-2 sua chinh vong-1 sau reviewer C7 (PASS-WITH-8, 3 MAJOR):
- Doi ba-cham -> hai-cham la REGRESSION co dieu-kien, KHONG phai cosmetic: chi tuong-duong khi origin/main
  con ancestor; cay phan-ky thi hai-cham liet ca file CHI CO tren origin/main (= DA PRODUCTION) vao "phan MOI".
  Thu pham that = git diff mu untracked. Sandbox 2 chieu CONFIRMED.
- git status --porcelain | cut -c4- de path RAC (rename in MOT dong "R old -> new"; path co dau cach bi quote).
  Sandbox: 2/2 MISS; thuoc moi 2/2 OK.
- Thuoc CHOT 4/4 site: { git diff --name-only origin/main...HEAD; git diff --name-only HEAD;
  git ls-files -o --exclude-standard; } | sort -u

Bai: chan-doan sai VAN pass acceptance — acceptance do HINH-DANG chuoi, khong do HANH-VI.

Lop mo-neo TU-VO-HIEU: con-tro so-dong tro vao CHINH tep chua no tu thoi moi lan sua dau tep
(112->118->121 trong 1 phien) => neo TEN, khong neo SO DONG. Ap cho index.css, gotchas.md, PipelineStageFolders.
Con-tro verbatim _mind doi ve commit DA PUSH (ee21056/d081681) — ban truoc tro 727a512 nam trong dai squash
=> tu de con-tro mo-coi.

H24 light-audit 9 FLAG, flush 8 o canonical: Mig 71->72 - Gotchas 86->87 - Tests 644->645 (chay that
dotnet test: 45 Domain + 600 Infra, 0 fail) - user-mem 59->60 - header S168->S179 - roster 23->26 (go han so
theo B1) - HANDOFF dong 4 slot (68)-(71) + E4.

"So noi doi theo huong BI QUAN" x3 ca/1 phien (4 slot - E4 - run.md S173) => leo thang lan 3 phai DO LAI TIEN-DE.

Kem: 2 NO vong-3 - 2 synthesis ORPHAN (run-chua-gom 2->0) - di-tru cua-so 6 vao _context - keo+ap 2 thu
loi-do-luong (BAC Lop 8 CO SO: mtime cum SE 0,7% vs hub 69%) - drift-audit thang PASS_WITH_FLAGS-8 (va 2, con 6)
- _mind 99,67%->84,2% - don 9 dir rong - archive-gate strike 1/2.

#53: 4/4 vai garble return dau, vot tron 4/4 bang resume-in-session. Mat 0 byte.

0 file code nghiep-vu. Build 2/2 app PASS. Test 645/645.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-07 12:25:55 +07:00

162 lines
9.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# CLAUDE.md — Full Context (SOLUTION_ERP)
## 1. Giới thiệu
**SOLUTION_ERP** là hệ thống quản lý Hợp đồng Nhà cung cấp / Thầu phụ / Tổ đội / Dịch vụ + **Phiếu Duyệt NCC tiền-HĐ** cho **Công ty TNHH Xây dựng Solutions**, thay thế quy trình giấy / Word+Excel hiện tại.
**Scope chính:**
1. Số hóa 8 form hợp đồng (template engine điền field → export .docx/.xlsx)
2. Workflow 9 phase trình ký HĐ (state machine + role guard + SLA auto-approve + versioned WF per ContractType)
3. Tự gen mã HĐ theo Quy định SOL-CCM-RG-001
4. Dashboard báo cáo HĐ theo NCC, dự án, trạng thái, giá trị
5. **Module Duyệt NCC (Phase 6-8)** — phiếu trình duyệt so sánh giá tiền-HĐ, 2 quy trình A/B versioned admin-config, kế thừa HĐ 1-click khi DaDuyet, Ý kiến 4 phòng ban sign-off
6. ~~**Module Ngân sách (Phase 7-8)** — 4 bảng quản lý ngân sách dự án, workflow simple 3-step, integration link với Contract & PE + cột "So với ngân sách" PE matrix~~ ⚠️ **REMOVED Mig 50 (S61)** — module Budget cũ (4 bảng Budgets/BudgetDetails/BudgetApprovals/BudgetChangelogs) XÓA, thay bằng **ngân sách per-gói-thầu `PeWorkItemBudgets`** (1 record/cặp Dự án × Hạng mục, nhập theo role PRO/CCM); FE pages/types/menu `Bg_*` gỡ hết.
7. **Test gate (Phase 8)** — xUnit Domain policy + Infra code generator, CI fail-fast no deploy
## 2. Kiến trúc tổng thể
```
┌────────────────┐ ┌────────────────┐
│ fe-admin │ │ fe-user │ React 19 + Vite + TS + shadcn/ui
│ :8082 │ │ :8080 │ TanStack Query, Tailwind
└────────┬───────┘ └────────┬───────┘
│ │
│ Vite proxy /api → :5443
▼ ▼
┌──────────────────────────────────────┐
│ SolutionErp.Api :5443 │ ASP.NET Core 10 + JWT
│ Controllers / Middleware / Swagger │
└──────────────┬───────────────────────┘
┌────────▼─────────┐
│ SolutionErp. │ CQRS + MediatR
│ Application │ FluentValidation + AutoMapper
└────────┬─────────┘
┌────────▼─────────┐ ← SolutionErp.Infrastructure
│ SolutionErp. │ (EF Core, Identity, Repos, External services)
│ Domain │
└──────────────────┘
┌────────────────┐
│ SQL Server │ dbo schema, GUID PK
└────────────────┘
```
## 3. Project layout
```
SOLUTION_ERP/
├── src/Backend/
│ ├── SolutionErp.Domain/ Entities + Enums (Contracts/, PurchaseEvaluations/, Forms/, Identity/, Master/, Notifications/)
│ ├── SolutionErp.Application/ CQRS handlers, DTOs, Validators, Mappings, Interfaces
│ ├── SolutionErp.Infrastructure/ EF DbContext, Identity, Repositories, External services
│ └── SolutionErp.Api/ Controllers, Middleware, Program.cs, appsettings
├── fe-admin/ (admin UI — CRUD master, approve, dashboards, workflow designer, permission matrix)
├── fe-user/ (user UI — soạn HĐ + duyệt phiếu PE + inbox)
├── docs/
│ ├── CLAUDE.md (file này)
│ ├── STATUS.md ⭐ snapshot hiện tại + Recently Done
│ ├── HANDOFF.md ⭐ brief 5 phút cho session tiếp
│ ├── PROJECT-MAP.md bản đồ tổng quan
│ ├── rules.md coding conventions
│ ├── architecture.md layered + PE §9 + Budget §10 + Testing §11
│ ├── gotchas.md pitfall đã gặp (số → docs/STATUS.md)
│ ├── forms-spec.md 8 form catalog + RG-001
│ ├── workflow-contract.md 9 phase HĐ + role matrix
│ ├── database/
│ │ ├── database-guide.md conventions + migration workflow
│ │ └── schema-diagram.md ERD (số bảng → docs/STATUS.md) (+§11 PE +§12 ~~Budget~~ DROP +§13 PEDeptOpinions +§14 Contract V2 LevelOpinions; §16+ Mig 27-62 pending)
│ ├── flows/ 6 sequence diagram (auth/permission/contract/form/sla + PE ref architecture)
│ ├── guides/ setup, cicd, deploy, runbook, security
│ ├── changelog/
│ │ ├── migration-todos.md roadmap compact (Phase 0-5+Tier3 collapsed)
│ │ └── sessions/ session logs YYYY-MM-DD
│ └── _archive/ raw dump Phase 0 (forms-spec-raw, workflow-raw)
├── .claude/skills/ 6 skill: 3 domain (contract-workflow, form-engine, permission-matrix) + 3 ops (dependency-audit-erp, ef-core-migration, iis-deploy-runbook)
├── scripts/ deploy, migrate-domains, backup, deps-audit
├── SolutionErp.slnx Solution file
├── global.json .NET 10 SDK pin
└── CLAUDE.md Pointer → docs/CLAUDE.md
```
## 4. Tech stack chi tiết
| Layer | Tech | Version |
|---|---|---|
| .NET SDK | .NET | 10.0.104 |
| ORM | EF Core | 10 |
| DB | SQL Server | 2019+ (LocalDB dev) |
| API | ASP.NET Core Web API | 10 |
| Mediator | MediatR | latest |
| Validation | FluentValidation | latest |
| Mapping | AutoMapper | latest |
| Auth | JWT Bearer + ASP.NET Identity | 10 |
| Logging | Serilog | latest |
| OpenAPI | Swashbuckle | latest |
| FE Build | Vite | 8 |
| FE Lib | React | 19 (auto-scaffolded) |
| FE Lang | TypeScript | 6 |
| FE Styling | Tailwind CSS + shadcn/ui | Phase 1 install |
| FE Data | TanStack Query | Phase 1 install |
| Node (local) | >= 20 | local có thể Node 22 |
| Node (CI) | **pin 20.x** | bài học từ NamGroup |
## 5. Reference projects
- **NamGroup** (`D:\Dropbox\CONG_VIEC\NAMGROUP\SOURCECODE_CÔNG_TY\NAMGROUP\`) — template 2 FE + IIS deploy + permission matrix
- **DH_Y_DUOC** (`D:\Dropbox\CONG_VIEC\DAI_Y_DUOC\DH_Y_DUOC_SOURCECODE\DH_Y_DUOC\`) — template backend hiện đại (Clean Arch + CQRS + EF migrations)
## 6. Roadmap (status 2026-04-29)
| Phase | Focus | Trạng thái |
|---|---|---|
| **0 Draft** | Scaffold, parse FORM + QUY_TRINH | ✅ Done |
| **1 Alpha Core** | Auth + Permission + CRUD master + Contract draft | ✅ Done |
| **2 Form Engine** | OpenXml + ClosedXML + LibreOffice PDF + DynamicForm | ✅ Done |
| **3 Workflow** | 9 phase state machine + RG-001 code gen + SLA job + attachments + SignalR | ✅ Done |
| **4 Reporting** | Dashboard KPI + Excel export + MyDashboard role-aware | ✅ Done |
| **5 Production** | CI/CD Gitea Actions + 3 IIS site + Let's Encrypt + Security headers + Users CRUD | ✅ Done |
| **Tier 3** | Versioned WF + 3-panel layout + 4-bảng + 4 catalogs + 16 demo users + Brand identity | ✅ Done |
| **6 Module Duyệt NCC** | PE iter 1 (skeleton) + iter 2 (UX polish) + Domain rebrand `.solutions.com.vn` | ✅ Done |
| **7 Budget BE + 14 Solutions users** | Migration 14 — 4 bảng Budget + workflow simple + 11 endpoint + 14 user thật ⚠️ Budget bị **REMOVED Mig 50 (S61)**`PeWorkItemBudgets` | ✅ Done (Session 4) |
| **8 Budget FE + PE feature complete + Tests** | FE Budget 3-panel + PE/HD-Budget integration + PE Workflow Designer + Ý kiến 4 PB (mig 15) + Tests Phase 1-2 (71 test) + CI gate ⚠️ FE Budget (pages/types/menu `Bg_*`) **REMOVED S61** cùng Mig 50 | ✅ Done (Session 5) |
| **9 UAT + Ops + carry over** | UAT thật + SMTP + Rotate creds + SQL backup + Export PDF (pending) + Tests Phase 3-5 | 📝 Active (Session 6) |
| **10+ Post-launch** | E-signature, Bravo/SAP, Mobile, AI OCR | 📝 Future |
Chi tiết atomic tasks: [`changelog/migration-todos.md`](changelog/migration-todos.md).
Session logs: [`changelog/sessions/`](changelog/sessions/).
## 7. Quy ước code
- **Ngôn ngữ UI:** 100% tiếng Việt. Code + comment + tên DB table: **English**.
- **Tên file:** PascalCase cho `.cs`, kebab-case cho TS/TSX (trừ React component = PascalCase).
- **Null safety:** `.NET` bật nullable reference types. TS `strict: true`.
- **Async/await** cho mọi I/O.
- **Error handling BE:** `GlobalExceptionMiddleware` → map exception → ProblemDetails. KHÔNG try-catch ở controller.
- **Error handling FE:** error boundary + toast. Dùng `useErrorHandler` hook.
- **Logging:** Serilog structured. Không `Console.WriteLine`.
## 8. Security baseline
- HTTPS everywhere (IIS redirect HTTP → HTTPS)
- JWT expiry 1h, refresh token 7d
- Password hash: Identity default (PBKDF2)
- CORS: whitelist chỉ 2 FE origin
- Rate limit: 100 req/min/IP cho endpoint auth
- SQL injection: EF Core parameterized (không raw SQL trừ khi cần)
- Audit log: mọi write → `AuditLog` table
## 9. Liên hệ + Production
- **Dev:** pqhuy1987@gmail.com (solo + Claude)
- **Prod login:** `admin@solutions.com.vn` / `Admin@123456` ⚠️ rotate sau login đầu
- **3 domain prod:**
- https://api.solutions.com.vn — API
- https://admin.solutions.com.vn — Admin FE
- https://eoffice.solutions.com.vn — User FE
- **Gitea remote:** https://git.baocaogiaoduc.vn/vietreport-admin/solution-erp
- **SSH VPS:** `ssh vietreport-vps` (config sẵn `~/.ssh/config` user=Administrator key=id_ed25519)
- **Domain expert:** TBD (sẽ update sau UAT đầu tiên)