Repair Asset Management — Reverse Engineering & Rebuild
Blueprint
Architecture decisions
withTenant wrapper mandatory — no bare Prisma callsinvoice.status = sentnumbering_sequences + sequence_definitionsexpected_batches.session_count columndaily_metrics_snapshots tableconcurrency=1 (per-org upgrade → backlog B-001)'migrated' source enum on device_repair_codesfinalizeDispatch idempotency (FOR UPDATE + early return)sequence_definitions seed table (global, no RLS)$transaction callback form only (no array form)no-bare-prisma, no-withtenant-in-iteration, no-async-array-mapExecution
| Sprint | Scope | Status | Verification |
|---|---|---|---|
| S0 | Foundations (monorepo, Docker, CI skeleton) | ✓ Complete | Unit tests |
| S1 | Tenancy & Auth (JWT + RLS) | ✓ Complete | Integration ✓ |
| S2 | Master Data CRUD | ✓ Complete | Unit tests |
| S3 | Asset Receiving | ✓ Complete | Unit tests |
| S4 | QC Workbench (triage, BER review) | ✓ Complete | Unit tests |
| S5 | Inventory & Parts Issue | ✓ Complete | Unit tests |
| S6 | Worksheets & Team Build | ✓ Complete | Unit tests |
| S7 | Outbound Dispatch | ✓ Complete | Unit tests |
| S8 | Invoicing & Pricing | ✓ Complete | Unit tests |
| S9 | Reports & Owner Dashboard | ✓ Complete | Unit tests |
| S10 | TypeScript polish (19 errors resolved) | ✓ Complete | tsc clean |
| S11 | Stub pages (Repairs, Technicians, Settings) | ✓ Complete | Unit tests |
| S12 | Devices page + pagination retrofit | ✓ Complete | Unit tests |
| S13 | drfone-parse BullMQ processor | ✓ Complete | Unit tests |
| S14 | bulk-upload processor + Team page | ✓ Complete | Unit tests |
| S15 | Infra catch-up (PG16, Redis, RLS idempotent) | ✓ Complete | Integration ✓ |
| S16 | Idempotent RLS + BullMQ e2e + CI tracked | ✓ Complete | E2E verified |
| S17 B1 | DrfoneCodeMapping + unmapped queue + reports count | ✓ Complete | E2E verified |
Sprint 17 B1 — what shipped
repair_codes catalogue table + 24 canonical codes seededdrfone_code_mappings table + RLS + FORCE + UNIQUE(org_id, drfone_code)device_repair_codes.repair_code_id FK (nullable) addeddrfone_mapped, drfone_unmappeddrfone / drfone_auto rowsDrfoneCodeMappingService — TenantContext for CRUD, explicit orgId for BullMQ worker (Rule #18)DrfoneMappingsController — 7 routes including resolve endpointGET /initial-qc/unmapped-queue endpointGET /reports/drfone-unmapped-count endpointdrfone-parse.e2e.spec.ts and passing2dd95ca — 21 files, 2,230 insertions, 216 deletionsTest coverage
Deferred items
| ID | Item | Status | Blocking trigger |
|---|---|---|---|
| B-001 | BullMQ per-org concurrency upgrade | Deferred | Before second paying tenant |
| B-002 | reserveNumber first-call TOCTOU race | ✓ Resolved S16-1b | — |
| B-003 | Shared-packages tsconfig missing | Deferred | Second engineer onboarding |
| B-004 | Migration 0004 backfill performance (production scale) | Deferred | Sprint 19 production migration |
Immediate actions
workflows scope
Road to completion
repair_codes catalogue management + dashboard widget