File size: 6,176 Bytes
2ec948b
d80bf0f
 
 
2ec948b
 
d80bf0f
2ec948b
 
 
d80bf0f
 
 
 
 
 
 
 
 
2ec948b
 
d80bf0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
---
title: Wildberries Analytics Dashboard
emoji: πŸ›οΈ
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.7.1
app_file: app.py
pinned: false
license: mit
short_description: AI-powered analytics dashboard for Wildberries marketplace
tags:
- analytics
- dashboard
- e-commerce
- wildberries
- inventory
- forecasting
- business-intelligence
---

# πŸ›οΈ Wildberries Analytics Dashboard

An AI-powered analytics dashboard for Wildberries marketplace sellers that provides sales insights and inventory forecasting capabilities.

## ✨ Features

- πŸ“Š **Sales Analytics**: Track revenue, orders, and product performance
- πŸ“¦ **Inventory Forecasting**: Predict stockout dates using multiple algorithms
- ⚠️ **Risk Management**: Automated alerts for low stock situations
- πŸ“ˆ **Interactive Dashboards**: Visual analytics with Plotly charts
- πŸ”„ **Real-time Data**: Integration with Wildberries API
- 🎯 **Demo Mode**: Works without API token for testing

## πŸš€ Quick Start

### Using with Your Wildberries API Token

1. **Get your API token**:
   - Go to your Wildberries seller account
   - Navigate to Settings β†’ Access to API
   - Generate a token with Analytics and Statistics permissions

2. **Configure the Space**:
   - Fork this Space or duplicate it
   - Go to Settings in your Space
   - Add a new secret: `WILDBERRIES_API_TOKEN` with your token value

3. **Start analyzing**:
   - Use the Sales Analytics tab for performance insights
   - Use the Inventory Forecasting tab for stock predictions

### Demo Mode

You can try the dashboard immediately without an API token - it will use sample data to demonstrate all features.

## πŸ“Š Forecasting Methods

The dashboard implements multiple inventory forecasting algorithms:

### 1. Simple Division Method
```
Days Until Stockout = Current Stock Γ· Average Daily Sales
```
- **Best for**: Stable demand patterns
- **Pros**: Easy to understand and implement
- **Cons**: Doesn't account for variability

### 2. Safety Stock Method
```
Safety Stock = (Max Daily Sales Γ— Max Lead Time) - (Avg Daily Sales Γ— Avg Lead Time)
Adjusted Days = (Current Stock - Safety Stock) Γ· Average Daily Sales
```
- **Best for**: Critical inventory items
- **Pros**: Accounts for demand uncertainty
- **Cons**: More conservative estimates

### 3. Weighted Average Method
- Recent weeks: 50% weight
- Previous weeks: 30% weight
- Earlier periods: 20% weight
- **Best for**: Trending products
- **Pros**: Adapts to recent changes
- **Cons**: May overreact to short-term fluctuations

### 4. Seasonal Adjustment Method
```
Adjusted Demand = Base Daily Sales Γ— Seasonal Factor
Days Until Stockout = Current Stock Γ· Adjusted Demand
```
- **Best for**: Seasonal products
- **Pros**: Accounts for seasonal patterns
- **Cons**: Requires historical seasonal data

## πŸ”§ Technical Architecture

### Core Components

- **Frontend**: Gradio web interface with Plotly visualizations
- **Backend**: Python with pandas for data processing
- **API Client**: Custom Wildberries API integration with rate limiting
- **Forecasting Engine**: Multiple statistical algorithms for prediction
- **Data Layer**: In-memory processing with CSV export capabilities

### API Integration

The dashboard respects Wildberries API rate limits:
- Maximum 300 requests per minute
- Uses token bucket algorithm
- Implements exponential backoff for 429 errors
- Automatic retry logic with circuit breaker

### Deployment

Optimized for Hugging Face Spaces:
- Single-file deployment (`app.py`)
- Environment variable configuration
- Gradio's built-in API endpoints
- Automatic scaling and load balancing

## πŸ“ˆ Usage Examples

### Sales Analysis
```python
# Analyze last week's performance
analyze_sales_performance("week")

# Get monthly trends
analyze_sales_performance("month")
```

### Inventory Forecasting
```python
# Conservative approach with safety stock
calculate_stockout_forecast("safety_stock")

# Quick estimation
calculate_stockout_forecast("simple")

# Trend-aware forecasting
calculate_stockout_forecast("weighted")
```

## πŸ”’ Security & Privacy

- **No data storage**: All processing happens in-memory
- **Secure tokens**: API keys stored as Hugging Face Spaces secrets
- **Rate limiting**: Respects API limits to prevent account issues
- **Error handling**: Graceful fallback to demo mode if API unavailable

## πŸ› οΈ Local Development

To run locally:

```bash
# Clone the repository
git clone <your-space-url>
cd <space-name>

# Install dependencies
pip install -r requirements.txt

# Set environment variables
export WILDBERRIES_API_TOKEN="your_token_here"

# Run the application
python app.py
```

## πŸ“‹ API Permissions Required

Your Wildberries API token needs access to:
- βœ… Analytics API
- βœ… Statistics API
- βœ… Marketplace data (for product information)

## 🀝 Contributing

1. Fork this Space
2. Make your changes
3. Test with demo mode
4. Submit a discussion or create your own improved version

## πŸ“š Resources

- [Wildberries API Documentation](https://dev.wildberries.ru/en/openapi/api-information)
- [Hugging Face Spaces Documentation](https://huggingface.co/docs/hub/spaces)
- [Gradio Documentation](https://gradio.app/docs/)

## πŸ“„ License

MIT License - see LICENSE file for details.

## πŸ› Troubleshooting

### Common Issues

**"Demo Mode" showing instead of real data**
- Check if `WILDBERRIES_API_TOKEN` is set in Space settings
- Verify token has correct permissions
- Ensure token hasn't expired (180-day validity)

**API Rate Limit Errors**
- Dashboard automatically handles rate limits
- If persistent, check if other applications are using the same token
- Consider upgrading to higher-tier API access

**Empty charts or data**
- May indicate no sales in selected period
- Try extending the analysis period
- Verify API token has access to your store data

## 🎯 Roadmap

- [ ] Multi-language support (Russian, English)
- [ ] Advanced seasonal analysis
- [ ] Export to Excel/PDF reports
- [ ] Integration with other marketplaces
- [ ] Mobile-responsive design improvements
- [ ] Real-time notifications for critical stock levels

---

**Made with ❀️ for Wildberries sellers**