Scripts moi (PowerShell admin trên VPS Windows Server):
- setup-sql-db.ps1: tao DB SolutionErp + grant db_owner cho vrapp (user shared voi VIETREPORT). Idempotent.
- setup-iis-sites.ps1: app pool SolutionErp-Api (NoManagedCode + AlwaysRunning + no idle) + 3 site (SolutionErp-Api/Admin/User) voi host header, C:\inetpub\solution-erp\{api,fe-admin,fe-user,logs,uploads}. Placeholder index.html + SPA web.config voi URL rewrite fallback + security headers. Firewall rule. ACL grant AppPool identity Modify. Naming prefix SolutionErp-* tranh conflict VIETREPORT.
- setup-ssl.ps1: download win-acme v2.2.9 → issue cert Let's Encrypt 3 domain (api/admin/user.huypham.vn) qua HTTP-01 challenge + auto install IIS binding + HTTP→HTTPS redirect + scheduled task 90d renew.
- setup-gitea-runner.ps1: download act_runner.exe → register voi Gitea git.baocaogiaoduc.vn, install Windows service, labels windows-latest,self-hosted,windows,x64 (cho phep share voi VIETREPORT).
FE production config:
- fe-admin/.env.production + fe-user/.env.production: VITE_API_BASE_URL=https://api.huypham.vn
- fe-admin/src/lib/api.ts + fe-user/src/lib/api.ts: BASE_URL = (import.meta.env.VITE_API_BASE_URL ?? '') + '/api'
- Dev: empty prefix → /api qua Vite proxy :5443
- Prod: https://api.huypham.vn/api (cross-origin CORS da config AllowedOrigins)
Docs:
- docs/guides/vps-setup.md MOI (master runbook): prereq, 4 script chay theo thu tu, set 5 Gitea secrets, first deploy, appsettings.Production.json pattern (file hoac user-secrets), smoke test 3 curl, post go-live checklist (doi admin password, rotate secrets chat-exposed, backup schedule, disable Swagger prod, monitor logs), table co-existence VIETREPORT
- CLAUDE.md root: add vps-setup.md reference
Gitea repo da setup (extern):
- https://git.baocaogiaoduc.vn/vietreport-admin/solution-erp (private)
- Secrets set via API: IIS_HOST=103.124.94.38, IIS_USER=Administrator, DB_CONNECTION (voi vrapp password), JWT_SECRET placeholder
- CON THIEU: IIS_PASSWORD (Windows admin — user cung cap), JWT_SECRET real value (64-char tu vps-jwt-key.txt — user update qua Gitea UI)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4.7 KiB
4.7 KiB
CLAUDE.md — AI Agent Context
Full content:
docs/CLAUDE.md
SOLUTION_ERP — Hệ thống Quản lý Hợp đồng Nhà cung cấp / Thầu phụ / Tổ đội 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 — 4 file đọc trước tiên
1. docs/STATUS.md ← Snapshot HIỆN TẠI (phase nào, việc gì đang làm)
2. docs/PROJECT-MAP.md ← Bản đồ toàn cảnh (nên đọc đầu dự án)
3. docs/changelog/migration-todos.md ← Atomic tasks theo từng phase
4. docs/workflow-contract.md ← ⭐ State machine 9 phase — ảnh hưởng mọi thiết kế
⚡ 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
IApplicationDbContextinterface (Application layer) - Auth: JWT Bearer + ASP.NET Identity
- DB: SQL Server (LocalDB dev / SQL Server prod), EF Core 10 Code-First migrations
- Error handling:
GlobalExceptionMiddlewaremap 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
>=20trongengines; CI pin20.xqua.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, ...)
- 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
Commit convention
[CLAUDE] <scope>: <imperative message>
Scope: Contract · Form · Workflow · Supplier · Auth · Admin · Api · App · Domain · Infra · FE-Admin · FE-User · Docs · CICD · Scripts
📖 Tài liệu quan trọng
| File | Nội dung |
|---|---|
docs/STATUS.md |
🔥 Current state — đọc đầu tiên |
docs/HANDOFF.md |
Brief 5 phút: session trước làm gì + next tasks |
docs/rules.md |
⭐ Coding conventions (BE Clean Arch, FE React, DB, Git, Docs) |
docs/architecture.md |
⭐ Layered architecture + request lifecycle + deployment |
docs/PROJECT-MAP.md |
Bản đồ tổng quan |
docs/changelog/migration-todos.md |
Roadmap 5 phase + atomic tasks |
docs/CLAUDE.md |
Full context — tech stack chi tiết |
docs/workflow-contract.md |
State machine 9 phase + role matrix |
docs/forms-spec.md |
Catalog 8 form + quy định mã HĐ RG-001 |
docs/database/database-guide.md |
DB conventions + migration workflow + cheatsheet |
docs/database/schema-diagram.md |
⭐ ERD + luồng DB + data flow 19 table |
docs/flows/README.md |
Index 6 flow (auth, permission, contract, form, SLA) |
docs/gotchas.md |
⭐ 26 bẫy đã gặp — đọc trước khi debug tương tự |
.claude/skills/ |
3 skill: contract-workflow, form-engine, permission-matrix |
docs/guides/vps-setup.md |
⭐ Master runbook deploy VPS shared với VIETREPORT |
⚠️ Kết thúc session
- Update
docs/STATUS.md(In Progress→Recently Done) - Tick checklist tương ứng trong
docs/changelog/migration-todos.md - Tạo session log
docs/changelog/sessions/YYYY-MM-DD-HHMM-{topic}.mdnếu đáng ghi - Commit
[CLAUDE] <scope>: <message> - ⚠️ Update
SolutionErp.slnxnếu có.cs/.csprojmới
Bỏ qua nếu chỉ trả lời câu hỏi, không sửa file nào.