🚀 Live Deployment: https://fin-sight-beta-pied.vercel.app/
FinSight AI is a production-grade autonomous agent that acts as a senior financial analyst. It takes a company name as input, orchestrates a multi-agent workflow to conduct deep research (fetching hard financial metrics and scraping real-time news), synthesizes the findings, and delivers a final institutional-grade verdict: INVEST, WATCHLIST, or PASS, along with a detailed Devil's Advocate committee review.
- Node.js (v18+)
- API Keys: Google AI Studio (Gemini), Groq, Alpha Vantage, and Tavily.
Clone the repository and install dependencies:
npm installCreate a .env.local file in the root directory and add your API keys:
GOOGLE_API_KEY=your_gemini_key
TAVILY_API_KEY=your_tavily_key
ALPHA_VANTAGE_API_KEY=your_alpha_vantage_key
GROQ_API_KEY=your_groq_keyStart the Next.js development server:
npm run devOpen http://localhost:3000 in your browser.
The application is built on a modern Next.js stack, using LangGraph.js to orchestrate the AI workflow.
The Multi-Agent Graph Architecture:
- Sequential Fan-Out: The graph executes 5 core research nodes sequentially (Business Model, Financials, Competition, Leadership/News, Risk Factors). We specifically chose sequential execution to strictly adhere to token-per-minute (TPM) limits on free-tier LLM APIs, preventing rate-limit crashes.
- Specialized Tools:
financialsNodeuses the Alpha Vantage API for perfectly structured, hallucination-free JSON quantitative data.- Other nodes use the Tavily Search API for real-time web scraping.
- Deep Synthesis: The graph then generates a Bull Case, Bear Case, Moat Analysis, and Catalysts report.
- The Verdict: Finally, the
synthesisNodeacts as the lead analyst, grading the company across 5 dimensions and outputting an INVEST/PASS verdict. This is immediately challenged by acommitteeNodeacting as a Devil's Advocate to ensure objectivity.
The "Waterfall" LLM Fallback System:
To guarantee 100% uptime, the gemini.js orchestrator utilizes a custom fallback wrapper. It attempts to use gemini-2.5-flash first. If Google imposes a rate-limit block, it seamlessly falls back to gemini-1.5-flash (larger quota), and if Google fails entirely, it instantly reroutes the request to Groq's open-source llama-3.3-70b-versatile model.
- LangGraph vs. standard LangChain: I chose LangGraph for precise state management and node separation rather than a standard ReAct agent, as financial verdicts require highly structured, deterministic steps rather than open-ended agentic loops.
- Sequential vs. Parallel Execution: While LangGraph excels at parallel node execution, I explicitly forced sequential edges. Trade-off: The report takes slightly longer to generate (60 seconds), but this ensures the application remains highly stable and crash-free on free-tier LLM API rate limits (12k TPM).
- Alpha Vantage vs. Web Scraping: Financial numbers scraped from web articles are often hallucinated or outdated. I traded slightly higher API complexity to strictly fetch JSON metrics via Alpha Vantage, guaranteeing that P/E ratios and Market Caps are mathematically accurate. (Note: The agent uses a fast LLM call to resolve raw company names into valid ticker symbols automatically).
- Serverless State Management: I chose to omit in-memory caching and rate-limiting from the Next.js API route. Because Vercel utilizes stateless Serverless functions, in-memory Maps do not persist reliably across requests or regions. For production rate-limiting, I would integrate Vercel KV or Upstash Redis.
Here is an example of a complete, institutional-grade report generated for NVIDIA (NVDA). The autonomous agent successfully evaluated the company's financial health, generated contrasting bull/bear arguments, and conducted a Devil's Advocate review.
- Database Persistence: I would add a PostgreSQL database (via Prisma) to cache finalized reports, saving API costs and providing users with a historical dashboard of their research.
- Streaming Output: While the UI receives node-by-node progress updates, I would implement token-by-token streaming via Server-Sent Events (SSE) within the markdown components to make the UI feel even faster.
- Deeper Quantitative Agent: I would introduce a Python-based sub-agent that executes a discounted cash flow (DCF) model based on historical SEC 10-K filings.


