Introduce PocketBase workflow support, migration tooling, server APIs and documentation. Adds a set of PocketBase collection JSONs (order_items, order_items_v2, collection_pool, delivery_notes, delivery_note_items, repairs) and a large import manifest for workflow collections; includes docs describing MCP/API layer, migration audit, order-item schema and rollout plans. Adds server-side agent/MCP endpoints and services (api/mcp, api/v1/orders, collection-pool, order-items status, health) plus helper modules (pocketbase-admin, orders-service, order-item-status, agent-auth) and a migration script to create order_items_v2/collection_pool. UI: new pages for collection-pool, delivery-notes, repairs and several updates to orders/quotes pages, sidebar, tooltip and pb helpers/types. Also updates package.json (migration script and related changes) and global styles. Required env vars and suggested migration command are documented (e.g. NEXT_PUBLIC_POCKETBASE_URL, PB_ADMIN_EMAIL, PB_ADMIN_PASSWORD, ORDER_ITEMS_COLLECTION; run npm run pb:migrate:orders-v2).
2.3 KiB
2.3 KiB
WFDASH Migration Audit (2026-05-25)
Current State
- Legacy app: Django monolith in
/D:/NEWBUILD/WFDASH_django. - New app: Next.js + PocketBase in
/D:/NEWBUILD/wfnextjs. - Database direction: PocketBase collections already mirror core CRM entities.
- Operations direction: workflow automation moving to n8n.
Django Scope Found
- 40+ model classes across modules, including: quotes, orders, driver_list, delivery_notes, stock, repairs, husqvarna service, POS, AI orders, reporting/portal modules.
- Heavy background/process setup: Celery, Redis, email monitors, webhook integrations, debug middleware, multiple app copies/archives.
- Hosting complexity indicators:
- very broad
INSTALLED_APPS - multiple legacy snapshots (
*_old, date-stamped modules) - mixed concerns (UI, automation, integrations, monitoring) in one runtime.
- very broad
Next.js Scope Found
- Strong foundation for CRM core modules (customers, companies, suppliers, quotes, orders).
- PocketBase collection integration already implemented in UI helpers.
- Missing before agent rollout:
- dedicated server API layer
- MCP-compatible tool gateway
- migration governance docs and field naming standards.
PocketBase Findings (from attached schema)
Core collections present:
customers,companies,suppliers,quotes,quote_items,orders,order_items,purchase_orders.
order_items already includes advanced lifecycle fields and driver/delivery states.
Current mixed naming exists (driver_status) while new desired naming is drv_*.
Recommended Migration Strategy
- Freeze feature growth in Django except critical fixes.
- Define "parity slices" by workflow, not by old apps.
- Migrate in this order:
- Quote to Order conversion lifecycle
- Order item operations + driver loop
- Purchase order + supplier communications
- Monitoring and alerts via n8n
- Optional legacy modules (repairs/POS/service) only if still needed
- Keep PocketBase as source of truth for transactional state.
- Move automations to n8n and keep Next.js API minimal and deterministic.
Immediate Deliverables Added in This Repo
/D:/NEWBUILD/wfnextjs/src/app/api/v1/*REST starter routes for agents./D:/NEWBUILD/wfnextjs/src/app/api/mcp/route.tsMCP-style JSON-RPC gateway.- Normalizer accepting both
driver_statusanddrv_statusfor transition safety.