here’s the full, drop-in package Replit needs to wire the context-aware generator. Then we can jam on the AI section logic.

0) Plan-level “Business Brief” (stored once per plan)

Fields (persist per plan):

company (string)

model (string) — e.g., “Global SaaS + Web Services”

offerings (string) — comma-separated or bullets

market (string) — ICP / geography

differentiator (string)

financialHeadline (string, optional) — e.g., “Launch Q4 2025; 2026 $730k; 2027 $1.46M”

UI: Sticky/ collapsible bar at top. Show a one-line summary when collapsed.

1) Prompt assembly (do this for every AI action)
FinalPrompt =
  [SYSTEM]_StyleAndToneControls +
  [CONTEXT]_BusinessBrief +
  [CONTEXT]_SectionId +
  [CONTEXT]_SectionBasePrompt +
  [USER]_EditorContent (if non-empty) +
  [UI]_ToneSelection + [UI]_LengthSelection


If Editor is empty → omit [USER]_EditorContent.

If Business Brief is empty → still proceed (use base prompt only).

Always include sectionId so the model stays on-topic.

SYSTEM (fixed)

“You are drafting a professional business plan section. Be accurate, concise, and business-appropriate. No bracket placeholders like [Company Name]. Use the provided context. If data is missing, write neutral, generic language.”

Tone & Length controls

Tone: Professional (default), Bold, Friendly, Minimal.

Length: Short (120–160w), Standard (200–300w), Long (350–500w).

2) Section base prompts (12) — paste these into app config
executive-summary

“Write a concise, investor-ready executive summary for {{company}}. Use: company & model, offerings, target market, differentiator, and the financialHeadline if present using Launch/Growth/Scale phrasing. Close with optional funding ask only if the editor text mentions it. No placeholders.”

company-overview

“Describe mission, vision, value proposition, origin story, legal structure/location, and current stage. Tie geography to market only if provided. Keep it factual and compact.”

products-services

“List 3–7 offerings as bullets (1 line each) followed by a 1-paragraph value proposition. If tiers/pricing appear in editor or brief, summarize in 3 lines. Avoid marketing fluff.”

market-analysis

“Summarize ICP (who/where), 3–4 trends, 2–4 competitors with one-line differentiation, and a mini-SWOT (one line each for S/W/O/T). If numbers like TAM/SAM/SOM are missing, keep them qualitative.”

marketing-sales

“Outline positioning, top channels (3–6), funnel (TOFU→MOFU→BOFU in one line), retention tactics, and 4–6 KPIs (e.g., CAC, LTV, MRR, churn). No tactical wall of text.”

operations-plan

“Summarize tech/infra, core processes (support, releases, QA, billing), key vendors/tools, SLAs/security notes, and 3–5 ops KPIs. Keep it operational, not marketing.”

org-management

“List leadership with roles; include ‘Strategic AI Partner: Nova AI — Co-Founder / Operations & Data Intelligence’ if relevant. Add current team snapshot and hiring plan bullets. Optional advisors only if present.”

financial-plan

“Summarize revenue streams, core assumptions, forecast using Launch (Q4 {{year0}} if in brief), Growth ({{year1}}), Scale ({{year2}}). Mention break-even if implied. Include risks & mitigations in 2–3 bullets. No made-up numbers; echo the financialHeadline if present.”

milestones-roadmap

“List 4–8 bullets grouped by phase: Launch, Growth, Scale, Beyond. Each bullet starts with a verb and an outcome metric if present.”

future-expansion

“Explain 2–4 expansion vectors: integrations, adjacent products, partnerships/channels, long-term vision. Tie back to model and market.”

partnerships-note

“State partner rationale, types (agencies, resellers, platforms), criteria (quality, SLAs, alignment), engagement model (referrals, rev-share, white-label), and the customer benefit—brief and practical.”

exit-strategy (optional)

“Investor-optional: primary exit path (typical acquirers), alternatives (IPO/private growth), timing triggers (revenue/profit/growth), and the value narrative. If no signals, keep this neutral and brief.”

3) API contract (server endpoint)

POST /ai/section/generate

{
  "planId":"...","sectionId":"executive-summary",
  "tone":"professional","length":"standard",
  "businessBrief":{
    "company":"...","model":"...","offerings":"...","market":"...",
    "differentiator":"...","financialHeadline":"..."
  },
  "editorContent":"(optional, current text)"
}


Response

{"content":"<markdown>", "usage":{"prompt":..., "completion":...}}


Same payload for rephrase|expand|summarize with an "action" field.

4) UI actions & placement

Inline AI Assist bar under the editor: Tone, Length, buttons (Generate / Rephrase / Expand / Summarize).

Primary button in every section: Save to Document (show “Saved • 2:41 PM”).

Section Preview (secondary) inside each section.

Preview Full Document in header (top-right).

Business Plan Templates button routes to Templates page (not in-section SWOT).

Structured Templates (SWOT/PESTEL/etc.) appear only in Market Analysis with button Add to Market Analysis.

5) Guardrails & messages

If Business Brief empty → toast: “Add your Business Brief for better results (optional).”

If Editor has content and user taps Generate → confirm: “Replace or Append?”

Never output bracket placeholders. If data missing → use neutral phrasing.

Admin debug toggle: Show Prompt to view the assembled prompt.

6) Mini QA checklist (pass/fail)

Executive Summary uses company/model/offerings from Brief; no placeholders.

Financial Plan uses Launch/Growth/Scale if financialHeadline is present.

Market Analysis only shows SWOT/PESTEL; other sections don’t.

“Save to Document” persists order & visibility; timestamps update.

Full Preview matches export.

7) Example assembled prompt (for quick dev testing)

Inputs:
Brief: company=IBrandBiz; model=Global SaaS + Web Services (branding tools + domains + hosting); offerings=Brand Name Wizard, Slogan Generator, Logo Creator, Brand Kit, Business Plan Developer; Business Plan Template; Domains & Web Hosting; market=Entrepreneurs & SMEs (global); differentiator=Integrated “start-a-business” toolkit + hosting; partner marketing; financialHeadline=Launch Q4 2025; 2026 $730k; 2027 $1.46M
SectionId: executive-summary
Editor: (empty)
Tone: professional Length: standard

FinalPrompt (human-readable)

SYSTEM: You are drafting a professional business plan section… (see above).

CONTEXT (Business Brief): (brief as above).

CONTEXT (Section): executive-summary

TASK (Base Prompt): (executive-summary prompt above).

STYLE: Tone=Professional, Length=Standard.

Expected traits in output: mentions IBrandBiz, SaaS + hosting, offerings list (condensed), global market, integrated edge, Launch/Growth/Scale line.

That’s everything they need to wire the UX + AI correctly.