How ashgen12/deep-research-ai-agent works
Project type and purpose
• This is a full-stack AI research agent for the Indian stock market.
• It combines an interactive web UI (Gradio) with a backend “agent” built on LangChain that orchestrates tools to fetch, scrape, and summarize stock data and news.
File structure
• Top-level files:
• main.py – entry point: sets up the Gradio interface and the LangChain agent with tools.
• requirements.txt – lists dependencies (LangChain, Gradio, Deepseek, NSE API library, BeautifulSoup, requests).
• README.md – project overview and setup.
• Directory Interactions: contains modules implementing the individual tools:
• get_52_week_high_stocks
• gather_information
• summarize_insights
README for architectural insights
• Tech stack: Deepseek API (LLM), LangChain (agent framework), Gradio (UI), NSE API (market data), Beautiful Soup (web scraping).
• Workflow: User → Gradio UI → LangChain agent chooses tools → Tools call external services → Agent composes response → UI displays results
Main components
a. Frontend layer
• Gradio interface (hosted by main.py)
b. Backend / Orchestration layer
• LangChain Agent (configured in main.py)
• Tool modules in Interactions/ directory
c. External services
• NSE API (stock data)
• Google News (scraped via Beautiful Soup)
• Deepseek API (LLM for summarization and reasoning)
d. Configuration / Environment
• Deepseek API key (environment variable)
• Other API credentials if needed
Relationships and data flow
• User inputs query in Gradio UI → HTTP call to main.py
• Gradio passes user prompt to the LangChain agent
• LangChain agent analyzes the prompt and invokes one or more tools:
• get_52_week_high_stocks → requests to NSE API
• gather_information → web scraping logic (Beautiful Soup + requests)
• summarize_insights → HTTP call to Deepseek API
• Each tool returns structured data to the agent
• Agent combines tool outputs into final answer
• Gradio returns response to user in browser
Architectural patterns and design principles
• Separation of concerns: UI / Orchestrator / Tools / External services are distinct components
• Plug-in tool architecture via LangChain – easily add, remove, or replace tools in Interactions/
• Single entry point (main.py) that wires UI and agent together
• Environment-driven configuration for secret management
Final advice
• Be exhaustive: capture each distinct component, even if “small.”
• Review the README and code to ensure every piece (e.g., Gradio endpoints, API key management) appears in the architecture.