Status: Living document — long-term source of truth for architecture, multi-tenancy, RBAC, marketplace direction, and scaling.
Audience: Core team, future implementations, and AI-assisted development (keep this file aligned with reality as the product evolves).
Product narrative & brand: See docs/SOL52_MASTER_PLAN.md for historical product story and screen-level notes; this file owns technical architecture, tenancy, permissions, and roadmap sequencing.
Rule: Before large features (marketplace, auth hardening, new modules), update this document with the decision and the phase it belongs to.
Sol.52 is evolving from a best-in-class installer proposal & operations surface into a full solar ecosystem platform:
proposal_pricing + line items), and installer workflows.This is not “just a proposal PDF tool”; proposals remain a core sales engine, with pricing and org context feeding quotations, projects, and (later) marketplace-aware sourcing.
organization_id once auth + onboarding exist.proposal_pricing (and synced proposals.ppt_input / summaries) until a dedicated quotation module splits for good reason; marketplace references proposals/projects — it does not fork pricing silently.Scope: Global, cross-tenant.
Capabilities (target):
Hard rule: Marketplace creation and global control belong only here. Company admins never “run” the marketplace.
Implementation note: Until full auth: Super Admin may be represented by a small allowlist (e.g. platform_super_admins + service role) — see §6.
Scope: Single organization (their company).
Capabilities (target):
Marketplace (buyer + optional seller):
Scope: Organization-scoped, limited.
Capabilities (target):
Cannot:
| Domain | Ownership rule |
|---|---|
| Leads / customers | organization_id required (nullable only during transition) |
| Projects | organization_id (denormalized OK for perf; must match lead’s org) |
| Proposals | organization_id; public share links remain opaque IDs — authorization for edit is org-scoped |
| Proposal pricing | Implicit via proposals.id → prefer no duplicate org on child table unless needed for RLS performance |
| Quotations (future) | organization_id + proposal_id |
| Employees / memberships | organization_members.organization_id |
| Marketplace listings (future) | Seller organization_id + Super Admin moderation state |
| Orders / inventory (future) | Seller org + buyer org references |
user_id, organization_id (active org), platform_role (super_admin | null), org_role (company_admin | employee).organization_id match for normal users; Super Admin uses separate policy branch or security definer RPCs for support tools.Model: B2B discovery similar in spirit to Amazon sellers / IndiaMART — installers, distributors, inventory, offers, matched by location, system size, budget, brand preference.
Super Admin only:
Company Admin:
/marketplace hub — browse, filter, seller profilesproposal_pricing.line_items as the commercial line-item model; later, rows may gain optional catalog_listing_id / seller_org_id nullable columns — additive migrations only.Dynamic proposal sections (cover, about, technical narrative, BOM, commercial, ROI, warranty, payment, terms, gallery, customer checklist, AMC) live in proposalLayout on PremiumProposalPptInput, driven by lib/proposal-block-registry.ts and lib/proposal-template-schema.ts. Each block is toggleable and reorderable; the existing 12-slide deck path stays the default customer experience until web quote / PDF renderers read the layout.
BOM alignment: lib/epc-component-catalog.ts holds master categories (panels, inverter, structure, ACDB/DCDB, cables, earthing, LA, net meter, installation, misc electricals, battery, monitoring). Normalized pricing rows may set optional catalog_category on line items for future marketplace / regional catalogs — additive only.
Persistence: PATCH /api/proposals/[id]/layout writes layout into proposals.ppt_input using the same proposal-row sync helper as pricing (refreshed summary scalars).
020_organizations_foundation.sql)organizations — tenant root (name, slug, status).organization_members — links auth.users to org + org_role (company_admin | employee).platform_super_admins — explicit Super Admin allowlist (platform scope).organization_id on leads, proposals, projects — backward compatible; app code may ignore until auth.RLS: New org tables ship with RLS enabled and no broad policies — service role / migrations own writes until JWT-based policies are designed. This avoids silently widening anon access.
quotations (org + proposal FK, PDF metadata, status)marketplace_sellers, marketplace_listings, marketplace_inquiries (all org-scoped + Super Admin moderation columns)subscription_plans, organization_subscriptions (billing)catalog_skus for internal + marketplace alignment| Capability | Super Admin | Company Admin | Employee |
|---|---|---|---|
| Global marketplace control | ✅ | ❌ | ❌ |
| Approve sellers globally | ✅ | ❌ | ❌ |
| Browse / use marketplace | ✅ (support) | ✅ | Per policy |
| Register org as seller | N/A | ✅ (pending approval) | ❌ |
| Org employees & roles | All orgs | Own org | ❌ |
| Org billing | Platform | Own org | ❌ |
| Proposals / pricing | All (support) | Own org | Own org / assigned |
| Projects / leads | All (support) | Own org | Assigned |
| Phase | Focus |
|---|---|
| A — Now | Org tables + nullable FKs; app remains MVP; document vision (this file). |
| B | Auth (Supabase Auth), JWT claims, set organization_id on writes, admin onboarding. |
| C | RLS tightening per org; remove permissive anon where no longer needed; Super Admin tools. |
| D | Quotation module v2 + audit trail; optional catalog references on line items. |
| E | Marketplace MVP: seller registry, listings, inquiries, Super Admin console. |
| F | Subscriptions, commissions, analytics, integrations. |
Phases can overlap; do not skip B before claiming production multi-tenancy.
In scope today:
/proposal/[id]Explicitly out of scope until phased:
organization_id (or justified exception in this file).End of MASTERPLAN — keep implementations honest and the platform vision single-threaded.