Skip to content

[TASK][Backend] Finish brand and branch business rules: slots, moderation, and rating eligibility #7

@vugarsafarzada

Description

@vugarsafarzada

Source of Truth

  • PRD: https://www.notion.so/3435ef9e213280eaa56ad864787cda02
  • Repo: Reziphay/nodejs-app
  • Task type: execution-ready backend task for AI/code agents
  • Depends on: coordinate with #6 for verification gating
  • Blocks: nextjs-app#7, nextjs-app#10, and part of moderation work in #11

Current Codebase Snapshot

  • prisma/schema.prisma already contains Brand, Branch, BranchBreak, BrandCategory, BrandTransfer, BrandRating, and gallery/logo media relations.
  • src/routes/v1/brand.route.ts already exposes brand media upload, category listing, public brands, my brands, brand CRUD, branch CRUD, transfers, and brand ratings.
  • Missing PRD rules include slot entitlement, richer brand metadata, mandatory branch-at-create, moderation reason/state detail, and strict review eligibility tied to completed reservations.

Goal

Complete the Brand and Branch domains so they match the PRD business rules and become a stable base for Service, Team, Reservation, and Moderation work.

In Scope

  • Extend the brand model for website and social links required by the PRD.
  • Support the full branch input set: cover/interior media, address fields, phone, email, opening/closing, 24/7 flag, and breaks.
  • Enforce that a brand is created together with at least one branch.
  • Add brand-slot entitlement rules: one free slot per USO, additional slots unlocked through an entitlement model.
  • Persist moderation metadata such as rejection reason, reviewer identity, and resubmission-ready state transitions.
  • Strengthen public brand detail payloads so frontend discovery/detail pages can render branches, categories, gallery, and ratings consistently.
  • Enforce that brand rating/review creation is allowed only after a completed reservation under that brand.

Suggested Implementation Order

  1. Review current schema and route contracts before adding new fields so existing endpoints do not regress.
  2. Add schema changes for social links, moderation metadata, and slot entitlement.
  3. Update create/update brand flows so branch creation is mandatory and validated server-side.
  4. Keep branch/team invariants intact when branches are edited or deleted.
  5. Tighten brand rating eligibility behind reservation-aware rules.
  6. Update tests for create/edit/delete, transfers, ratings, and public detail reads.

Important Constraints For Agents

  • Do not break existing transfer flows or the current media upload contracts.
  • If real payment capture is not yet available, model slot entitlement cleanly behind a service boundary instead of hard-coding fake payment logic into controllers.
  • Keep owner/admin/public visibility rules explicit in service/controller code.

Deliverables

  • Prisma migration(s) and updated brand/branch models.
  • Updated DTO/validation rules and controller/service logic.
  • Public and owner payloads that include the data needed by the frontend brand workspace and detail pages.
  • Tests for slot rules, moderation transitions, branch invariants, and rating eligibility.

Acceptance Criteria

  • A USO cannot create a brand without creating at least one branch.
  • Slot entitlement is enforced server-side and is not only a frontend rule.
  • Brand moderation state can carry rejection reason and support resubmission.
  • Public brand detail returns the fields needed for gallery, branches, categories, and ratings.
  • Brand ratings/reviews are rejected unless the user has a completed reservation under that brand.
  • Existing transfer/media flows continue to work after the changes.

Out of Scope

  • A full billing provider integration unless the repo already has one ready to attach.
  • Search ranking/recommendation logic for brand discovery.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions