The PoE Economy Analysis Tool is built with a modular architecture consisting of the following components:
- Data Collection Module (
data_collector.py): Responsible for fetching real-time data from poe.ninja API - Data Integration Module (
data_integration.py): Integrates data from different leagues and sources - Analysis Engine (
analysis_engine.py): Analyzes market data to identify profitable opportunities - Web Interface (
app.py, templates, static files): Presents data and opportunities to users - Configuration (
config.py): Manages settings and platform compatibility
The DataCollector class handles fetching data from poe.ninja for various item types:
- Currencies (Divine Orb, Exalted Orb, etc.)
- Fragments (Scarabs, Splinters, etc.)
- Oils (Golden Oil, Silver Oil, etc.)
- Scarabs (All types and tiers)
- Incubators
- Artifacts
- Divination Cards
Key methods:
collect_all_data(league): Collects all data types for a specific leaguecollect_currency_data(league): Collects currency datacollect_item_data(league, item_type): Collects data for specific item types
The DataIntegration class combines data from different leagues and adds additional analysis:
- Integrates primary league (Phrecia) with historical league (Settlers)
- Calculates price trends and volatility
- Adds reference data for farming locations and strategies
Key methods:
integrate_data(market_data): Main integration methodintegrate_currencies(primary_currencies, historical_currencies): Integrates currency dataintegrate_items(primary_items, historical_items): Integrates item data
The AnalysisEngine class identifies profitable opportunities in four categories:
- Flipping: Currency trading opportunities
- Farming: Profitable items to target farm
- Crafting: Profitable crafting strategies
- Investment: Long-term investment opportunities
Key methods:
analyze_all_opportunities(integrated_data): Main analysis methodanalyze_flipping_opportunities(integrated_data): Analyzes flipping opportunitiesanalyze_farming_opportunities(integrated_data): Analyzes farming opportunitiesanalyze_crafting_opportunities(integrated_data): Analyzes crafting opportunitiesanalyze_investment_opportunities(integrated_data): Analyzes investment opportunities
The web interface is built with Flask and includes:
- Main dashboard (
index.html) - JavaScript for interactive charts and tables (
main.js) - CSS for styling (
style.css)
Key endpoints:
/: Main dashboard/api/opportunities: Get current profit opportunities/api/update: Trigger manual data update/api/leagues: Get available leagues/api/status: Get current status/api/currency_data: Get currency data for charts
To add a new item type to track:
- Add the new item type to
ITEM_TYPESinconfig.py:
ITEM_TYPES = {
# Existing types...
'NewItemType': f'{POE_NINJA_ITEM_URL}?league={{league}}&type=NewItemType',
}- Update the
collect_all_datamethod indata_collector.pyto include the new item type - Update the
integrate_datamethod indata_integration.pyto process the new item type - Add analysis for the new item type in
analysis_engine.py
To add a new analysis method:
- Create a new method in
analysis_engine.py:
def analyze_new_opportunities(self, integrated_data):
# Analysis logic here
return opportunities- Update the
analyze_all_opportunitiesmethod to include your new analysis - Update the web interface to display the new opportunities
To customize the web interface:
- Modify
templates/index.htmlto add new UI elements - Update
static/js/main.jsto handle new data and interactions - Customize
static/css/style.cssto change the appearance
The tool is designed to work on both Windows and Unix/Linux systems:
- Path handling is managed through the
get_platform_pathfunction inconfig.py - Directory creation is handled by
ensure_dir_existsfunction - All file operations use platform-agnostic path joining
When adding new file operations, always use:
from config import get_platform_path
file_path = get_platform_path('/path/to/file')- The tool updates data every 15 minutes by default (configurable in
config.py) - Data is cached to minimize API requests
- Background updates run in a separate thread to avoid blocking the UI
- Consider implementing pagination for large datasets
To test the tool:
- Run unit tests for individual components:
python -m unittest tests/test_data_collector.py
python -m unittest tests/test_analysis_engine.py
- Test the full application:
python app.py
- Verify data accuracy by comparing with poe.ninja website
For production deployment:
- Consider using a production WSGI server like Gunicorn:
pip install gunicorn
gunicorn -w 4 app:app
- Set up a reverse proxy with Nginx or Apache
- Configure proper logging and monitoring
- Consider containerization with Docker for easier deployment
Common issues and solutions:
- API rate limiting: Implement exponential backoff for API requests
- Memory usage: Optimize data structures and implement pagination
- Slow analysis: Profile and optimize analysis algorithms
- Path issues: Ensure all file operations use
get_platform_path