[CLAUDE] Phase1: foundation - BE Clean Arch + Identity + JWT + 2 FE React + login E2E

Backend (.NET 10):
- Domain: BaseEntity/AuditableEntity, ContractType/Phase/ApprovalDecision enums, User/Role (Identity<Guid>), AppRoles (12 const)
- Application: IApplicationDbContext/ICurrentUser/IDateTime/IJwtTokenService, custom exceptions, ValidationBehavior (MediatR pipeline), Auth CQRS (Login/Refresh/Me), DependencyInjection
- Infrastructure: ApplicationDbContext (IdentityDbContext), AuditingInterceptor (auto audit + soft delete), DbInitializer (seed 12 role + admin), DesignTimeDbContextFactory, JwtTokenService, DateTimeService, DI
- Api: CurrentUserService, GlobalExceptionMiddleware (ProblemDetails), AuthController, Program.cs rewrite (Serilog + JWT + CORS + Swagger), appsettings + launchSettings (port 5443)
- Migration Init applied to SolutionErp_Dev LocalDB

Frontend (React 19 + Vite 8 + Tailwind 4):
- fe-admin (:8082 blue) + fe-user (:8080 emerald) - shared structure, khac menu + brand color
- Tailwind 4 via @tailwindcss/vite plugin, theme brand colors
- AuthContext (localStorage token), ProtectedRoute, Layout (sidebar + header)
- UI kit: Button/Input/Label (CVA + Tailwind)
- LoginPage voi toast error, DashboardPage/InboxPage placeholder
- Axios interceptor: auto Bearer + 401 redirect
- TanStack Query client, React Router 7, Sonner toast

Package downgrades (do .NET 10 / TS 6 compat):
- MediatR 14 -> 12.4.1 (v14 breaking changes)
- Swashbuckle 10 -> 6.9.0 (v10 khong tuong thich OpenApi 2)
- Removed Microsoft.AspNetCore.OpenApi (conflict voi Swashbuckle)

E2E verified: POST /api/auth/login qua Vite proxy ca 2 FE -> JWT + user info

Credentials seed: admin@solutionerp.local / Admin@123456

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-04-21 10:59:44 +07:00
parent 25dad7f36f
commit 702411fcc8
85 changed files with 10326 additions and 964 deletions

View File

