LogicGoInfotechSpaces commited on
Commit
00c5fd3
·
verified ·
1 Parent(s): 60f60c7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -154
README.md CHANGED
@@ -8,157 +8,3 @@ colorTo: yellow
8
  pinned: true
9
  ---
10
  # Smart Budget Recommendation API
11
-
12
- A FastAPI-based service that provides intelligent budget recommendations based on past spending behavior. This service analyzes historical expense data and suggests personalized budgets for each category.
13
-
14
- ## Features
15
-
16
- - **Smart Budget Recommendations**: Analyzes past spending patterns and recommends personalized budgets
17
- - **Category-based Analysis**: Provides recommendations for each expense category
18
- - **Confidence Scoring**: Each recommendation includes a confidence score based on data quality
19
- - **MongoDB Integration**: Stores expenses and budgets in MongoDB
20
- - **RESTful API**: Clean API endpoints for expense tracking and budget management
21
-
22
- ## Example Recommendation
23
-
24
- ```json
25
- {
26
- "category": "Groceries",
27
- "average_expense": 3800.0,
28
- "recommended_budget": 4000.0,
29
- "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).",
30
- "confidence": 0.85
31
- }
32
- ```
33
-
34
- ## API Endpoints
35
-
36
- ### Health Check
37
- - `GET /health` - Check API and database connection status
38
-
39
- ### Expenses
40
- - `POST /expenses` - Create a new expense
41
- - `GET /expenses?user_id={user_id}` - Get expenses for a user
42
-
43
- ### Budgets
44
- - `POST /budgets` - Create a new budget
45
- - `GET /budgets?user_id={user_id}` - Get budgets for a user
46
-
47
- ### Recommendations
48
- - `GET /recommendations/{user_id}?month={month}&year={year}` - Get smart budget recommendations
49
- - `GET /category-expenses/{user_id}?months={months}` - Get average expenses by category
50
-
51
- ## Local Development
52
-
53
- ### Prerequisites
54
- - Python 3.11+
55
- - MongoDB connection string
56
-
57
- ### Setup
58
-
59
- 1. Install dependencies:
60
- ```bash
61
- pip install -r requirements.txt
62
- ```
63
-
64
- 2. Set environment variables:
65
- ```bash
66
- export MONGODB_URI="mongodb://expenseuser:Kem_6o%3F%[email protected]:27017/expense?authSource=admin"
67
- # optional
68
- export OPENAI_API_KEY="your_openai_key"
69
- ```
70
-
71
- 3. Run the application:
72
- ```bash
73
- uvicorn app.main:app --reload
74
- ```
75
-
76
- The API will be available at `http://localhost:8000`
77
-
78
- ## Docker Deployment
79
-
80
- ### Build Docker Image
81
- ```bash
82
- docker build -t smart-budget-recommendation .
83
- ```
84
-
85
- ### Run Docker Container
86
- ```bash
87
- docker run -p 7860:7860 -e MONGODB_URI="your_mongodb_uri" smart-budget-recommendation
88
- ```
89
-
90
- ## Hugging Face Deployment
91
-
92
- ### Prerequisites
93
- 1. Hugging Face account
94
- 2. Docker installed
95
- 3. MongoDB connection string stored as a secret in Hugging Face
96
-
97
- ### Steps
98
-
99
- 1. **Store secrets in Hugging Face**:
100
- - Go to your Hugging Face Space settings
101
- - Navigate to "Variables and secrets"
102
- - Add `MONGODB_URI` with your MongoDB connection string
103
- - *(Optional)* Add `OPENAI_API_KEY` if you want GPT-powered recommendations
104
-
105
- 2. **Create Hugging Face Space**:
106
- - Create a new Space on Hugging Face
107
- - Choose "Docker" as the SDK
108
-
109
- 3. **Upload Files**:
110
- - Upload all files from this repository to your Space
111
- - Ensure `Dockerfile` is in the root directory
112
-
113
- 4. **Configure Space**:
114
- - The Dockerfile will automatically build and run the application
115
- - The app will use the `MONGODB_URI` secret from Hugging Face environment variables
116
-
117
- ### Hugging Face Space Configuration
118
-
119
- The Dockerfile is configured to:
120
- - Use Python 3.11
121
- - Install all dependencies
122
- - Expose port 7860 (Hugging Face default)
123
- - Run the FastAPI application with Uvicorn
124
-
125
- Hugging Face will automatically:
126
- - Build the Docker image
127
- - Set environment variables from secrets
128
- - Deploy the container
129
- - Provide a public URL
130
-
131
- ## API Documentation
132
-
133
- Once deployed, access interactive API documentation at:
134
- - Swagger UI: `http://your-url/docs`
135
- - ReDoc: `http://your-url/redoc`
136
-
137
- ## Algorithm Details
138
-
139
- The Smart Budget Recommendation engine:
140
-
141
- 1. **Data Collection**: Analyzes expenses from the past 6 months
142
- 2. **Category Analysis**: Groups expenses by category and calculates:
143
- - Average monthly spending
144
- - Standard deviation (variability)
145
- - Number of transactions
146
- - Months of data available
147
- 3. **Budget Calculation**:
148
- - Base: Average monthly expense
149
- - Buffer: 5-10% based on spending variability
150
- - Rounding: Rounds to nearest 100 for cleaner numbers
151
- 4. **Confidence Scoring**:
152
- - Based on data quality (months analyzed, transaction count, consistency)
153
- - Returns score from 0-1
154
- 5. **(Optional) GPT Refinement**:
155
- - If `OPENAI_API_KEY` is set, GPT reviews the history and suggests increase/decrease/keep along with a natural-language reason.
156
-
157
- ## Environment Variables
158
-
159
- - `MONGODB_URI`: MongoDB connection string (required)
160
- - `OPENAI_API_KEY`: Optional. If set, GPT-based recommendations augment the rule-based engine.
161
-
162
- ## License
163
-
164
- Copyright © 2025 WalletSync. All Rights Reserved
 
8
  pinned: true
9
  ---
10
  # Smart Budget Recommendation API