# Backend implementation tasks Status date: 2026-07-24 ## Phase 1 - isolated backend baseline - [x] Create `E:\workspace\server\saas-voc-server` as an independent Git repository. - [x] Keep `moshengqi-server` and `future-server` read-only. - [x] Add strict environment validation without credential fallbacks. - [x] Add pooled PostgreSQL access and an idempotent migration runner. - [x] Add an independent Parse Server application configuration. - [x] Add the initial domestic VOC schema, constraints, foreign keys, and indexes. - [x] Seed the `demashi` workspace and JD source metadata. - [x] Add health, sync, job-status, and snapshot endpoints. - [x] Add a database-free local-demo server for frontend integration using the normalized Demashi snapshot. - [x] Add Fmode timeout/retry/authentication behavior behind a server-only client. - [x] Add unit tests and compile under strict TypeScript settings. - [x] Add a shared platform repository contract with local-memory and PostgreSQL implementations. - [x] Add Parse-session authentication, workspace membership, and four-role RBAC. - [x] Add cursor-paginated product, relation, review, job, import, and platform workflow APIs. - [x] Add analysis requests, action workflows, alerts, and audit history without fake AI results. - [x] Cover local platform flows, viewer write denial, Parse session behavior, pagination, and audit writes. - [x] Make the database-free runtime reusable through a configurable local workspace id. - [x] Reject partial platform migrations through the health check. - [x] Add manual sync retry/cancel, local job events, and stale-worker job recovery. - [x] Protect owner membership and validate action assignees inside the workspace boundary. - [ ] Run migrations against a newly provisioned PostgreSQL database. - [x] Smoke-test the local HTTP service under the supported Node 22 runtime. - [x] Add a Parse REST storage driver that preserves the existing frontend/backend API contract. - [x] Add isolated master-key-only `Voc*` schemas and remote schema reconciliation. ## Phase 2 - case-data persistence - [x] Add a batch importer for the normalized Demashi dataset. - [x] Import 2,817 operating products and 9,717 daily metric rows through bounded Parse REST batches. - [x] Import 40 competitor relations with deterministic relation keys. - [x] Add a streaming importer that persists the original Demashi workbook directly through Parse REST. - [x] Create 37 mapped competitor products and backfill all 37 real product details through the company relay. - [x] Verify Parse counts and snapshot totals against `demashi-summary.json`. - [x] Switch `DomesticDatasetService` between static case mode and backend API mode. - [x] Run desktop/mobile browser smoke tests against Parse REST API mode. ## Phase 3 - real JD source contract - [x] Verify the existing Fmode gateway health endpoint over public TLS (HTTP 200 on 2026-07-23). - [x] Complete quota-controlled live JD product and review requests through the existing Fmode gateway using a process-only credential. - [x] Confirm the catalog JD product-detail path and required `itemId` parameter. - [x] Confirm the catalog JD review path and optional `page` parameter. - [x] Confirm the live double-`data` response envelope and first-page review pagination metadata. - [x] Confirm the live non-empty JD review contract and capture a sanitized fixture for `commentScore`, `commentDate`, and nested `data` arrays. - [x] Save sanitized product and review contract fixtures without credentials or personal data. - [x] Implement JD product and review adapters against company-gateway contract fixtures. - [x] Process queued jobs with partial-failure events and bounded retries. - [x] Implement idempotent product/review UPSERT and truthful job progress updates. - [x] Fetch and persist one bounded review page for all 37 mapped competitors (355 sanitized reviews). - [ ] Verify source UPSERT and snapshot totals against the provisioned PostgreSQL database. ## Phase 4 - deployable closure - [ ] Provision a dedicated PostgreSQL database and least-privilege runtime role. - [ ] Provision independent Parse application credentials. - [ ] Put TLS and same-origin reverse proxying in front of `/parse` and `/api/domestic-voc`. - [x] Add backend authentication, workspace authorization, and role permission boundaries. - [ ] Enable and integrate the frontend `AuthGuard` after Parse credentials and the first user are provisioned. - [x] Add failed-job replay/cancel APIs and automatic stale-job recovery. - [ ] Add database backup, restore, and retention procedures after infrastructure is provisioned. - [ ] Resolve or formally accept remaining moderate Parse transitive advisories. - [x] Complete local end-to-end acceptance with Demashi relations, competitor product detail, and real review evidence. ## Explicitly deferred - Multi-platform adapters beyond JD. - Multi-tenant billing, SSO provisioning, and custom roles beyond the four built-in roles. - Scheduled full-catalog crawling. - AI reports, sentiment, pain points, or recommendations without review evidence. - Any reuse of the cross-border production database or credentials.