@ -2,54 +2,75 @@
> **Update rule:** trước khi bắt đầu 1 task → ghi row vào `🔥 In Progress`. Xong → chuyển sang `✅ Recently Done`.
**Last updated:** 2026-04-21
**Last updated:** 2026-04-21 11:00
## 📍 Phase hiện tại: **Phase 0Draft Scaffold** (in progress)
## 📍 Phase hiện tại: **Phase 1Alpha Core** (foundation xong, chờ đợt 2)
## 🔥 In Progress
| Ai | Task | Bắt đầu |
|---|---|---|
| Claude | Hoàn tất Phase 0 — docs + git init | 2026-04-21 |
_(không có — Phase 1 foundation xong, chờ quyết định bước tiếp)_
## ✅ Recently Done (newest on top)
| Ngày | Ai | Task | Commit |
|---|---|---|---|
| 2026-04-21 | Claude | Parse QUY_TRINH → `workflow-contract.md` (9 phase state machine + role matrix) | — |
| 2026-04-21 | Claude | Parse 8 FORM → `forms-spec.md` (catalog + RG-001 code format) | — |
| 2026-04-21 | Claude | Scaffold 2 React + Vite apps (fe-admin :8082, fe-user :8080) + proxy config + Node engines pin | — |
| 2026-04-21 | Claude | Scaffold .NET 10 solution + 4 project (Domain/Application/Infrastructure/Api) + references + packages | — |
| 2026-04-21 | Claude | Tạo cấu trúc thư mục `SOLUTION_ERP/` + MEMORY.md | — |
| 2026-04-21 | Claude | **Phase 1 foundation HOÀN TẤT** — BE (Clean Arch + Identity + JWT + migration) + FE (2 app, Tailwind 4, Router, AuthContext, Login) — E2E login pass qua Vite proxy | (chưa commit, sắp xong) |
| 2026-04-21 | Claude | **Phase 0 HOÀN TẤT** — scaffold + parse FORM/QUY_TRINH + docs + skills + git init | `25dad7f` |
## 🎯 Next up (Phase 0 còn lại)
Session logs:
- [`changelog/sessions/2026-04-21-1045-phase0-scaffold.md`](changelog/sessions/2026-04-21-1045-phase0-scaffold.md)
- [`changelog/sessions/2026-04-21-1100-phase1-foundation.md`](changelog/sessions/2026-04-21-1100-phase1-foundation.md)
- [ ] Tạo file root: `.gitignore`, `README.md`, `global.json`, `docker-compose.yml`
- [ ] Tạo 3 skill folder placeholders (`contract-workflow`, `form-engine`, `permission-matrix`)
- [ ] `git init` + commit đầu tiên `[CLAUDE] Scaffold: khởi tạo SOLUTION_ERP Phase 0`
- [ ] Set Gitea remote (khi user cấp URL)
## 🎯 Next up — Phase 1 đợt 2 (CRUD master + Permission Matrix)
## 📋 Phase 1 — Alpha Core (sắp tới)
### Backend
- [ ] `Domain/Entities/Supplier`, `Project`, `Department` (+ EF configurations)
- [ ] `Application/Suppliers/{Commands,Queries}/*` (Create, Update, Delete, GetById, List)
- [ ] Tương tự cho Project + Department
- [ ] `Api/Controllers/{SuppliersController, ProjectsController, DepartmentsController}`
- [ ] Pagination, search, sort server-side (`GetListQuery` với `PagedResult<T>`)
- [ ] Migration 2: `AddMasterData`
Xem chi tiết ở [`changelog/migration-todos.md`](changelog/migration-todos.md) section **Phase 1**.
### Permission Matrix
- [ ] `Domain/Entities/MenuItem`, `Permission`
- [ ] Seed default menu tree (based on FE screens)
- [ ] `Application/Permissions/Queries/GetMyMenuTreeQuery`
- [ ] `Api/Controllers/{MenusController, RolesController, PermissionsController}`
- [ ] Admin UI: Permission Matrix grid (role × menu × CRUD checkbox)
Summary:
1. Install Tailwind + shadcn/ui cho 2 FE + setup `BrandingProvider`
2. Tạo `BaseEntity`, `AuditableEntity`, `ApplicationDbContext`, migration đầu tiên
3. ASP.NET Identity + JWT endpoint (login, refresh, logout, seed admin)
4. Permission Matrix (Role × MenuKey × CRUD) — copy pattern từ NamGroup skill
5. CRUD Supplier + Project + Contract (draft only, chưa workflow)
6. FE admin: login page + layout + permission guard + 3 CRUD page
7. FE user: login + layout + list HĐ của tôi
### Contract draft (chưa workflow)
- [ ] `Domain/Entities/Contract` skeleton (không state machine)
- [ ] Basic CRUD controller + FE list page
### FE
- [ ] `<PermissionGuard menuKey="Contracts">` + `usePermission()` hook
- [ ] 3 trang CRUD admin (Suppliers / Projects / Departments) với table + modal
- [ ] Route guard theo role (admin-only routes)
## 📊 Thông số sau Phase 1 foundation
- **Backend LOC:** ~400 (Domain 60 + Application 170 + Infrastructure 190 + Api 120)
- **Frontend LOC:** ~450 mỗi app (shared 90%)
- **Build time:** .NET ~4s, FE TS check ~3s mỗi app, Vite dev ~3s ready
- **E2E verified:** Login (fe-admin proxy + fe-user proxy) → API → JWT + user info + /me
## 🚨 Blockers / risks
- **Gitea remote** chưa có URL — chờ user cấp để push code
- **3 file `.doc`** (FO-002.02, .03, .06) không parse được bằng python-docx — cần Word COM hoặc LibreOffice ở Phase 2
- **Node 22 local vs 20 CI** — phải test CI sớm (Phase 5) để tránh surprise
- **Gitea remote** chưa có URL — push sau
- ⚠️ **Swashbuckle 10.x** không tương thích với .NET 10 + Microsoft.OpenApi 2.0 — đã downgrade về 6.9.0. Theo dõi update sau.
- ⚠️ **MediatR 14.x** breaking changes — đã downgrade về 12.4.1. Ok cho Phase 1-5.
- ⚠️ **Microsoft.AspNetCore.OpenApi** đã remove (conflict Swashbuckle 6.9). Nếu sau muốn dùng built-in OpenAPI thì phải chọn 1 trong 2.
- ⚠️ **Design-time DB (`SolutionErp_Design`)** được tạo khi chạy `dotnet ef` — có thể drop an toàn (không chứa data thật)
- ⚠️ **3 file `.doc` FORM** chưa convert được — Phase 2
## 📊 Thông số
## Credentials mặc định
- LOC: ~0 (scaffold chỉ)
- Build time: ~10s (.NET)
- Test coverage: 0% (chưa có test)
```
Email: admin@solutionerp.local
Password: Admin@123456
```
URLs dev:
- API: http://localhost:5443 — Swagger ở `/swagger`
- Admin FE: http://localhost:8082
- User FE: http://localhost:8080