Skip to content

AdityaTakuli/LAMDAAnalytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

LAMDA Supply Chain Risk Analysis System

A comprehensive AI-powered supply chain risk analysis system featuring a complete 7-agent AI pipeline that combines PyTorch machine learning models with real-time external API integration and a modern React frontend.

๐Ÿš€ Features

  • Complete AI Agent Pipeline: 7 specialized AI agents for comprehensive risk analysis
  • Real-time External API Integration: Gemini AI, SERP API, Weather API, Google Maps
  • TGN Model Integration: PyTorch-based risk prediction with fallback mechanisms
  • Async Orchestration: Parallel execution of all AI agents for optimal performance
  • Real-time Monitoring: Live tracking of supply chain disruptions and alerts
  • Interactive Dashboard: Modern React-based interface with real-time updates
  • Comprehensive Risk Analysis: Multi-factor risk assessment with actionable insights

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   React Frontend โ”‚    โ”‚  FastAPI Backend โ”‚    โ”‚  PyTorch TGN   โ”‚
โ”‚   (Port 5175)   โ”‚โ—„โ”€โ”€โ–บโ”‚   (Port 8007)   โ”‚โ—„โ”€โ”€โ–บโ”‚  (tgn_model.pth)โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                              โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚  AI Agent       โ”‚
                    โ”‚  Orchestrator   โ”‚
                    โ”‚  (7 Agents)     โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ–ผ         โ–ผ         โ–ผ
            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
            โ”‚ Gemini   โ”‚ โ”‚ SERP API โ”‚ โ”‚ Weather  โ”‚
            โ”‚ AI API   โ”‚ โ”‚          โ”‚ โ”‚ API      โ”‚
            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿค– AI Agent Pipeline

The system features a complete 7-agent AI pipeline:

  1. ๐Ÿ” Trade Agent โ†’ Gemini AI trade flow analysis
  2. ๐Ÿ“ฐ News Agent โ†’ SERP API โ†’ Web scraping โ†’ Gemini sentiment analysis
  3. ๐ŸŒค๏ธ Weather Agent โ†’ Weather API โ†’ Anomaly detection
  4. ๐Ÿ›๏ธ Political Agent โ†’ Gemini geopolitical risk assessment
  5. ๐ŸŒ GSCPI Agent โ†’ Gemini global supply chain pressure analysis
  6. โš–๏ธ Normalizer Agent โ†’ Feature normalization and scaling
  7. ๐Ÿค– TGN Model โ†’ Trained AI risk prediction
  8. ๐Ÿ“Š Reporter Agent โ†’ Gemini report generation and simplification

๐Ÿ“‹ Prerequisites

  • Python 3.13+
  • Node.js 16+
  • npm or yarn
  • API Keys for external services:
    • Google Gemini API
    • Google Maps API
    • SERP API
    • Weather API (OpenWeather or WeatherAPI)

๐Ÿ› ๏ธ Installation & Setup

1. Clone Repository

git clone https://github.com/iareARiES/LAMDAAnalytics.git
cd LAMDAAnalytics

2. Backend Setup

# Install Python dependencies
cd backend
pip install -r requirements.txt

# Configure API keys
cp .env.example .env
# Edit .env with your API keys:
# GOOGLE_MAPS_API_KEY=your_key
# SERP_API_KEY=your_key
# WEATHER_API_KEY=your_key
# GEMINI_API_KEY=your_key

# Start the backend server
python -m uvicorn main:app --host 127.0.0.1 --port 8007

The backend will be available at: http://127.0.0.1:8007

3. Frontend Setup

# Navigate to frontend directory
cd project2

# Install dependencies
npm install

# Start the development server
npm run dev

The frontend will be available at: http://localhost:5175

4. Quick Start (Windows)

# Start backend (in one terminal)
python start_backend.py

# Start frontend (in another terminal)
start_frontend.bat

๐Ÿ”ง API Endpoints

Core Analysis

  • POST /analyze - Complete AI agent pipeline analysis
  • GET /model/info - Get TGN model information
  • GET /health - Health check

Monitoring & Analytics

  • GET /monitoring/alerts - Get real-time alerts
  • GET /analytics/overview - Get analytics overview

๐Ÿ“Š Usage

  1. Open the Dashboard: Navigate to http://localhost:5175/dashboard
  2. Configure Analysis:
    • Select component type (semiconductors, batteries, etc.)
    • Enter seller location (e.g., "Hsinchu, Taiwan")
    • Enter import location (e.g., "Los Angeles, USA")
    • Enter seller name (e.g., "TSMC")
  3. Run Analysis: Click "Analyze Supply Chain Risk"
  4. View Results:
    • Risk score and level (0-1 scale)
    • Detailed risk factors with percentages
    • AI-generated mitigation strategies
    • Real-time monitoring data

๐Ÿง  AI Model Integration

The system integrates with your PyTorch TGN model (tgn_model.pth) which provides:

  • Risk Prediction: Neural network-based risk scoring
  • Feature Processing: 7 normalized input features
  • Component Analysis: Individual risk factor contributions
  • Fallback Mechanism: Weighted scoring when model unavailable

