Project Checklist — Tổng thể Cập nhật: 22/07/2026

Project Checklist

Toàn bộ hạng mục của dự án ERP/MES — từ planning đến production. Cập nhật theo tiến độ thực tế.

Tiến độ tổng thể theo nhóm
Planning & Docs 100%
Source & CI/CD 80%
Seed Engine 100%
Domain Layer 100%
Application Layer 100%
Infrastructure Layer 100%
API Layer 100%
Testing 100%
Frontend 100%
Deployment 65%
Hoàn thành
Đang làm / Một phần
Chưa làm
Planning & Architecture 100% Hoàn thành
Kiến trúc tổng thể — Composable Architecture docs
ISA-95, CQRS/ES, Event-Driven, Tech Stack, Roadmap 3 phases → erp-mes-architecture.html
Database Design — Event Store + Read Models docs
PostgreSQL DDL, Sensor OEE range-partitioned tables, Redis cache strategy → erp-mes-database.html
Domain Events Catalog — 22 Bounded Contexts docs
Commands, Domain Events, Queries, Sagas cho tất cả 22 BC từ Production đến Sensor OEE → erp-mes-domain-events.html
Industry Seed Engine — 4 ngành done
Jewelry, Cement, Steel, Footwear · ~170 records/ngành · CLI runner → scripts/seed.js
Production BC — DDD Design + C# Code partial
Aggregate, Value Objects, Domain Events, CQRS Handlers → src/Core/Production/
Source Management & CI/CD 80% — Đang hoàn thiện
Platform đã chọn: GitHub + GitHub Actions
GitHub Free (private repos) · GitHub Actions 2,000 phút/tháng miễn phí · GHCR cho container registry
.gitignore, README.md, .env.example done
Cấu hình cơ bản cho .NET 9 + Node.js project
CI Pipeline — GitHub Actions done
.github/workflows/ci.yml · Build, Unit Tests, Architecture Tests (NetArchTest), Integration Tests (Testcontainers), Security Scan (Trivy)
CD Pipeline — Docker Build & Deploy done
.github/workflows/cd.yml · Build Docker image, push GHCR, deploy staging (auto), deploy production (tag + manual approval)
PR Template done
.github/PULL_REQUEST_TEMPLATE.md
Tạo GitHub Repository thật sự
Push code lên GitHub, setup branch protection rules cho main, add collaborators
GitHub Secrets configuration
Add secrets: STAGING_HOST, STAGING_USER, STAGING_SSH_KEY, PROD_HOST, PROD_USER, PROD_SSH_KEY vào GitHub repo settings
GitHub Environments setup
Tạo environments "staging" và "production" với approval rules cho production
Branch protection rules
Require PR review, require CI pass trước khi merge vào main, disable force push
Domain Layer — src/Core/ 100% — 22 Bounded Contexts done ✅
Shared base classes done
AggregateRoot<TId>, DomainEvent, IRepository<T,TId>
Production — ProductionOrder Aggregate done
7 commands, Event Sourcing Apply(), 8 Domain Events, 6 Value Objects, Business Rules enforcement
Quality — QualityInspection Aggregate done
Inspection lifecycle, NCR (NonConformance) sub-entity, verdict logic, InspectionResult value objects
Maintenance — MaintenanceWorkOrder Aggregate done
Work order lifecycle, Asset value object, PM/CM/PdM type distinctions
Inventory / Finance / Auth/IAM / BOM / Planning done
Đầy đủ Aggregate + Value Objects + Domain Events + strongly-typed IDs. Snapshots cho InventoryItem.
Approval / Notification / Traceability / CAPA / Shift / Master Data / Documents done
Procurement / ECO / Calibration / Predictive Analytics / Sensor OEE done
ECO + Calibration ES full lifecycle. Predictive Analytics + Sensor OEE query-side (không ES). OeeFormulas.cs pure helper tại Application layer.
Application Layer — src/Application/ 100% — Tất cả 22 BCs + OeeFormulas + Reporting ✅
CQRS interfaces: ICommand, IQuery, ICommandHandler, IQueryHandler done
Production Commands: Create, Release, Start, RecordOutput, Pause, Resume, Complete, Cancel done
Production Queries: GetById, List done
Quality / Maintenance / Inventory / Finance Commands + Queries done
BOM / Planning / Approval / Notification / Traceability / CAPA / Shift Commands + Queries done
Reporting Engine / OEE / Master Data / Documents / Procurement / ECO / Calibration / Predictive Analytics / Sensor OEE done
OeeFormulas.cs pure static helper (A/P/Q/Total/ShiftWindow) — testable without DB · Reporting query-side với Redis cache
Event Handlers / Projection updaters done
ProductionOrderProjection trong Infrastructure layer — Kafka consumer cập nhật Read Model
Handler wiring — DI (không dùng MediatR) done
Direct DI registration trong ServiceCollectionExtensions.cs. Đơn giản, không phụ thuộc thêm package
Infrastructure Layer — src/Infrastructure/ 100% — 22 BCs + Sensor OEE + Migrations 001-022 ✅
PostgreSQL Event Store Repository done
PostgresProductionOrderRepository: load events → reconstitute, save với optimistic locking, Outbox trong cùng transaction
Outbox Pattern Implementation done
OutboxPublisher BackgroundService: poll 500ms → publish Kafka → UPDATE status. Retry 5 lần trước khi FAILED
Kafka Producer + Consumer setup done
Confluent.Kafka producer (idempotent), consumer group per projection. Headers: event-type cho routing
Production Projection — Kafka → Read Model done
ProductionOrderProjection: xử lý 8 event types, UPDATE production_orders table, idempotent (ON CONFLICT DO NOTHING)
PostgreSQL Read Repository done
PostgresProductionOrderReadRepository: GetById + List với filter status/date. JOIN machine_types + users
Database Migration SQL done
deploy/migrations/001_init_event_store.sql: events, snapshots, outbox, production_orders với indexes đầy đủ
Dependency Injection wiring done
DependencyInjection.cs: register tất cả repositories, producers, background services
Read Model Projections: quality, maintenance done
Read Model Projections: tất cả 15 topics done
Inventory / Finance / BOM / Planning / Approval / Notification / Traceability / CAPA / Shift / Procurement / ECO / Calibration. Tất cả kế thừa KafkaProjectionBase (seek-retry 5× → DLQ projection_failures)
Redis Cache Layer
IDistributedCache (StackExchange.Redis) + IAppCache. Short-TTL: oee:live:{tenant} (5s), reports:ops-dashboard:{tenant} (15s) via CachingReportingReadRepository. Fail-open nếu Redis lỗi. Config: Redis:Cache:*
Database Migrations — SQL thuần (001-022) done
deploy/migrations/: 22 files từ event store → sensor OEE range-partitioned tables. Migration runner trong docker-compose.prod.yml (idempotent psql).
Sensor OEE Data Writer done
Ingest telemetry vào sensor_readings + machine_uptime_events (Postgres range-partitioned); OEE A×P×Q snapshot qua OeeFormulas.cs
API Layer — src/Api/ 100% — 190+ endpoints · SignalR hubs · Rate limiting ✅
ASP.NET Core 9 Minimal API setup done
Program.cs: DI wiring, middleware pipeline, endpoint routing
JWT Authentication + Tenant middleware done
Bearer token validation, tenant_id từ JWT claim hoặc X-Tenant-Id header
Production Order endpoints (10 endpoints) done
Create, Release, Start, RecordOutput, Pause, Resume, Complete, Cancel, GetById, List
Quality endpoints (9) + Maintenance endpoints (9) done
Inspections, NCR flow, work orders, breakdown reporting
Global error handling — Problem Details done
ExceptionHandlingMiddleware: DomainException→422, NotFoundException→404, ArgumentException→400
OpenAPI + Scalar API Explorer done
Scalar UI tại /scalar/v1, JSON spec tại /openapi/v1.json
Health check endpoint done
/health — check PostgreSQL + Redis connectivity, JSON response
Inventory (8) · Finance (8) · Auth (10) · BOM (9) · Planning (10) · Approval (11) · Notification (7) done
Traceability · CAPA · Shift · Reports · OEE · Master Data · Documents · Procurement (12) · ECO (9) · Calibration (7) · Analytics (4) · Sensors done
SignalR real-time hubs done
/hubs/notifications (inbox push) · /hubs/oee (Andon broadcast mỗi 5s, Redis cache 5s TTL)
Bounded Contexts — 22 BCs 22/22 BC done ✅
Production BC done
ProductionOrder aggregate · 8 events · 10 endpoints · 20 unit tests · Event Store + Projection
Quality BC done
QualityInspection + NCR · 7 events · 9 endpoints · 12 unit tests
Maintenance BC done
WorkOrder PM/CM/PdM · AssetBreakdownReported · 7 events · 9 endpoints · 11 unit tests
Inventory BC done
InventoryItem · Receive/Deduct/Reserve/Release/Adjust · LowStockAlert · 8 endpoints · 8 unit tests · stock_levels + stock_movements
Finance BC done
CostEntry Post/Reverse · ProductionCost Calculate · Variance · 8 endpoints · 9 unit tests · cost_entries + production_costs
Auth / IAM done
User state store · Register/Login JWT · RBAC 7 roles · PBKDF2 600k · Refresh token 14d rotation + reuse detection (migration 016) · 10 endpoints · users table
BOM BC done
BillOfMaterials Draft→Active→Obsolete · multi-level explode · ScrapPercent · versioning per product · 9 endpoints · 10 unit tests · bills_of_materials + bom_components
Planning / MRP-lite BC done
ProductionPlan Draft→Released→Closed · RunMrp (BOM explode × Inventory) → Shortage · Dispatch list · 10 endpoints · 10 unit tests
Notification BC · Traceability BC · CAPA BC · Shift Management BC done
Notification: inbox ES + SignalR push · Traceability: lot genealogy forward/backward · CAPA: 7-state lifecycle · Shift: Morning/Afternoon/Night + supervisor + handover
Reporting Engine · OEE Live Andon · Master Data · Documents · Predictive Analytics (query-side) done
Reporting: 6 query types + CSV export + Redis cache · OEE: A×P×Q Andon board SignalR 5s · Master Data: Product/Machine/Employee/Supplier · Documents: SOP/WI/Drawing/Cert lifecycle · Analytics: equipment health + stock shortage + quality risk scores
Procurement BC done
PurchaseOrder ES · Draft→PendingApproval→Approved→(Partial)Received→Closed · Inventory hooks 2 chiều (ReceiveGoods→ReceiveStock; LowStockAlert→auto draft PO) · 12 endpoints · 17 unit tests · migration 018
ECO BC done
EcoRequest Draft→Submitted→Approved(→Implemented auto)|Rejected|Cancelled · ChangeLines AddMaterial/RemoveMaterial/ModifySpec · IEcoBomActivationHook → auto BOM revision · 9 endpoints · migration 020
Calibration BC done
CalibrationRecord Scheduled→InProgress→Passed|Failed|Cancelled · Internal/External/Verification types · nextDueDate > scheduledDate validation · 7 endpoints · migration 021
Sensor OEE (query-side, Postgres range-partitioned) done
sensor_readings + machine_uptime_events + oee_daily_snapshots (partitioned by month, migration 022) · OeeFormulas.cs pure static A/P/Q/Total/ShiftWindow · 35 unit tests · 1 smoke integration test
Approval Workflow Module Matrix + Request + SLA + Delegation + BC hooks ✅
Approval Matrix — cấu hình qua API done
EntityType + RoutingType + Approvers + SlaHours · 1 Active / entity / tenant
ApprovalRequest Aggregate — Event Sourced done
Sequential + Parallel + AnyOf · 8 Domain Events · audit trail · 11 endpoints · 11 unit tests
SLA Engine + Escalation done
DueAt theo SlaHours · EscalateOverdue command khi quá hạn
Delegation có thời hạn done
Ủy quyền 1 lần · ValidUntil · không re-delegate
Integration hooks với BC khác done
IApprovalAutoSubmit: Release ProductionOrder → matrix ProductionOrder; Disposition NCR → NcrDisposition. Thiếu matrix → no-op (BC vẫn succeed).
Tính năng cốt lõi còn thiếu — Phát hiện mới Tất cả done — chỉ còn AI/ML Phase 3
🔴 BOM — Bill of Materials done
Đa cấp · versioning Draft→Active→Obsolete · explode + scrap · 9 endpoints · 10 unit tests · bills_of_materials + bom_components
🔴 Production Planning / MRP-lite done
ProductionPlan · RunMrp (BOM explode + inventory shortage) · Dispatch list · 10 endpoints · 10 unit tests
🔴 Notification System — Centralized done
Inbox ES · SignalR hub · Email/Push stubs · Publish/Read/Dismiss · 7 endpoints · 6 unit tests
🟡 Traceability Engine done
TraceabilityLot Open→Issued→Closed · IssueToOrder · LinkParent (genealogy) · TraceBackward / TraceForward · traceability_lots + lot_links · API /api/v1/traceability/lots
🟡 Reporting Engine done
Daily Production · Quality Summary · Maintenance History · OEE · Ops dashboard · CSV export. API /api/v1/reports + FE /reports.
🟡 OEE Dashboard — Real-time done
Andon board plant/line/machine · SignalR /hubs/oee push mỗi 5s · API /api/v1/oee/live + FE /oee. Sensor/Timescale vẫn future.
🟡 Shift Management done
Schedule · Assign supervisor · Target · Start → Handover → Close. API /api/v1/shifts + FE /shifts.
🟡 CAPA — Corrective & Preventive Action done
Open → Investigate → ActionPlan → InProgress → Verify → Closed. API /api/v1/capa + FE screen.
🟡 Master Data Management done
Product · Machine · Employee · Supplier CRUD (state store). API /api/v1/master-data + FE /master-data.
🟡 Procurement / Purchase Module done 17/07
PurchaseOrder aggregate (ES): Draft → PendingApproval → Approved → PartiallyReceived → Received → Closed · Rejected · Cancelled. Lines nội bộ aggregate, partial receipt per line, chống over-receipt/duplicate material. PO number PO-{year}-{seq} durable. 12 endpoints /api/v1/procurement/purchase-orders · topic procurement.events · migration 018 · 17 unit tests. Inventory hooks 2 chiều (done 18/07, verified live): ① ReceiveGoods → auto ReceiveStock (movement ref PO {số}) · ② LowStockAlert → auto draft PO supplier TBD, qty = max(2×reorder − available, reorder), dedup theo PO mở chứa material. FE /procurement (done 20/07): tạo PO, quản lý lines, submit/approve/reject, nhận hàng từng phần per line, lịch sử receipts, close/cancel
⚪ Document Management
State store controlled_documents (migration 017). Types: SOP/WI/Drawing/MillCert/GIA/NCR. Lifecycle Draft→Published→Obsolete · link entity · version bump. API /api/v1/documents · FE /documents. Blob = storage URI only.
⚪ Engineering Change Order (ECO) done
EcoRequest ES · ECO-{year}-{seq:D5} · ChangeLines dedup · IEcoBomActivationHook auto-activate new BOM revision · 9 endpoints · topic eco.events · migration 020 · FE /eco
⚪ Calibration Management done
CAL-{year}-{seq:D5} · Internal/External/Verification · Scheduled→InProgress→Passed|Failed|Cancelled · nextDueDate validation · certificate_number · 7 endpoints · migration 021 · FE /calibration
⚪ Predictive Analytics — rule-based done
Equipment health score 0-100 (CM frequency + open WOs + overdue cal + low OEE) · Inventory days-to-stockout (Safe/Watch/Warning/Critical) · Quality fail rate per machine (Low/Medium/High/Critical). 4 endpoints /api/v1/analytics · FE /analytics
⚪ AI / ML Anomaly Detection (Phase 3)
Statistical anomaly từ sensor data · Quality defect pattern recognition · Predictive maintenance models. Phụ thuộc vào sensor data đủ lớn (>30 ngày)
Testing 100% — 266 unit · 12 arch · 7 integration ✅
Unit Tests — Domain + Application Layer (xUnit + NSubstitute) done
266 tests: domain business rules tất cả BCs · OeeFormulas 35 tests (A/P/Q/Total/ShiftWindow) · application handler tests (NSubstitute mock repo)
Integration Tests — Infrastructure Layer done
7 smoke tests: Production/Quality/Maintenance/Auth/ECO/Calibration/SensorOEE · Testcontainers Postgres/Redis · assert Event Store + Outbox + DB rows. Project tests/Integration.
Architecture Tests (NetArchTest) — 12 tests done
Layer deps Core→Application→Infrastructure→Api · handlers/events sealed · endpoints namespace. Project tests/Architecture.
API Integration Tests done
WebApplicationFactory · health · register/login · create production order · schedule shift.
Deployment 65% — Docker Compose + CD pipeline + staging server done
Dockerfile (multi-stage, non-root) done
deploy/Dockerfile
Docker Compose — full stack done
deploy/docker-compose.yml: API + PostgreSQL + Redis + Kafka (KRaft)
docker-compose.prod.yml — production overrides
Resource limits (CPU/memory) cho api/worker/postgres/redis/kafka · migration runner service (postgres:17-alpine + psql idempotent) · healthcheck wget · JSON logging (Serilog.Formatting.Json) · ports reset cho infra services
docker-compose.staging.yml
Tương tự prod nhưng ít resource hơn, dùng tag :staging, expose port DB/Redis để debug
VPS Staging server setup done
Nginx reverse proxy · docker-compose.staging.yml · CD SSH deploy tự động từ GitHub Actions khi merge vào staging
Cloudflare Pages — deploy portfolio/docs public CI pipeline ready
.github/workflows/cloudflare-pages.yml — trigger khi docs/ thay đổi trên namdaoint. Cần add 2 GitHub Secrets: CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID. Project name: d-pro-portfolio trên Cloudflare Pages dashboard.
HTTPS / SSL setup (Let's Encrypt + Nginx hoặc Traefik)
On-premises deployment guide cho khách hàng nhà máy
Script cài đặt, yêu cầu phần cứng tối thiểu, hướng dẫn IT KH
Database backup strategy
pg_dump scheduled, backup retention, restore procedure
Frontend 100% — Tất cả screens + Operator Tablet done ✅
React + Vite project scaffold done
TypeScript + ESLint tại frontend/ — Vite 5 (Node 18). Proxy /apilocalhost:5080
Design System — Custom industrial dark theme done
Navy/Indigo palette · Tabler Icons · Mermaid diagrams pan/zoom + fullscreen. Không dùng MUI/shadcn — custom CSS đủ nhẹ cho shop-floor.
Authentication flow (JWT + Refresh Token) done
apiFetch: 401 → POST /auth/refresh single-flight → retry; fail → clear session + redirect /login. Logout gọi /auth/logout revoke server-side.
Production Order management UI done
List + create orders
Quality / Inventory / Maintenance UI done
BOM / Planning / Finance / Traceability / CAPA / Shifts / Reports / OEE Live / Master Data / Approval / Notifications / Documents / Procurement / ECO / Calibration / Analytics UI done
MES Live Dashboard — real-time machine status, OEE done
Andon board FE /oee + SignalR /hubs/oee (plant / line / machine).
Operator Tablet Mode done
Route /operator không có sidebar — giao diện tối giản cho shop-floor: Record Output + Report Breakdown. Thiết kế touch-friendly.
Security & Performance Hardening — Review 2026-07-14 89% — chỉ còn Kafka HA prod (3 brokers)
PBKDF2 iterations 100k → 600k (OWASP) done
Pbkdf2PasswordHasher.cs — hash cũ vẫn verify được vì iterations lưu trong chuỗi hash
JWT Refresh Token flow done
Access 30 phút + refresh 14 ngày. Rotation mỗi lần refresh; reuse detection → revoke all tokens (REFRESH_TOKEN_REUSED); đổi mật khẩu → revoke all. Bảng refresh_tokens chỉ lưu SHA-256 hash (migration 016). Endpoints: POST /auth/refresh, POST /auth/logout. 7 unit tests
Frontend: auto-refresh access token done
apiFetch: 401 → POST /auth/refresh (single-flight) → retry 1 lần; fail → clear session + redirect /login. Login/logout persist & revoke refresh token.
Snapshot support cho aggregate nhiều events
InventoryItem: IAggregateSnapshotStore + load snapshot + tail events. Write mỗi EventStore:SnapshotEvery (default 100) trong cùng TX với events/outbox. AggregateRoot.Replay / FromSnapshot
Tách Kafka consumers ra Worker process riêng
src/Worker/ host: OutboxPublisher + projections. Flag Workers:RunMessagingInProcess (API default true cho local; compose prod: API=false, Worker=true). OEE SignalR broadcast giữ trên API. Image chung, entrypoint Worker: dotnet ERP.MES.Worker.dll
Kafka production: tối thiểu 3 brokers + replication factor 3
Dev hiện dùng 1 node KRaft — OK cho dev, không đủ HA cho production
Redis: dùng thật hoặc gỡ khỏi stack
Đã dùng Redis cho hot reads (OEE live + ops dashboard). Health check giữ nguyên. Invalidation theo TTL ngắn (shop-floor freshness); projection DEL có thể bổ sung sau.
Rate limiting cho API
.NET AddRateLimiter: global fixed-window per user/tenant+IP (RateLimiting:ApiPermitLimit default 300/60s); policy auth chặt hơn cho login/refresh/register (20/60s). 429 + Retry-After. Exempt: /health, OpenAPI, hubs. Integration tests: RateLimiting:Enabled=false
Number generators → PostgreSQL durable sequence done
Bug cũ: in-memory Interlocked.Increment reset khi restart → UNIQUE violation. Fix: bảng number_sequences (migration 015) + atomic INSERT ON CONFLICT DO UPDATE RETURNING, key per kind/tenant/year — an toàn multi-instance
Operations & Monitoring 80% — chỉ còn Distributed tracing backend
Structured logging (Serilog)
Serilog.AspNetCore + Serilog.Sinks.File cho cả API và Worker. Dev: human-readable console. Production: JSON (Serilog.Formatting.Json) sẵn sàng ingest vào Loki/Cloud Logging. UseSerilogRequestLogging với TenantId enrichment.
Metrics export (OpenTelemetry → Prometheus)
GET /metrics (Prometheus scrape endpoint, exempt khỏi auth + rate limit). ASP.NET Core instrumentation: HTTP request count, duration, status codes. .NET runtime metrics: GC, thread pool, heap size. OTLP export (Tempo/Jaeger) khi cấu hình Telemetry:OtlpEndpoint. Worker có runtime metrics + OTLP.
Grafana dashboards setup
deploy/docker-compose.monitoring.yml: Prometheus (retention 15d) + Grafana :3001, auto-provision datasource + dashboard D-Pro — API & Outbox Overview (request rate, P50/95/99, error rate, outbox pending/published/failures, GC heap, threadpool, in-flight). Custom meter ERP.MES: erp_outbox_pending (gauge ~10s), erp_outbox_published_total, erp_outbox_publish_failures_total
Alerting rules (Prometheus rules)
deploy/monitoring/alerts.yml: ApiDown (1m), HighErrorRate >1% (5m), HighLatencyP99 >500ms (5m), OutboxBacklog >1k (5m), OutboxPublishFailures. Kafka consumer lag: cần kafka-exporter — bổ sung khi có cluster prod
Distributed tracing (OpenTelemetry → Tempo/Jaeger)
🔴 Projection error handling — message bị skip khi lỗi fixed 18/07
Phát hiện khi smoke-test Procurement: event fail → event sau commit offset vượt qua → mất message (cả 13 projections). Fix: KafkaProjectionBase — consume loop chung duy nhất: lỗi → consumer.Seek() retry cùng offset (max 5 lần, delay 2s) → quá 5 lần ghi DLQ projection_failures (payload JSONB + error, migration 019) rồi commit đi tiếp. 13 projections refactor còn mỗi HandleAsync switch (~60 dòng boilerplate/file bỏ đi). BC mới bắt buộc kế thừa base này

Checklist này được cập nhật theo tiến độ thực tế

Cập nhật lần cuối: 22/07/2026

← Về trang chủ