FinSonar
- Your AI-powered, real-time, research-driven assistant for Indian stock market insights and recommendations :)
- Our mission is to democratize access to advanced financial intelligence, making the Indian stock market more transparent, accessible, and profitable for everyone.
🧩 Overview
FinSonar is a web-based tool tailored for Indian investors, traders, and analysts, providing real-time insights into the Indian stock market (BSE and NSE). Powered by the Perplexity Sonar API, FinSonar delivers actionable intelligence on stocks like RELIANCE, TCS, and HDFCBANK through a daily newsletter, portfolio analysis, and investment tip evaluation. Key features include:
- Real-time updates on Indian stock market movements.
- Clear, citation-backed explanations of market events.
- User-friendly subscription system for daily insights with unsubscribe functionality.
- Portfolio analysis with stock-wise recommendations.
- Evaluation of investment tips from text or images.
🌟 Inspiration
The Indian stock market, with its dynamic growth and increasing retail investor participation, lacks accessible, real-time, and trustworthy tools tailored for local investors. We were inspired by the need to empower Indian investors—novices and experts alike—with clear, data-driven insights. The Perplexity Sonar API’s ability to provide real-time, reasoned, and citation-backed responses motivated us to build FinSonar as a reliable companion for navigating the complexities of stocks like those in the Nifty 50 and Sensex.
🚀 What it does
FinSonar equips users with tools to make informed investment decisions in the Indian stock market:
- Daily Newsletter: Delivers market insights, key stock movements, and explanations at 8 AM IST, with easy subscribe/unsubscribe options.
- Portfolio Analysis: Users upload a portfolio (CSV/Excel or text) to receive stock-specific recommendations, such as holding or selling
ASIANPAINTbased on market trends. - Investment Tip Analysis: Evaluates user-submitted tips (text or images) for credibility, e.g., assessing whether to "Buy RELIANCE due to a new energy deal."
- Reasoned Insights: Provides clear, citation-backed explanations for stock movements, like why
HDFCBANKdropped 3% due to RBI rate hikes. - Planned Features: Top gainers/losers, simplified explanations (e.g., "Explain Nifty 50 like I’m 5"), and fundamental analysis for Indian companies.
All insights leverage the Perplexity Sonar API for real-time data, news, and sentiment analysis from sources like Moneycontrol, Economic Times, and X posts.
🛠️ How we built it
We built FinSonar using a modern tech stack to ensure scalability, responsiveness, and seamless integration with the Perplexity Sonar API:
- Frontend: Developed with React and Vite.js, styled using Tailwind CSS and shadcn/ui for a responsive UI handling subscription forms, portfolio uploads, and tip analysis.
- Backend: Built with FastAPI (Python) for efficient API endpoints, integrated with the Perplexity Sonar API for real-time market insights and reasoning.
- Database: Used MongoDB to store newsletter subscriptions with a unique email index.
- Scheduler: Implemented APScheduler to trigger daily newsletters at 8 AM IST.
- Email Delivery: Configured SMTP (e.g., Gmail) to send HTML newsletters with insights.
- File Handling: Enabled CSV/Excel portfolio uploads and image-based tip analysis using Python libraries like
pandasandopenpyxl. - Sonar API Integration: Leveraged Sonar’s search and reasoning capabilities to fetch and synthesize data for newsletters, portfolio recommendations, and tip evaluations.
We followed an agile development approach, iterating on user feedback and testing APIs with tools like Postman to ensure robustness.
🔧 Features & How Perplexity Sonar API Is Used
1. 📰 Daily Indian Stock Market Newsletter
- What: Users subscribe to receive daily insights on Indian stocks via email, with an option to unsubscribe.
- How: A frontend form sends a POST request to
/api/newsletter/subscribe. A daily APScheduler job at 8 AM IST fetches insights via the Sonar API and sends HTML emails. Unsubscribe requests hit/api/newsletter/unsubscribe. - Sonar API: The
get_market_insightsfunction queries Sonar for news, analyst commentary, and X post sentiment, summarizing key drivers for stocks likeTCSwith citations (e.g., BSE announcements).
2. 🧠 Reasoned Explanations for Indian Stock Events
- What: Explains stock movements (e.g., "Why did SBIN rise 2%?") with clear, sourced reasoning.
- How: The
get_market_insightsfunction uses Sonar Reasoning to analyze earnings, macroeconomic factors (e.g., RBI policies), or sector trends. - Sonar API: Synthesizes data from multiple sources, correlating events like RBI rate hikes with
HDFCBANKperformance, including links to credible sources.
3. 📈 Top Gainers and Losers (Planned)
- What: Will highlight top-performing and underperforming Indian stocks in the newsletter.
- How: The
/market/gainers-losersendpoint will fetch data using Sonar, filtering for BSE/NSE tickers. - Sonar API: Queries real-time market data to identify stocks like
RELIANCEwith reasons for movement.
4. 🔍 Explain Like I’m 5 / 15 / 50 (Planned)
- What: Simplifies complex concepts (e.g., "What is Nifty 50?") for different user levels.
- How: Future interactive features will use Sonar Reasoning to tailor explanations.
- Sonar API: Adjusts response complexity, e.g., explaining P/E ratios for beginners or SEBI regulations for experts.
5. 📊 Portfolio Analysis
- What: Analyzes user-uploaded portfolios (CSV/Excel or text) for stock-wise recommendations.
- How: Users upload files via
/upload-portfolioor submit text via/analyze-portfolio-text. The backend parses data and queries Sonar for insights. - Sonar API: Fetches stock-specific data (e.g., financials, sentiment) to recommend actions like "Hold ASIANPAINT" with citations.
6. 💡 Investment Tip Analysis
- What: Evaluates user-submitted tips (text or images) for credibility.
- How: Text tips are sent to
/api/tip/analyze, and images to/api/tip/analyze-image. Sonar Reasoning assesses validity against market data. - Sonar API: Cross-references tips (e.g., "Buy RELIANCE due to energy deal") with news and provides pros, cons, and citations.
7. 🧮 Financial Independence Planner (FIRE):
- Create detailed, personalized plans for financial independence using inputs like age, salary, marital status, and more.
- How It Works:
- User Just need to fill FIRE planner form. -Sonar API Usage : Analyzes age, salary,..etc and provides a reasoned FIRE detail plan.
🌐 API Endpoints
The following table lists FinSonar’s API endpoints, their descriptions, and their usage of the Perplexity Sonar API:
| Endpoint | Method | Description | Sonar API Usage | Status | Example Response |
|---|---|---|---|---|---|
/market/insights |
GET | Fetches real-time market insights for Indian stocks (e.g., Nifty 50, Sensex trends). | Queries Sonar for news, analyst commentary, and X posts, summarizing key drivers with citations. | Available | "Strong IT sector performance boosted TCS" with source links. |
/market/gainers-losers |
GET | Retrieves top gainers and losers in the Indian stock market. | Queries Sonar for real-time performance data for BSE/NSE tickers. | Planned | "HDFCBANK +3%, SBIN -2%" with reasons and citations. |
/books |
GET | Provides a list of recommended finance books relevant to Indian markets. | Queries Sonar for curated book recommendations with India-specific context. | Available | Books like "The Intelligent Investor" with summaries. |
/books/learnings?book_name={bookName} |
GET | Fetches key learnings from a specified finance book, contextualized for Indian markets. | Uses Sonar Reasoning to summarize takeaways and relate to Indian investing. | Planned | Value investing principles applied to RELIANCE. |
/books/finance-question?question={question} |
POST | Answers user-submitted finance questions about the Indian market. | Uses Sonar Reasoning for detailed, citation-backed answers. | Planned | Explanation of RBI rate hikes’ impact on HDFCBANK. |
/companies |
GET | Lists Indian companies with relevant market data. | Queries Sonar for company profiles and recent news for BSE/NSE firms. | Available | Data on TCS, INFY with market cap and sector details. |
/companies/fundamental-analysis?company_name={companyName} |
GET | Provides fundamental analysis for a specified Indian company. | Queries Sonar for financial metrics (e.g., P/E ratio) and analyst reports. | Planned | Metrics and growth outlook for RELIANCE. |
/api/newsletter/subscribe |
POST | Subscribes a user’s email to the daily newsletter. | None; stores email in MongoDB. | Available | Success message for subscription. |
/api/newsletter/unsubscribe |
POST | Unsubscribes a user’s email from the newsletter. | None; deletes email from MongoDB. | Available | Success message for unsubscription. |
/upload-portfolio |
POST | Uploads a portfolio file (CSV/Excel) for stock-wise analysis. | Queries Sonar for insights on each stock, providing recommendations. | Available | "Hold ASIANPAINT due to stable demand" with citations. |
/analyze-portfolio-text |
POST | Analyzes portfolio data submitted as text. | Queries Sonar for stock-specific insights based on parsed text. | Available | Recommendations for each stock in the portfolio. |
/api/tip/analyze |
POST | Analyzes a user-submitted text investment tip for credibility. | Uses Sonar Reasoning to evaluate against market data and news. | Available | Pros, cons, and citations for "Buy RELIANCE due to energy deal". |
/api/tip/analyze-image |
POST | Analyzes an investment tip from an uploaded image (e.g., screenshot). | Extracts text and uses Sonar Reasoning to evaluate validity. | Available | Analysis with pros, cons, and citations for image-based tips. |
🖥️ Tech Stack
- Frontend: React/Vite.js, Tailwind CSS, shadcn/ui.
- Backend: FastAPI (Python).
- Sonar API: Perplexity Sonar for real-time insights and reasoning.
- Database: MongoDB for subscriptions.
- Scheduler: APScheduler for newsletters.
- Email: SMTP for HTML newsletters.
- File Handling: CSV/Excel and image uploads via
pandas,openpyxl, andpython-multipart. - Data Sources: Sonar API integrates news, BSE/NSE data, and X post sentiment.
🧗 Challenges we ran into
- API Integration: Integrating the Perplexity Sonar API to fetch India-specific data required fine-tuning queries to filter out irrelevant global results.
- Real-Time Data: Ensuring timely and accurate market insights for dynamic stocks like
RELIANCEwas challenging due to the fast-paced nature of market news. - File Parsing: Handling diverse portfolio file formats (CSV/Excel) and ensuring consistent parsing for analysis demanded robust error handling.
- Newsletter Scheduling: Setting up APScheduler to reliably trigger at 8 AM IST across time zones required careful configuration.
- Image Analysis: Extracting and validating text from image-based tips (e.g., screenshots) posed technical hurdles in OCR integration with Sonar.
🏆 Accomplishments that we're proud of
- Built a fully functional subscription system with a daily newsletter delivering real-time Indian stock insights.
- Successfully integrated the Perplexity Sonar API to provide citation-backed, reasoned insights tailored to Indian markets.
- Developed robust portfolio analysis for CSV/Excel and text inputs, offering actionable stock recommendations.
- Created a tip analysis feature that evaluates both text and image inputs, enhancing user trust in investment decisions.
- Designed a scalable backend with FastAPI and MongoDB, ready for future enhancements like dashboards and alerts.
📚 What we learned
- Sonar API Capabilities: Gained deep insights into leveraging the Perplexity Sonar API for real-time data synthesis and reasoning, especially for niche markets like India.
- Indian Market Nuances: Understood the importance of local context (e.g., RBI policies, SEBI regulations) in stock analysis.
- Full-Stack Development: Improved skills in integrating React frontends with FastAPI backends, handling file uploads, and scheduling tasks.
- User-Centric Design: Learned to prioritize clear, accessible insights for diverse users, from beginners to seasoned investors.
- Error Handling: Mastered robust error handling for file parsing and API responses to ensure a smooth user experience.
🔮 What's next for FinSonar
- Integrate top gainers/losers into the daily newsletter for a comprehensive market overview.
- Develop an interactive dashboard for real-time stock queries and visualizations using
/market/insightsand/companies/fundamental-analysis. - Add push notifications for significant market events (e.g., RBI announcements).
- Enhance tip analysis with sentiment scoring and historical performance comparisons.
- Introduce graphical portfolio visualizations (e.g., returns, risk metrics) to improve user engagement.
- Expand to include watchlist creation and real-time stock alerts for users.
🛠️ Setup Instructions
- Clone the Repository:
git clone https://github.com/thekavikumar/FinSonar.git
cd finsonar
- Backend Setup:
- Install dependencies:
bash pip install fastapi uvicorn pymongo python-dotenv apscheduler pandas openpyxl python-multipart - Create a
.envfile in the backend directory:MONGO_URI=mongodb://localhost:27017 PERPLEXITY_API_KEY=your_perplexity_api_key SMTP_SERVER=smtp.gmail.com SMTP_PORT=587 SMTP_USER=your_email@gmail.com SMTP_PASSWORD=your_app_specific_password - Run MongoDB and start the FastAPI server:
bash uvicorn backend.src.main:app --reload
- Frontend Setup:
- Navigate to the frontend directory:
bash cd frontend - Install dependencies:
bash npm install - Create a
.envfile:VITE_PUBLIC_BACKEND_URL=http://localhost:8000 - Start the development server:
bash npm run dev
- Test the Newsletter:
- Subscribe via the frontend form.
- Verify email storage in MongoDB (
newsletter_db.newsletter_subscriptions). - Trigger the newsletter manually or wait for 8 AM IST.
- Test API Endpoints:
curl http://localhost:8000/market/insights
curl -X POST http://localhost:8000/api/newsletter/subscribe -H "Content-Type: application/json" -d '{"email":"test@example.com"}'
curl -X POST http://localhost:8000/upload-portfolio -H "Content-Type: multipart/form-data" -F "file=@portfolio.csv"
📞 Contact
Developed with ❤️ by:
Built With
- fastapi
- langchain
- mongodb
- perplexity
- python
- react-js
- render
- sonar-api
- sonar-pro
- sonar-pro-reasoning
- tailwindcss
- typescript
- vercel

Log in or sign up for Devpost to join the conversation.