File size: 1,871 Bytes
847392c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Quick Start Guide

## Local Development

1. **Install dependencies:**
```bash
pip install -r requirements.txt
```

2. **Set environment variable:**
```bash
# Windows PowerShell
$env:MONGODB_URI="mongodb://expenseuser:Kem_6o%3F%[email protected]:27017/expense?authSource=admin"

# Linux/Mac
export MONGODB_URI="mongodb://expenseuser:Kem_6o%3F%[email protected]:27017/expense?authSource=admin"
```

3. **Run the application:**
```bash
uvicorn app.main:app --reload
```

4. **Access the API:**
- API: http://localhost:8000
- Docs: http://localhost:8000/docs
- Health: http://localhost:8000/health

## Test the Smart Budget Recommendation

1. **Create some sample expenses:**
```bash
curl -X POST "http://localhost:8000/expenses" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "user123",
    "amount": 3800,
    "category": "Groceries",
    "description": "Monthly groceries",
    "date": "2024-01-15T00:00:00",
    "type": "expense"
  }'
```

2. **Get recommendations:**
```bash
curl "http://localhost:8000/recommendations/user123?month=2&year=2024"
```

Expected response:
```json
[
  {
    "category": "Groceries",
    "average_expense": 3800.0,
    "recommended_budget": 4000.0,
    "reason": "Your average monthly grocery expense is Rs.3,800. We suggest setting your budget to Rs.4,000 for next month (includes a 5% buffer for variability).",
    "confidence": 0.85
  }
]
```

## Docker Deployment

1. **Build the image:**
```bash
docker build -t smart-budget-recommendation .
```

2. **Run the container:**
```bash
docker run -p 8000:8000 -e MONGODB_URI="your_mongodb_uri" smart-budget-recommendation
```

## Hugging Face Deployment

See `HUGGINGFACE_DEPLOYMENT.md` for detailed instructions.

Quick steps:
1. Create a new Docker Space on Hugging Face
2. Add `MONGODB_URI` as a secret
3. Upload all files
4. Wait for automatic build and deployment