Skip to content

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Š MacroPulse Copilot

Your Daily Market & Macro Intelligence Platform
India-focused economic analysis with real-time data and AI-powered insights

MacroPulse Copilot Python Flask

🎯 Overview

MacroPulse Copilot is a production-ready Flask web application designed for students and economists to receive daily market and macroeconomic context with plain-English explanations. The platform provides:

  • Real-time Foreign Exchange rates (focus on INR)
  • Commodity prices (Gold, Crude Oil, Silver, Natural Gas)
  • Economic indicators (US Treasury Yields, Interest Rates)
  • Market news aggregation
  • AI-powered analysis explaining India-specific impacts
  • Interactive charts for trend visualization

✨ Features

🌍 India-Focused Analysis

  • All global events are analyzed through the lens of Indian market impact
  • INR-based foreign exchange tracking
  • India-relevant commodity pricing

πŸ€– AI-Powered Insights

  • Plain-English explanations of complex macro concepts
  • Daily market summaries powered by OpenAI GPT
  • Context-aware analysis of global events on Indian economy

πŸ“ˆ Live Interactive Dashboards

  • Real-time data visualization using Chart.js
  • US Treasury yield curves
  • Historical trend analysis
  • Responsive, mobile-friendly design

🎨 Professional UI/UX

  • Subtle, clean interface built with Bootstrap 5
  • Inter font family for modern typography
  • Smooth animations and transitions
  • Fully responsive design

πŸš€ Quick Start

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)
  • OpenAI API key
  • FRED API key

Installation

  1. Clone or download the project
cd macropulse_copilot
  1. Create a virtual environment (recommended)
python -m venv venv

# On Windows
venv\Scripts\activate

# On macOS/Linux
source venv/bin/activate
  1. Install dependencies
pip install -r requirements.txt
  1. Set up environment variables
# Copy the example environment file
cp .env.example .env

# Edit .env and add your API keys
# OPENAI_API_KEY=your_key_here
# FRED_API_KEY=your_key_here
  1. Run the application
python app.py
  1. Access the dashboard
Open your browser and navigate to: http://localhost:5000

πŸ”‘ API Keys Setup

OpenAI API Key

  1. Go to OpenAI Platform
  2. Create an account or sign in
  3. Navigate to API Keys section
  4. Click "Create new secret key"
  5. Copy the key and add it to your .env file

FRED API Key

  1. Go to FRED API
  2. Create a free account
  3. Request an API key
  4. Copy the key and add it to your .env file

πŸ“ Project Structure

macropulse_copilot/
β”œβ”€β”€ app.py                  # Main Flask application
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ .env.example           # Example environment variables
β”œβ”€β”€ README.md              # This file
β”‚
β”œβ”€β”€ static/                # Static assets
β”‚   β”œβ”€β”€ css/
β”‚   β”‚   └── style.css     # Custom styling
β”‚   └── js/
β”‚       └── dashboard.js  # Dashboard functionality
β”‚
└── templates/             # HTML templates
    β”œβ”€β”€ index.html        # Main dashboard
    β”œβ”€β”€ 404.html          # Not found page
    └── 500.html          # Server error page

πŸ”§ Configuration

Environment Variables

Variable Description Required Default
OPENAI_API_KEY OpenAI API key for AI analysis Yes -
FRED_API_KEY FRED API key for economic data Yes -
SECRET_KEY Flask secret key No dev-secret-key
DEBUG Debug mode No False
PORT Application port No 5000

Caching

The application uses Flask-Caching with the following timeouts:

  • FRED data: 1 hour
  • Forex rates: 30 minutes
  • Commodity prices: 30 minutes
  • News: 2 hours

πŸ“Š Data Sources

  1. Foreign Exchange: Exchange Rate API
  2. Economic Data: FRED (Federal Reserve Economic Data)
  3. AI Analysis: OpenAI GPT-4
  4. Charts: Chart.js

πŸ› οΈ Technology Stack

Backend

  • Flask 3.0: Python web framework
  • Flask-Caching: Response caching
  • OpenAI API: AI-powered analysis
  • Requests: HTTP client

Frontend

  • Bootstrap 5: UI framework
  • Chart.js: Data visualization
  • Font Awesome: Icons
  • Inter Font: Typography

πŸ“± Features in Detail

Dashboard Components

  1. Market Overview

    • Real-time forex rates (USD, EUR, GBP, CNY vs INR)
    • Visual indicators for currency strength
  2. Commodity Prices

    • Gold, Crude Oil, Silver, Natural Gas
    • Price changes with percentage indicators
    • INR-denominated pricing
  3. AI Market Analysis

    • Context-aware insights
    • Plain-English explanations
    • India-specific impact assessment
  4. Treasury Yields Chart

    • 60-day historical data
    • 10-year and 2-year comparison
    • Impact on Indian bond markets
  5. Market News

    • Curated news feeds
    • Time-stamped updates
    • Relevant Indian market news

πŸ”’ Production Deployment

Using Gunicorn

gunicorn -w 4 -b 0.0.0.0:5000 app:app

Environment Variables for Production

export FLASK_ENV=production
export DEBUG=False
export SECRET_KEY="your-strong-secret-key"
export OPENAI_API_KEY="your-openai-key"
export FRED_API_KEY="your-fred-key"

Recommended Setup

  1. Reverse Proxy: Use Nginx or Apache
  2. HTTPS: Configure SSL certificates
  3. Process Manager: Use systemd or supervisor
  4. Monitoring: Implement logging and error tracking

πŸ› Troubleshooting

Common Issues

Problem: "API key not configured" warning

  • Solution: Ensure your .env file has the correct API keys set

Problem: Charts not displaying

  • Solution: Check browser console for errors, ensure Chart.js is loaded

Problem: No data showing

  • Solution: Verify API keys are valid and have sufficient quota

Problem: Slow loading times

  • Solution: Adjust cache timeouts in app.py

🀝 Contributing

This is a production-ready application. To customize:

  1. Modify app.py to add new data sources
  2. Update templates/index.html for UI changes
  3. Enhance static/js/dashboard.js for new features
  4. Adjust styling in static/css/style.css

πŸ“„ License

This project is provided as-is for educational and commercial use.

πŸ™ Acknowledgments

πŸ“§ Support

For issues and questions:

  1. Check the troubleshooting section
  2. Review API documentation
  3. Verify environment variables
  4. Check server logs

Built with ❀️ for students and economists

MacroPulse Copilot - Making macro economics accessible and understandable

Releases

Packages

Contributors

Languages