Skip to content

AustinBoyuJiang/Stock-Explain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Stock Explain

An AI-powered stock analysis platform that provides real-time market intelligence, sentiment analysis, and trend insights.

Features

  • Real-time Stock Analysis: AI agent searches and analyzes market data for any stock ticker
  • Streaming Search Process: Watch the AI agent work in real-time as it gathers information
  • Market Sentiment: Get insights on social media opinions and market perception
  • Trend Analysis: Understand current market trends and future outlook
  • News Integration: Latest headlines and market-moving news

Quick Start

Prerequisites

  • Python 3.8+
  • Node.js 16+
  • npm or yarn

Environment Setup

  1. Backend Setup:

    cd backend
    pip install -r requirements.txt
  2. Create .env file in backend directory:

    REKA_API_KEY=your_reka_api_key_here
    BRIGHTDATA_API_KEY=your_brightdata_api_key_here
    BRIGHTDATA_PROXY_USER=your_proxy_user
    BRIGHTDATA_PROXY_PWD=your_proxy_password
    BRIGHTDATA_BROWSER_USER=your_browser_user
    BRIGHTDATA_BROWSER_PWD=your_browser_password
  3. Frontend Setup:

    cd frontend
    npm install

Running the Application

Option 1: Use the startup script (Recommended)

python start_dev.py

Option 2: Manual startup

# Terminal 1 - Backend
cd backend
python api.py

# Terminal 2 - Frontend
cd frontend
npm run dev

Access the Application

Usage

  1. Search for a Stock: Enter any stock ticker (e.g., NVDA, TSLA, AAPL) in the search bar
  2. Watch the AI Work: See real-time updates as the AI agent searches and analyzes data
  3. Get Insights: Receive comprehensive analysis including:
    • Market trends and sentiment
    • Recent news and social media opinions
    • Technical analysis and outlook
    • Key market drivers

Architecture

Backend (/backend)

  • FastAPI: REST API with streaming support
  • Agent Search: AI-powered web search and analysis
  • Reka AI: Language model for analysis and summarization
  • Bright Data: Web scraping and data collection

Frontend (/frontend)

  • React + TypeScript: Modern web interface
  • Vite: Fast development and build tool
  • Tailwind CSS: Utility-first styling
  • Radix UI: Accessible component library

API Endpoints

POST /search

Analyze a stock with AI agent

Request:

{
  "prompt": "Analyze NVDA stock trends and sentiment",
  "max_steps": 6,
  "stream": true
}

Response (Streaming):

data: {"type": "init", "timestamp": "2025-01-25T10:30:00Z", "prompt": "..."}
data: {"type": "step_update", "step": 1, "action": "serp_search", "payload": {...}}
data: {"type": "tool_result", "preview": {"text": "Found 10 results...", "data": [...]}}
data: {"type": "final_answer", "content": "Analysis summary..."}
data: {"type": "complete", "success": true, "final_result": "..."}

Development

Project Structure

├── backend/           # FastAPI backend
│   ├── api.py        # Main API server
│   ├── agent_search.py # AI search agent
│   ├── serp_search.py # Web search functionality
│   └── browse_url.py  # Web scraping
├── frontend/          # React frontend
│   ├── src/
│   │   ├── components/ # UI components
│   │   └── App.tsx    # Main application
└── start_dev.py      # Development startup script

Adding New Features

  1. Backend: Add new endpoints in api.py or extend agent capabilities in agent_search.py
  2. Frontend: Create new components in src/components/ and integrate in App.tsx

Troubleshooting

Common Issues

  1. CORS Errors: Ensure backend CORS is configured for your frontend URL
  2. API Key Issues: Verify all required API keys are set in .env
  3. Port Conflicts: Change ports in respective config files if needed

Logs

  • Backend logs: Check terminal running python api.py
  • Frontend logs: Check browser developer console
  • Network issues: Verify API endpoints in browser Network tab

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

License

This project is licensed under the MIT License.

About

Our project at Cal Hacks 12.0

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published