A real-time market sentiment analysis application that provides AI-powered stock insights by combining price momentum analysis with news sentiment.
- Real-time Market Data: Fetches stock price data from Alpha Vantage API
- News Sentiment Analysis: Integrates latest news headlines from NewsAPI
- AI-Powered Insights: Uses Google Gemini AI to analyze market sentiment
- Interactive Frontend: React-based dashboard with dark/light theme support
- Caching System: 15-minute cache for API responses to optimize performance
- Responsive Design: Built with Tailwind CSS for modern UI/UX
genzoic/
├── main.py # FastAPI backend server
├── frontend/ # React frontend application
│ ├── src/
│ │ ├── components/ # React components
│ │ └── App.jsx # Main application component
│ └── package.json # Frontend dependencies
├── .env # Environment variables (not tracked)
└── README.md # This file
- Python 3.8+
- Node.js 16+
- API keys for:
- Alpha Vantage (stock data)
- NewsAPI (news headlines)
- Google Gemini (AI analysis)
git clone https://github.com/ChristusJoy/genzoic.git
cd genzoic# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install fastapi uvicorn python-dotenv google-generativeai requestsCreate a .env file in the root directory:
cp .env.example .env # If you have an example fileAdd your API keys to .env:
ALPHA_VANTAGE_API_KEY=your_alpha_vantage_api_key_here
NEWS_API_KEY=your_news_api_key_here
GEMINI_API_KEY=your_gemini_api_key_herecd frontend
npm install# From the root directory
source venv/bin/activate # If not already activated
uvicorn main:app --reload --host 0.0.0.0 --port 8000Backend will be available at: http://localhost:8000
# In a new terminal, from the frontend directory
cd frontend
npm run devFrontend will be available at: http://localhost:5173
GET /api/v1/market-pulse?ticker={SYMBOL}
Retrieves market sentiment analysis for a given stock ticker.
ticker(required): Stock symbol (e.g., AAPL, GOOGL, TSLA)
{
"ticker": "AAPL",
"as_of": "2025-08-07",
"momentum": {
"returns": [1.2, -0.5, 2.1, 0.8],
"score": 0.9
},
"news": [
{
"title": "Apple Reports Strong Q3 Earnings",
"description": "Apple Inc. reported better-than-expected earnings...",
"url": "https://example.com/news/article"
}
],
"pulse": "bullish",
"llm_explanation": "The stock shows positive momentum with strong earnings news driving bullish sentiment."
}# Get market pulse for Apple
curl "http://localhost:8000/api/v1/market-pulse?ticker=AAPL"
# Get market pulse for Tesla
curl "http://localhost:8000/api/v1/market-pulse?ticker=TSLA"
# Get market pulse for Google
curl "http://localhost:8000/api/v1/market-pulse?ticker=GOOGL"- FastAPI Framework: Chosen for its async support and automatic API documentation
- Modular Design: Separate functions for data fetching, analysis, and caching
- Error Handling: Comprehensive error handling for API failures and data issues
- CORS Configuration: Configured to allow frontend access from localhost:5173
- Caching Strategy: 15-minute TTL cache to reduce API calls and improve performance
- React 19: Latest React version with modern hooks and features
- Component-Based: Modular components for search, display, and data visualization
- Tailwind CSS: Utility-first CSS framework for rapid UI development
- Theme Support: Dark/light mode toggle with system preference detection
- Responsive Design: Mobile-first approach with responsive breakpoints
- User Input: User enters stock ticker in search bar
- API Request: Frontend sends request to backend
/api/v1/market-pulseendpoint - Data Fetching: Backend fetches data from multiple APIs:
- Alpha Vantage for price data and momentum calculation
- NewsAPI for recent news headlines
- AI Analysis: Google Gemini analyzes combined data to determine market sentiment
- Response: Structured JSON response with pulse, explanation, and raw data
- Caching: Response cached for 15 minutes to optimize subsequent requests
- UI Update: Frontend displays results in user-friendly cards and charts
- API keys stored in environment variables (not in code)
- CORS properly configured for production deployment
- Input validation for ticker symbols
- Error responses don't expose sensitive information
- Caching: 15-minute cache reduces redundant API calls
- Async Operations: All API calls are asynchronous
- Error Handling: Graceful degradation when APIs are unavailable
- Response Size: Limited news articles (5 max) to reduce payload size
- Backend: Add new endpoints in
main.py - Frontend: Create new components in
frontend/src/components/ - Styling: Use Tailwind CSS classes for consistent design
# Test backend endpoint
curl "http://localhost:8000/api/v1/market-pulse?ticker=AAPL"
# Check API documentation
open http://localhost:8000/docs- Set
originsin CORS middleware to your production domain - Use environment-specific configuration files
- Consider rate limiting for production API
- Implement proper logging and monitoring
- Use HTTPS in production
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues:
- Check that all API keys are correctly set in your
.envfile - Ensure all dependencies are installed
- Verify that both backend and frontend servers are running
- Check the console logs for error messages
For additional support, please open an issue on GitHub.