10 KiB
M4 V2 Frontend Migration Guide
Status: Active
Last updated: 2026-03-11
Audience: Web and mobile frontend developers
1) Purpose
This document tells frontend exactly how to migrate toward the v2 backend services on this branch.
It is intentionally strict about readiness:
core-api-v2is ready for frontend integration now for uploads, signed URLs, model calls, and verification workflows.command-api-v2now has a first real write slice backed by the v2 SQL schema and verified through live smoke tests.query-api-v2now has a first real read slice backed by the v2 SQL schema and verified through live smoke tests.
Frontend should not assume all three services are ready just because they are deployed.
2) Live dev service URLs
- Core API v2:
https://krow-core-api-v2-e3g6witsvq-uc.a.run.app - Command API v2:
https://krow-command-api-v2-e3g6witsvq-uc.a.run.app - Query API v2:
https://krow-query-api-v2-e3g6witsvq-uc.a.run.app
3) Readiness summary
| Service | Status | Frontend guidance |
|---|---|---|
core-api-v2 |
Ready now with persistence caveat | Use for file upload, signed URLs, model calls, rapid order helpers, and verification flows |
command-api-v2 |
First production slice | Use for documented v2 write flows only |
query-api-v2 |
First production slice | Use for documented v2 read flows only |
4) Non-negotiable migration rules
- Do not point undocumented read screens to
query-api-v2yet. - Do not replace undocumented order, shift, or staffing mutations with
command-api-v2yet. - Do move all new service-style frontend work to
core-api-v2. - Do use command/query v2 for the routes listed in this document when building the new v2 clients.
- Any new frontend abstraction should separate:
core service clientcommand service clientquery service clientlegacy Data Connect access
- Build the frontend with switchable adapters so the command/query cutover is a client config change, not a rewrite.
5) Auth and headers
All protected v2 routes currently require Firebase ID token:
Authorization: Bearer <firebase-id-token>
All services return:
X-Request-Idresponse header- Standard error envelope:
{
"code": "STRING_CODE",
"message": "Human readable message",
"details": {},
"requestId": "uuid"
}
Additional rule for command routes:
Idempotency-Key: <unique-per-user-action>
6) What frontend can migrate now
6.1 Move to core-api-v2 now
- File uploads
- Signed download URL generation
- Rapid order voice transcription
- Rapid order structured parsing
- Generic model invocation
- Verification job creation
- Verification status polling
- Manual verification review and retry
6.2 Keep on existing stack for now
- Business reads
- Staff reads
- Shift lists and details outside the documented order detail shape
- Applications lists and details not yet served by query v2
- Payments and reporting reads
6.3 Move to command/query v2 now for the new v2 clients
- Order creation
- Order update
- Order cancel
- Shift assign staff
- Shift accept
- Shift status change
- Attendance clock-in and clock-out
- Favorite staff add and remove
- Staff review create
- Order list
- Order detail
- Favorite staff list
- Staff review summary
- Assignment attendance detail
7) Core API v2 routes frontend can use today
Use this service for backend capabilities that should not run directly from the client.
Important caveat:
- File storage is real and backed by Google Cloud Storage.
- Verification job state is not yet persisted to the v2 SQL schema.
- Frontend can integrate with these routes now, but do not treat verification history as mission-critical durable state yet.
Base URL:
https://krow-core-api-v2-e3g6witsvq-uc.a.run.app
Routes:
POST /core/upload-filePOST /core/create-signed-urlPOST /core/invoke-llmPOST /core/rapid-orders/transcribePOST /core/rapid-orders/parsePOST /core/verificationsGET /core/verifications/:verificationIdPOST /core/verifications/:verificationId/reviewPOST /core/verifications/:verificationId/retryGET /health
For request and response examples, use:
docs/MILESTONES/M4/planning/m4-core-api-frontend-guide.mddocs/MILESTONES/M4/planning/m4-api-catalog.md
8) Command API v2 routes ready for the first migration slice
These routes are deployed and backed by the v2 SQL schema. They enforce auth, policy gate, and idempotency.
Base URL:
https://krow-command-api-v2-e3g6witsvq-uc.a.run.app
Routes:
POST /commands/orders/createPOST /commands/orders/:orderId/updatePOST /commands/orders/:orderId/cancelPOST /commands/shifts/:shiftId/change-statusPOST /commands/shifts/:shiftId/assign-staffPOST /commands/shifts/:shiftId/acceptPOST /commands/attendance/clock-inPOST /commands/attendance/clock-outPOST /commands/businesses/:businessId/favorite-staffDELETE /commands/businesses/:businessId/favorite-staff/:staffIdPOST /commands/assignments/:assignmentId/reviewsGET /healthGET /readyz
Implemented now:
POST /commands/orders/createPOST /commands/orders/:orderId/updatePOST /commands/orders/:orderId/cancelPOST /commands/shifts/:shiftId/change-statusPOST /commands/shifts/:shiftId/assign-staffPOST /commands/shifts/:shiftId/acceptPOST /commands/attendance/clock-inPOST /commands/attendance/clock-outPOST /commands/businesses/:businessId/favorite-staffDELETE /commands/businesses/:businessId/favorite-staff/:staffIdPOST /commands/assignments/:assignmentId/reviews
Live verification completed on 2026-03-11:
- order create
- order update
- order cancel
- shift assign staff
- shift accept
- shift status change
- attendance clock-in
- attendance clock-out
- favorite add
- favorite list
- review create
- review summary
- order list/detail
- attendance detail
Order creation request contract:
{
"tenantId": "uuid",
"businessId": "uuid",
"vendorId": "uuid",
"orderNumber": "ORD-1001",
"title": "Cafe Event Staffing",
"serviceType": "EVENT",
"shifts": [
{
"shiftCode": "SHIFT-1",
"title": "Morning Shift",
"startsAt": "2026-03-11T08:00:00.000Z",
"endsAt": "2026-03-11T16:00:00.000Z",
"requiredWorkers": 2,
"roles": [
{
"roleCode": "BARISTA",
"roleName": "Barista",
"workersNeeded": 2
}
]
}
]
}
Order creation success response:
{
"orderId": "uuid",
"orderNumber": "ORD-1001",
"status": "OPEN",
"shiftCount": 1,
"shiftIds": ["uuid"],
"idempotencyKey": "abc-123",
"requestId": "uuid"
}
Important:
- This is the first real write slice, not the full command surface.
- Frontend should migrate only the documented routes.
- Reuse one idempotency key per user action and never retry with a new key unless the UI is creating a brand new action.
- The old
501placeholders for order update, order cancel, shift status change, and shift assign staff are now implemented.
9) Query API v2 routes ready for the first migration slice
Base URL:
https://krow-query-api-v2-e3g6witsvq-uc.a.run.app
Current routes:
GET /healthGET /healthzGET /readyzGET /query/tenants/:tenantId/ordersGET /query/tenants/:tenantId/orders/:orderIdGET /query/tenants/:tenantId/businesses/:businessId/favorite-staffGET /query/tenants/:tenantId/staff/:staffId/review-summaryGET /query/tenants/:tenantId/assignments/:assignmentId/attendance
Frontend can point the new v2 clients to these routes now. Frontend should not point any undocumented screen, list, detail page, dashboard, or reporting view to query-api-v2 yet.
10) Recommended frontend adapter shape
Frontend should isolate backend calls behind service adapters instead of calling routes inline in screens.
Suggested split:
coreApiClientcommandApiClientqueryApiClientlegacyDataConnectClient
Suggested cutover plan:
- Move service-style operations to
coreApiClientfirst. - Add
commandApiClientnow as the write path for the documented v2 write routes. - Add
queryApiClientnow as the read path for the documented v2 read routes. - Keep everything else on
legacyDataConnectClientuntil the replacement route exists. - Expand migration route-by-route instead of big-bang switching whole apps.
11) Frontend implementation checklist
- Add three environment variables:
CORE_API_V2_BASE_URLCOMMAND_API_V2_BASE_URLQUERY_API_V2_BASE_URL
- Add shared auth header injection using Firebase ID token.
- Add shared response envelope parsing.
- Add request ID logging in frontend network layer.
- Add
Idempotency-Keygeneration utility for command calls. - Build command/query clients behind feature flags or adapter switches.
- Start integration with
core-api-v2,command-api-v2, andquery-api-v2for the documented routes only.
12) Frontend do and do not
Do:
- Treat
core-api-v2as the real backend entrypoint for uploads, model work, and verification. - Treat documented command/query v2 routes as the real backend entrypoint for the first v2 domain slice.
- Build migration-safe abstractions now.
- Keep old reads and writes isolated so they can be swapped cleanly later.
Do not:
- Hardcode v2 command success as if business action is complete.
- Point undocumented dashboards or reports to query v2 yet.
- Remove current Data Connect code until the replacement route actually exists and is verified.
13) Practical migration sequence
- Replace existing upload helpers with
core-api-v2. - Replace signed URL generation with
core-api-v2. - Point rapid order helpers to
core-api-v2. - Point attire and document verification flows to
core-api-v2. - Introduce command client wrapper with idempotency header support.
- Point new v2 order creation, shift accept, attendance, favorites, and reviews flows to
command-api-v2. - Point new v2 order list/detail, favorites, review summary, and attendance detail screens to
query-api-v2. - Point new v2 order update, order cancel, shift assign, and shift status flows to
command-api-v2. - Keep payments, reports, and remaining scheduling mutations on the legacy stack until the replacement routes exist.