FinFetch is a comprehensive financial analysis platform that provides real-time stock tracking, AI-powered financial insights, and market news aggregation. This full-stack application combines a modern React frontend with a robust FastAPI backend and MongoDB database to deliver a professional-grade financial toolset.
- Features
- Technology Stack
- System Architecture
- Installation
- Configuration
- Usage
- API Documentation
- Frontend Components
- Data Flow
- Database Schema
- Contributing
- License
- Acknowledgments
FinFetch offers a comprehensive suite of financial tools and features:
- Secure account creation and login
- JWT-based authentication
- User profile management
- Password reset functionality
- Interactive stock price charts with multiple timeframes (1D, 1W, 1M, 3M, 1Y, ALL)
- Real-time stock quotes with price updates
- Historical price data visualization
- Comprehensive financial metrics and company information
- Personal watchlist creation and management
- AI-powered financial chatbot for answering investment questions
- Context-aware responses with stock data integration
- Conversation history and session management
- Multi-stock context for comparative analysis
- Real-time financial news from premium RSS feeds
- Category-based news filtering (Market, Stocks, Economy, Crypto)
- News search functionality
- Stock-specific news integration
- Sentiment analysis for news articles
- Full mobile responsiveness across all pages
- Adaptive layouts for different screen sizes
- Touch-friendly interface
- Cross-browser compatibility
- Dark/Light theme toggle
- Personalized watchlists
- Customizable dashboard
- FastAPI: High-performance, modern Python web framework
- MongoDB: NoSQL database for flexible data storage
- Motor: Asynchronous MongoDB driver
- PyJWT: JSON Web Token implementation
- Google Generative AI: AI-powered financial assistant
- Pydantic: Data validation and settings management
- Feedparser: RSS feed parsing for news sources
- HTTPX: Asynchronous HTTP client for API calls
- React: Frontend UI library
- Vite: Next-generation frontend tooling
- React Router: Client-side routing
- Chart.js: Interactive financial charts
- Axios: Promise-based HTTP client
- React-Icons: Icon components library
- React-Toastify: Toast notifications
- CSS Variables: For theming and customization
- Financial Modeling Prep (FMP): Stock price data, company profiles
- Finnhub: Real-time quotes, company news, financials
- Various Financial News RSS Feeds: CNBC, Yahoo Finance, MarketWatch, etc.
FinFetch follows a modern, modular architecture pattern:
ββββββββββββββββββ βββββββββββββββββ ββββββββββββββββββ
β β β β β β
β React ββββββΊβ FastAPI ββββββΊβ MongoDB β
β Frontend β β Backend β β Database β
β β β β β β
ββββββββββββββββββ βββββββββ¬ββββββββ ββββββββββββββββββ
β
βββββββββββΌβββββββββββ
β β
β External APIs β
β & RSS Feeds β
β β
ββββββββββββββββββββββ
The application is structured with:
- Clear Separation of Concerns: Backend, frontend, and database layers are decoupled
- RESTful API Design: Predictable, resource-oriented URLs and standard HTTP methods
- Component-Based Architecture: Reusable React components
- Asynchronous Processing: Non-blocking I/O operations throughout the stack
- Data Caching Strategy: Optimized data fetching and storage to minimize external API calls
Before you begin, ensure you have the following installed:
- Python 3.8+
- Node.js 16+ and npm
- MongoDB 4.4+
- Git
-
Clone the repository:
git clone https://github.com/abhishek-kr01/FinFetch.git cd financial-app -
Set up a Python virtual environment:
cd backend python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.envfile in the backend directory (see Configuration section for details)
-
Navigate to the frontend directory:
cd ../frontend -
Install dependencies:
npm install
-
Create a
.envfile in the frontend directory (see Configuration section for details)
-
Install MongoDB Community Edition from the official website.
-
Start MongoDB service:
# On Windows (as a service) # MongoDB should start automatically after installation # On macOS (with Homebrew) brew services start mongodb-community # On Linux sudo systemctl start mongod
-
Create a database for the project:
mongosh > use financial_app > exit
# App settings
DEBUG=True
HOST=0.0.0.0
PORT=8000
# Frontend URL for CORS
FRONTEND_URL=http://localhost:5173
# JWT settings
JWT_SECRET_KEY=your_secret_key_change_this_in_production
JWT_ALGORITHM=HS256
# MongoDB settings
MONGO_URI=mongodb://localhost:27017
MONGO_DB_NAME=financial_app
# External API keys
FMP_API_KEY=your_fmp_api_key
FINNHUB_API_KEY=your_finnhub_api_key
GEMINI_API_KEY=your_gemini_api_key
# Logging settings
LOG_LEVEL=INFO
VITE_API_BASE_URL=http://localhost:8000/api
VITE_DEFAULT_STOCK=IBM
To use all features of FinFetch, you'll need to obtain API keys from:
-
Financial Modeling Prep (FMP):
- Register at Financial Modeling Prep
- Add your key to the
FMP_API_KEYenvironment variable
-
Finnhub:
- Register at Finnhub
- Add your key to the
FINNHUB_API_KEYenvironment variable
-
Google Generative AI (For Gemini):
- Get API key from Google AI Studio
- Add your key to the
GEMINI_API_KEYenvironment variable
cd backend
source venv/bin/activate # On Windows: venv\Scripts\activate
python main.pyThe FastAPI backend will be available at http://localhost:8000. API documentation can be accessed at http://localhost:8000/docs.
cd frontend
npm run devThe React frontend will be available at http://localhost:5173.
For production deployment, it's recommended to use Gunicorn with Uvicorn workers:
pip install gunicorn
cd backend
gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:appYou may also want to set up a reverse proxy with Nginx.
Build the frontend for production:
cd frontend
npm run buildThis will create a dist directory with optimized static files that can be served with Nginx or any other static file server.
The FastAPI backend automatically generates interactive API documentation at /docs endpoint. The main API routes include:
POST /api/auth/register- Create a new user accountPOST /api/auth/login- Authenticate and receive JWT tokenPOST /api/auth/password-reset- Request password resetGET /api/auth/me- Get current user information
GET /api/stocks/quotes/{symbol}- Get real-time quote for a stockPOST /api/stocks/quotes/batch- Get quotes for multiple stocksPOST /api/stocks/historical- Get historical price dataGET /api/stocks/financials/{symbol}- Get financial metricsPOST /api/stocks/search- Search for stocksGET /api/stocks/popular- Get popular/trending stocksGET /api/stocks/watchlist- Get user's watchlistPUT /api/stocks/watchlist- Update watchlistPOST /api/stocks/watchlist/{symbol}- Add to watchlistDELETE /api/stocks/watchlist/{symbol}- Remove from watchlist
GET /api/news/latest- Get latest financial newsPOST /api/news/search- Search news articlesPOST /api/news/filter- Filter news by categoryPOST /api/news/by-symbols- Get news for specific stocksGET /api/news/trending- Get trending financial newsGET /api/news/categories- Get available news categories
POST /api/chatbot/chat- Send message to AI assistantGET /api/chatbot/history/{session_id}- Get chat historyGET /api/chatbot/sessions- Get user's chat sessionsPOST /api/chatbot/sessions- Create a new chat sessionPUT /api/chatbot/sessions/{session_id}- Update a chat sessionDELETE /api/chatbot/sessions/{session_id}- Delete a chat session
GET /api/users/me- Get current user profilePUT /api/users/me- Update user profilePUT /api/users/me/watchlist- Update user watchlistDELETE /api/users/me- Delete user account
The frontend is structured with reusable components:
MainLayout- Primary layout for most pagesAuthLayout- Layout for authentication pages
Button- Customizable button componentCard- Container for content blocksHeader- Site navigation headerFooter- Site footerLoadingIndicator- Loading spinnerLogo- Application logoSearchBar- Stock search component
StockChart- Interactive price chartStockInfo- Company and financial informationStockNews- Company-specific newsWatchlist- User's saved stocksMarketOverview- Popular stocks display
LoginForm- User loginRegisterForm- New account creationForgotPasswordForm- Password reset
ChatInterface- AI assistant interfaceChatMessage- Individual message displaySymbolPicker- Stock context selector
NewsCard- Individual news articleNewsFilters- Category filtersNewsSearch- Search functionality
FinFetch implements a sophisticated data flow to provide real-time financial information while minimizing external API calls:
- Client Request: User requests stock data via frontend
- API Router: Backend API endpoint receives request
- Database Check: System checks MongoDB for recent data
- Data Freshness Check: System verifies if cached data is still valid
- Stock quotes: 5 minutes
- Financial metrics: 24 hours
- News articles: Stored indefinitely but refreshed periodically
- External API Call: If data is stale or not found, system calls external APIs
- Data Storage: Fresh data is stored in MongoDB
- Response: Data is returned to frontend
- Rendering: Frontend renders data in appropriate components
This approach balances real-time data with efficient resource usage and API rate limit considerations.
FinFetch uses MongoDB with the following collections:
{
"_id": ObjectId,
"email": String (unique),
"username": String (unique),
"password": String (hashed),
"first_name": String (optional),
"last_name": String (optional),
"created_at": DateTime,
"updated_at": DateTime,
"is_active": Boolean
}{
"_id": ObjectId,
"user_id": String,
"symbols": Array<String>,
"updated_at": DateTime
}{
"_id": ObjectId,
"symbol": String,
"price": Number,
"change": Number,
"change_percent": Number,
"volume": Number,
"market_cap": Number,
"pe_ratio": Number,
"timestamp": DateTime
}{
"_id": ObjectId,
"symbol": String,
"date": DateTime,
"open": Number,
"high": Number,
"low": Number,
"close": Number,
"volume": Number,
"created_at": DateTime
}{
"_id": ObjectId,
"symbol": String,
"company_name": String,
"sector": String,
"industry": String,
"market_cap": Number,
"pe_ratio": Number,
"eps": Number,
"dividend_yield": Number,
"revenue": Number,
"revenue_growth": Number,
"profit_margin": Number,
"debt_to_equity": Number,
"price_to_book": Number,
"rsi": Number,
"beta": Number,
"fifty_day_ma": Number,
"two_hundred_day_ma": Number,
"timestamp": DateTime
}{
"_id": ObjectId,
"headline": String,
"summary": String,
"source": String,
"date": DateTime,
"url": String,
"image": String (optional),
"symbol": String (optional),
"category": String,
"sentiment": {
"score": Number,
"label": String
},
"created_at": DateTime
}{
"_id": ObjectId,
"user_id": String,
"title": String,
"context": Object,
"created_at": DateTime,
"updated_at": DateTime
}{
"_id": ObjectId,
"user_id": String,
"session_id": String,
"content": String,
"is_user": Boolean,
"timestamp": DateTime
}Contributions to FinFetch are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -am 'Add new feature' - Push to the branch:
git push origin feature/my-feature - Submit a pull request
Please ensure your code follows the project's style guidelines and includes appropriate tests.
- Use async/await for all database operations
- Write docstrings for all functions and classes
- Follow PEP 8 style guide for Python code
- Use functional components and hooks for React components
- Write unit tests for new functionality
FinFetch makes use of the following open-source projects and APIs: