Downloads ยท 30 days
6
16% of all-time downloads
Benedwe/TradeNest-AI
TradeNest-AI is a machine learning model from Benedwe. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Production-Ready AI Trade Intelligence Platform
Downloads ยท 30 days
6
16% of all-time downloads
All-time downloads
38
Public
Repo size
252 MB
Likes
0
Public
Click a slice to open those files.
.so122 MB ยท 29%
From the Hugging Face model README
Production-Ready AI Trade Intelligence Platform
TradeNest AI is a standalone AI trade intelligence platform that provides predictive analytics, clear business explanations, and visual insights (charts and graphs) for every analysis.
Every analytical response MUST return:
No prediction is valid without visual support.
TradeNest AI
โ
โโโ api/
โ โโโ routes.py # API endpoints
โโโ core/
โโโ models/
โโโ preprocessing/
โโโ schemas/
โ โโโ request_schemas.py # Request validation
โ โโโ response_schemas.py # Response models
โโโ services/
โ โโโ prediction_service.py # ML predictions
โ โโโ explanation_service.py # Business explanations
โ โโโ visualization_service.py # Chart orchestration
โ โโโ web_data_service.py # Optional web/data enrichment
โโโ visualizations/
โ โโโ line_charts.py # Line chart generation
โ โโโ bar_charts.py # Bar chart generation
โ โโโ pie_charts.py # Pie chart generation
โโโ storage/
โโโ utils/
โโโ main.py # FastAPI application
Agg backend for server environments# Install dependencies
pip install -r requirements.txt
# Start the server
python main.py
# Or using uvicorn directly
uvicorn main:app --host 0.0.0.0 --port 8000
# Run both backend and beautiful frontend
python run_platform.py
The applications will be available at:
http://localhost:8000http://localhost:7860http://localhost:8000/docsInteractive API documentation:
http://localhost:8000/docshttp://localhost:8000/redocTradeNest AI features a stunning, user-friendly web interface built with Gradio:
Business Forecasting Tab
Country Intelligence Tab
Trade Analytics Tab
Economic Indicators Tab
/api/predict/demandForecast demand with visualizations.
Request:
{
"historical_values": [100, 120, 110, 130, 125],
"historical_dates": ["2024-01", "2024-02", "2024-03", "2024-04", "2024-05"],
"periods_ahead": 4,
"method": "moving_average"
}
Response:
{
"insight_summary": "Strong growth expected: 15.2% increase in average demand",
"explanation": "The line chart shows...",
"predictions": {
"values": [135.5, 138.2, 140.9, 143.6],
"range": "135.50 - 143.60"
},
"confidence_level": "High",
"visuals": {
"line_chart": "base64_encoded_image...",
"pie_chart": "base64_encoded_image..."
}
}
/api/predict/priceOptimize price with visualizations.
Request:
{
"prices": [10.0, 12.0, 11.0, 13.0, 12.5],
"volumes": [1000, 800, 900, 700, 850],
"target": "revenue"
}
Response:
{
"insight_summary": "Optimal price identified: $12.00 for maximum revenue",
"explanation": "The line chart displays the relationship...",
"predictions": {
"optimal_price": 12.0,
"expected_volume": 800,
"expected_revenue": 9600.0,
"price_elasticity": 0.75,
"recommendation": "Set price at $12.00 for maximum revenue"
},
"confidence_level": "Medium",
"visuals": {
"line_chart": "base64_encoded_image...",
"pie_chart": "base64_encoded_image..."
}
}
/api/analyze/trendAnalyze sales trend with visualizations.
Request:
{
"values": [5000, 5500, 5200, 6000, 5800, 6200],
"periods": ["Q1", "Q2", "Q3", "Q4", "Q5", "Q6"]
}
Response:
{
"insight_summary": "Strong upward trend: 12.5% growth detected in sales performance",
"explanation": "The trend chart provides a clear visual representation...",
"predictions": {
"trend_direction": "increasing",
"growth_rate": 24.0,
"trend_percentage": 12.5,
"average": 5616.67,
"volatility": 0.08,
"range": "5000.00 - 6200.00"
},
"confidence_level": "High",
"visuals": {
"line_chart": "base64_encoded_image...",
"pie_chart": "base64_encoded_image..."
}
}
/api/country/infoGet detailed country information from Country API.
Request:
{
"country_code": "TZ"
}
/api/country/searchSearch for countries by name.
Request:
{
"name": "Tanzania"
}
/api/trade/dataGet trade data between two countries.
Request:
{
"reporter_code": "842",
"partner_code": "156",
"year": "2023",
"commodity_code": "TOTAL",
"trade_flow": "export"
}
/api/imf/indicatorGet IMF economic indicator data.
Request:
{
"country_code": "US",
"indicator": "NGDP_RPCH",
"dataset": "IFS",
"start_year": "2020",
"end_year": "2024"
}
/api/forecast/businessComprehensive business performance forecasting.
Request:
{
"business_type": "retail",
"country_code": "US",
"historical_revenue": [100000, 120000, 115000, 130000, 140000, 135000],
"forecast_horizon_months": 12,
"include_external_factors": true
}
Response:
{
"business_type": "retail",
"country_code": "US",
"country_name": "United States",
"forecast_horizon_months": 12,
"forecast": {
"values": [145000, 150000, 155000, ...],
"growth_rates": [5.2, 3.4, 3.3, ...],
"cumulative_growth": 25.8
},
"insights": [
"๐ Strong growth expected: Average monthly growth of 4.2%",
"๐ Favorable macroeconomic environment: Country GDP growing at 2.1%"
],
"risk_assessment": [
"Moderate inflation creating cost pressures"
],
"opportunities": [
"E-commerce adoption still growing in emerging markets"
]
}
Every endpoint returns JSON with this structure:
{
"insight_summary": "Short business conclusion",
"explanation": "Clear explanation referencing visible charts",
"predictions": {
"values": [...],
"range": "numeric range"
},
"confidence_level": "High | Medium | Low",
"visuals": {
"line_chart": "base64_encoded_image",
"pie_chart": "base64_encoded_image"
}
}
No visuals โ response is invalid.
Explanations must:
Example:
"The line chart shows consistent week-over-week growth, while the pie chart confirms that 60% of sales come from peak weeks."
line_charts.py, bar_charts.py, or pie_charts.py)VisualizationServiceimport requests
import json
import base64
from PIL import Image
from io import BytesIO
# Make request
response = requests.post(
"http://localhost:8000/api/predict/demand",
json={
"historical_values": [100, 120, 110, 130, 125],
"periods_ahead": 4
}
)
data = response.json()
# Decode and save charts
line_chart = base64.b64decode(data['visuals']['line_chart'])
pie_chart = base64.b64decode(data['visuals']['pie_chart'])
# Save images
with open('line_chart.png', 'wb') as f:
f.write(line_chart)
with open('pie_chart.png', 'wb') as f:
f.write(pie_chart)
print(data['insight_summary'])
print(data['explanation'])
curl -X POST "http://localhost:8000/api/predict/demand" \
-H "Content-Type: application/json" \
-d '{
"historical_values": [100, 120, 110, 130, 125],
"periods_ahead": 4
}'
Input Data
โ
Validation (Pydantic)
โ
Prediction Service
โ
Visualization Service
โ
Chart Generation (Matplotlib)
โ
Base64 Encoding
โ
Explanation Service
โ
JSON Response (with visuals)
fastapi: Web frameworkuvicorn: ASGI serverpydantic: Data validationmatplotlib: Visualizationnumpy: Numerical operationsgradio: Beautiful web interfacerequests: API clientpandas: Data manipulationโ All core features implemented โ Visualization pipeline complete โ API endpoints functional โ Beautiful Gradio interface ready โ Country API integration โ Trade API integration โ IMF API integration โ Business forecasting engine โ Documentation ready
MIT License
TradeNest AI shows its intelligence, not just says it.