Input Features (Normalized 0-1)

  • inventory_days: Inventory coverage analysis
  • past_delay_days: Historical delay patterns
  • news_vol_7d: News volume in last 7 days
  • neg_tone_frac_3d: Negative sentiment fraction
  • strike_flag_7d: Labor unrest detection
  • weather_anomaly_7d: Weather anomaly detection
  • global_risk: Global supply chain pressure

๐Ÿ” Risk Analysis Features

  • Real-time News Monitoring: SERP API integration for disruption detection
  • Weather Risk Assessment: Climate-based anomaly detection
  • Political Risk Evaluation: Geopolitical and sanctions monitoring
  • Trade Flow Analysis: Gemini AI-powered trade pattern analysis
  • Global Pressure Monitoring: GSCPI integration for macro trends

๐Ÿ“ˆ Analytics Dashboard

  • Real-time Risk Scoring: Live risk assessment with confidence levels
  • Interactive Route Visualization: Supply chain map with risk overlays
  • Alert Management: Real-time disruption notifications
  • Performance Metrics: Model accuracy and execution times
  • Mitigation Strategies: AI-generated actionable recommendations

๐Ÿš€ Performance

  • Execution Time: ~26 seconds for complete analysis
  • Parallel Processing: All 7 agents execute concurrently
  • Caching: 15-minute TTL for news and weather data
  • Error Handling: Graceful degradation with mock responses
  • Scalability: Designed for high-throughput production use

๐Ÿงช Testing

Run Complete Pipeline Test

# Test the full AI agent pipeline
python run_orchestrator_realtime.py

# Test individual API connections
python test_google_api.py

# Test with mock data
python test_simple_orchestrator.py

API Testing

# Test the complete analysis endpoint
curl -X POST http://127.0.0.1:8007/analyze \
  -H "Content-Type: application/json" \
  -d '{
    "component_type": "Semiconductor",
    "seller_location": "Hsinchu, Taiwan",
    "import_location": "Los Angeles, USA",
    "seller_name": "TSMC"
  }'

๐Ÿšจ Troubleshooting

Backend Issues

  • Ensure Python dependencies are installed: pip install -r backend/requirements.txt
  • Check if model file exists: tgn_model.pth
  • Verify API keys are set in backend/.env
  • Check if port 8007 is available

Frontend Issues

  • Ensure Node.js dependencies are installed: npm install
  • Check if port 5175 is available
  • Verify backend is running on port 8007

API Issues

  • Verify all API keys are valid and have proper permissions
  • Check API quotas and billing status
  • Ensure internet connectivity for external API calls

Model Issues

  • Model file should be in the backend directory
  • Ensure PyTorch is properly installed
  • Check model file integrity

๐Ÿ“ Project Structure

LAMDAAnalytics/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ main.py                 # FastAPI server
โ”‚   โ”œโ”€โ”€ requirements.txt        # Python dependencies
โ”‚   โ”œโ”€โ”€ .env                    # API keys configuration
โ”‚   โ”œโ”€โ”€ tgn_model.pth          # PyTorch TGN model
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ””โ”€โ”€ settings.py        # Configuration management
โ”‚   โ”œโ”€โ”€ orchestrator/
โ”‚   โ”‚   โ”œโ”€โ”€ orchestrator.py    # Main orchestrator
โ”‚   โ”‚   โ”œโ”€โ”€ agents/            # AI agent implementations
โ”‚   โ”‚   โ””โ”€โ”€ utils/             # Utility functions
โ”‚   โ””โ”€โ”€ models/
โ”‚       โ””โ”€โ”€ tgn_model.py       # TGN model wrapper
โ”œโ”€โ”€ project2/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ Dashboard.jsx      # Main dashboard
โ”‚   โ”‚   โ”œโ”€โ”€ SupplyChainMap.jsx # Route visualization
โ”‚   โ”‚   โ””โ”€โ”€ services/
โ”‚   โ”‚       โ””โ”€โ”€ api.js         # API communication
โ”‚   โ””โ”€โ”€ package.json           # Frontend dependencies
โ”œโ”€โ”€ run_orchestrator_realtime.py # Pipeline test script
โ”œโ”€โ”€ test_google_api.py         # API testing script
โ””โ”€โ”€ README.md                  # This file

๐Ÿ”ฎ Future Enhancements

  • Real-time Data Feeds: Integration with live supply chain data
  • Advanced Visualization: 3D route mapping and risk heatmaps
  • Machine Learning: Model retraining and improvement
  • Multi-language Support: Internationalization
  • Mobile App: React Native mobile application
  • Blockchain Integration: Supply chain transparency
  • IoT Integration: Real-time sensor data

๐Ÿ“ License

This project is part of the LAMDA Analytics system for supply chain risk management.

๐Ÿ‘ฅ Team

  • Devansh Behl: Full Stack Development
  • Mayan Sharma: AI/ML Engineering
  • Aditya Takuli: Data Engineering & Analytics
  • Lay Gupta: Product & Business Model

๐Ÿ“ž Support

For support or questions:


Status: โœ… Fully Operational with Real API Integration
Last Updated: September 2025
Version: 2.0 - Complete AI Agent Pipeline

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors