# Pre-launch tasks: plan Six tasks across this repo and the back end at `/home/msi/Documents/dreams/back`. Order: 6, 1, 2, 3, 5, 4. ## Where each thing lives | Area | Front end | Back end | |---|---|---| | Buttons, tokens | `packages/island/src/atoms/button`, `styles/theme.css` | none | | Auth, sign-up, KYC | `features/auth`, `screens/(auth)` | `apps/user-service`, `apps/gateway/src/auth.controller.ts` | | Legal documents | `features/legal` (new), `/terms` | `apps/user-service` (`legal_documents`, `legal_acceptances`) | | Signals (code name `prediction`) | `features/prediction`, `compose/prediction` | `apps/content-service/src/predictions` | | Pricing, plans, subscriptions | `features/pricing`, `features/subscription` | `apps/subscription-service` | | Payouts, ledger | `features/finance` | `apps/subscription-service/src/earnings.service.ts` | | Notifications, SMS | `features/notification` | `apps/notification-service` | | Admin | `apps/wall-street-plaza`, `platforms/garden-roof` | `apps/admin-api` | ## Migrations The back end stores these in Mongo, which has no schema migrations, so each is a new collection, a field, or a one-time script: - `user_service.legal_documents`, `legal_acceptances`: new, seeded at startup when empty. - `content_service.posts`: `prediction.entryLow`, `entryHigh`, `entryMode`, `targetsHit`. Old rows stay as they are. - `content_service.signal_stats`: new, one snapshot per analyst. - `subscription_service.platform_settings`: new, holds `price_floor_monthly`. - `subscription_service.subscription_tiers`: `off_sale_reason`. - `scripts/flag-tiers-below-floor.js`: one-time, dry run by default, for running promotions under the new floor. ## Where the spec disagrees with the code | Spec | Code | Resolution | |---|---|---| | One Next.js app for phone and desktop | `apps/bull` and `apps/bear`, sharing `platforms/market` (decision 0001) | Follow the code; UI goes in `platforms/market` | | SQL tables, check constraints, migrations | Mongo through Mongoose; only payment-service uses Postgres | Collections; constraints become schema validators and service checks | | `/api/...` routes | Gateway and admin-api serve `/v1/...` | `/v1/...`, same paths otherwise | | Win rate over target, stop, expired | Closes store `win`, `loss`, `breakeven` and reasons `target`, `stop`, `horizon`, `early`, `admin` | User's answer: `early` and `admin` count by result at close | | ROI splits the stake across targets | Only the final target closes a signal; earlier hits are not recorded | Record `targetsHit` from now on. Older closes: a `target` close hit every target, any other close is treated as having hit none, because no price history exists to replay | | «باطل‌شده» | No such state exists | Counted as zero and excluded everywhere, until defined (TODO) | | Entry stamped from the live quote | Server ignores a client entry today | Client entry accepted per spec; distance limit left as a TODO | | `stop_loss` NOT NULL | Optional in the schema | Required on publish; old rows untouched | | Component and API e2e tests | No front-end test runner; back end has Jest specs only, and its playbook says no e2e harness | Vitest and Testing Library added to the front end; back-end API tests run the Nest controllers through HTTP against mocked TCP clients | | Branch per task | User asked for back-end commits on `main` | Back end: one commit per task, pushed to `main`. This repo: `feat/pre-launch--` branches, stacked in task order | | `secondary` is purple outline | It is a neutral border on white | Same rule applied: no follow control uses it | ## Answers from the user (2026-11-02) - `early` and `admin` closes count by result: profit is «هدف», loss is «حد ضرر», breakeven is «پایان مهلت». - The placeholder agreement is minor, so nobody is blocked at deploy. The final text ships as major and then every analyst gets the modal. - A tier below the floor also blocks renew and reactivate with 409 `tier_unavailable`. - Running promotions under the new floor count as a raise: one-time script, dry run first, tiers go `below_floor`, analysts get the notice. ## Open questions, left as TODOs in code - Maximum distance between a typed entry and the live quote. - When a range-entry signal counts as entered. - What makes a signal «باطل‌شده», and whether it counts in «کل سیگنال‌ها». - Final legal text.