lakshmisravya123
Major upgrade: comprehensive startup validation with market sizing, SWOT, competitor analysis, revenue models, go-to-market strategy
6fcad97
const GROQ_API_KEY = process.env.GROQ_API_KEY;
const OLLAMA_URL = process.env.OLLAMA_URL || 'http://localhost:11434';
const GROQ_MODEL = process.env.GROQ_MODEL || 'llama-3.3-70b-versatile';
const OLLAMA_MODEL = process.env.OLLAMA_MODEL || 'llama3.2:3b';
async function callAI(prompt) {
if (GROQ_API_KEY) {
const res = await fetch('https://api.groq.com/openai/v1/chat/completions', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${GROQ_API_KEY}` },
body: JSON.stringify({ model: GROQ_MODEL, messages: [{ role: 'user', content: prompt }], temperature: 0.7, max_tokens: 8000 }),
});
if (res.ok) { const data = await res.json(); return data.choices[0].message.content; }
console.warn('Groq failed, falling back to Ollama...');
}
const res = await fetch(`${OLLAMA_URL}/api/generate`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ model: OLLAMA_MODEL, prompt, stream: false }),
});
if (!res.ok) throw new Error('Both Groq and Ollama failed. Set GROQ_API_KEY or start Ollama.');
return (await res.json()).response;
}
function parseJSON(text) {
try { return JSON.parse(text.trim()); }
catch {
const m = text.match(/\{[\s\S]*\}/);
if (m) return JSON.parse(m[0]);
throw new Error('Failed to parse AI response');
}
}
async function validateIdea(idea, targetAudience, monetization) {
const prompt = `You are a world-class startup advisor, venture capital analyst, and market strategist with 20+ years of experience evaluating startup ideas for top-tier VCs (Sequoia, a16z, Y Combinator). You have deep expertise in TAM/SAM/SOM estimation, competitive analysis, financial modeling, and go-to-market strategy.
Evaluate this startup idea with the rigor and depth of a Series A due diligence report.
STARTUP IDEA: ${idea}
TARGET AUDIENCE: ${targetAudience || 'Not specified'}
MONETIZATION: ${monetization || 'Not specified'}
Return ONLY valid JSON with this EXACT structure (no markdown, no code blocks, just raw JSON):
{
"ideaName": "<catchy startup name>",
"oneLiner": "<compelling one-sentence pitch>",
"overallScore": <1-100 integer>,
"verdict": "<GO|CONDITIONAL_GO|PIVOT|NO_GO>",
"verdictExplanation": "<3-4 sentences explaining the verdict with specific reasoning>",
"marketSizing": {
"tam": "<Total Addressable Market with dollar figure e.g. $50B>",
"tamReasoning": "<how you estimated TAM>",
"sam": "<Serviceable Addressable Market with dollar figure>",
"samReasoning": "<how you narrowed to SAM>",
"som": "<Serviceable Obtainable Market dollar figure for first 3 years>",
"somReasoning": "<realistic capture rate reasoning>",
"marketGrowthRate": "<annual CAGR percentage>",
"marketTrend": "<growing|stable|declining>",
"timing": "<too early|perfect timing|late but possible|too late>",
"timingNote": "<why this timing assessment>"
},
"competitorAnalysis": {
"directCompetitors": [
{"name": "<name>", "funding": "<funding raised>", "strength": "<key strength>", "weakness": "<exploitable gap>", "marketShare": "<estimated percent>"}
],
"indirectCompetitors": [
{"name": "<name>", "howTheyCompete": "<how they address similar need>", "threat": "<low|medium|high>"}
],
"potentialCompetitors": [
{"name": "<big tech or company that could enter>", "likelihood": "<low|medium|high>", "timeframe": "<when they might enter>"}
],
"competitiveAdvantage": "<your key differentiator>",
"moatPossibility": "<none|weak|moderate|strong>",
"moatStrategy": "<how to build defensibility>"
},
"revenueModel": {
"primaryModel": "<subscription|freemium|marketplace|ads|usage-based|one-time|hybrid>",
"pricingStrategy": "<detailed pricing tiers or structure>",
"projectedRevenue": {
"year1": "<revenue estimate>",
"year2": "<revenue estimate>",
"year3": "<revenue estimate>"
},
"unitEconomics": {
"ltv": "<customer lifetime value>",
"cac": "<customer acquisition cost>",
"ltvCacRatio": "<ratio>",
"paybackPeriod": "<months to recover CAC>",
"grossMargin": "<percentage>"
},
"breakEvenTimeline": "<months to breakeven>"
},
"swotAnalysis": {
"strengths": ["<strength 1>", "<strength 2>", "<strength 3>"],
"weaknesses": ["<weakness 1>", "<weakness 2>", "<weakness 3>"],
"opportunities": ["<opportunity 1>", "<opportunity 2>", "<opportunity 3>"],
"threats": ["<threat 1>", "<threat 2>", "<threat 3>"]
},
"goToMarket": {
"phase1": {"name": "Launch (Month 1-3)", "strategy": "<specific strategy>", "channels": ["<channel1>", "<channel2>"], "targetMetric": "<metric to hit>", "budget": "<estimated budget>"},
"phase2": {"name": "Growth (Month 4-8)", "strategy": "<specific strategy>", "channels": ["<channel1>", "<channel2>"], "targetMetric": "<metric to hit>", "budget": "<estimated budget>"},
"phase3": {"name": "Scale (Month 9-12)", "strategy": "<specific strategy>", "channels": ["<channel1>", "<channel2>"], "targetMetric": "<metric to hit>", "budget": "<estimated budget>"},
"viralPotential": "<low|medium|high>",
"viralMechanism": "<how it could spread organically>",
"earlyAdopters": "<who to target first and why>"
},
"fundingAssessment": {
"currentStage": "<idea|pre-seed|seed|series-a>",
"readiness": "<not ready|almost ready|ready>",
"recommendedRaise": "<amount to raise>",
"valuationRange": "<estimated pre-money valuation range>",
"keyMilestonesNeeded": ["<milestone 1>", "<milestone 2>", "<milestone 3>"],
"investorFit": ["<type of investor 1>", "<type of investor 2>"],
"pitchStrength": "<what makes this pitch compelling to investors>"
},
"feasibility": {
"technicalComplexity": "<low|medium|high>",
"technicalNote": "<key technical considerations>",
"timeToMVP": "<realistic time estimate>",
"estimatedCost": "<cost range to build MVP>",
"teamNeeded": ["<role1>", "<role2>", "<role3>"],
"biggestTechnicalRisk": "<main technical risk>",
"techStack": "<recommended technology stack>"
},
"riskMatrix": [
{"risk": "<risk description>", "category": "<market|technical|financial|operational|legal>", "probability": "<low|medium|high>", "impact": "<low|medium|high>", "severity": "<low|medium|high|critical>", "mitigation": "<specific mitigation strategy>"}
],
"pivotSuggestions": [
{"pivot": "<pivot idea>", "reasoning": "<why this pivot could work>", "effort": "<low|medium|high>"}
],
"similarSuccesses": [
{"company": "<company name>", "similarity": "<how it is similar>", "outcome": "<what happened - funding, acquisition, revenue>", "lessonToApply": "<key takeaway>"}
],
"ninetyDayPlan": [
{"week": "Week 1-2", "action": "<specific action>", "deliverable": "<concrete deliverable>", "goal": "<measurable goal>"},
{"week": "Week 3-4", "action": "<specific action>", "deliverable": "<concrete deliverable>", "goal": "<measurable goal>"},
{"week": "Week 5-6", "action": "<specific action>", "deliverable": "<concrete deliverable>", "goal": "<measurable goal>"},
{"week": "Week 7-8", "action": "<specific action>", "deliverable": "<concrete deliverable>", "goal": "<measurable goal>"},
{"week": "Week 9-10", "action": "<specific action>", "deliverable": "<concrete deliverable>", "goal": "<measurable goal>"},
{"week": "Week 11-12", "action": "<specific action>", "deliverable": "<concrete deliverable>", "goal": "<measurable goal>"}
],
"pitchDeckOutline": [
{"slide": 1, "title": "Problem", "content": "<what to include on this slide>"},
{"slide": 2, "title": "Solution", "content": "<what to include>"},
{"slide": 3, "title": "Market Size", "content": "<what to include>"},
{"slide": 4, "title": "Product", "content": "<what to include>"},
{"slide": 5, "title": "Business Model", "content": "<what to include>"},
{"slide": 6, "title": "Traction", "content": "<what to include>"},
{"slide": 7, "title": "Competition", "content": "<what to include>"},
{"slide": 8, "title": "Team", "content": "<what to include>"},
{"slide": 9, "title": "Financials", "content": "<what to include>"},
{"slide": 10, "title": "The Ask", "content": "<what to include>"}
]
}
CRITICAL INSTRUCTIONS:
- Return ONLY raw JSON. No markdown. No code blocks. No explanatory text.
- Every field must be filled with substantive, specific content (no generic placeholders).
- Dollar figures should be realistic and well-reasoned.
- Competitor names should be real companies when possible.
- The 90-day plan should be actionable and specific.
- Risk matrix should have 4-6 risks covering market, technical, financial, and operational categories.
- Include 3+ direct competitors, 2+ indirect competitors, and 2+ potential competitors.
- Pivot suggestions should have 2-3 options.
- Similar successes should reference 3+ real companies.`;
const text = await callAI(prompt);
return parseJSON(text);
}
module.exports = { validateIdea };