Add PocketBase collections, APIs & migration docs
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).
2026-05-25 16:39:33 +00:00
|
|
|
# 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.
|
|
|
|
|
|
|
|
|
|
## 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
|
|
|
|
|
1. Freeze feature growth in Django except critical fixes.
|
|
|
|
|
2. Define "parity slices" by workflow, not by old apps.
|
|
|
|
|
3. Migrate in this order:
|
|
|
|
|
1. Quote to Order conversion lifecycle
|
|
|
|
|
2. Order item operations + driver loop
|
|
|
|
|
3. Purchase order + supplier communications
|
|
|
|
|
4. Monitoring and alerts via n8n
|
|
|
|
|
5. Optional legacy modules (repairs/POS/service) only if still needed
|
|
|
|
|
4. Keep PocketBase as source of truth for transactional state.
|
|
|
|
|
5. 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.ts` MCP-style JSON-RPC gateway.
|
2026-06-11 18:30:02 +00:00
|
|
|
- Normalizer accepting both `driver_status` and `drv_status` for transition safety.
|