AgriSense Deployer commited on
Commit
a1d0389
Β·
1 Parent(s): 84d705a

Fix HF Space configuration - add proper YAML metadata

Browse files
Files changed (1) hide show
  1. README.md +126 -271
README.md CHANGED
@@ -1,289 +1,144 @@
1
- # 🌾 AgriSense - AI-Powered Agricultural Platform
2
-
3
- **Full-stack AI/ML application for smart farming with real-time monitoring, crop disease detection, and intelligent recommendations.**
4
-
5
- [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
6
- [![Python](https://img.shields.io/badge/Python-3.12-blue.svg)](https://www.python.org/downloads/)
7
- [![FastAPI](https://img.shields.io/badge/FastAPI-0.115+-green.svg)](https://fastapi.tiangolo.com/)
8
- [![React](https://img.shields.io/badge/React-18.3-blue.svg)](https://reactjs.org/)
9
-
10
- ---
11
-
12
- ## πŸš€ Features
13
-
14
- ### πŸ”¬ AI/ML Capabilities
15
- - **Crop Disease Detection** - Computer vision with TensorFlow & PyTorch
16
- - **Intelligent Recommendations** - ML-powered crop advisory
17
- - **Chatbot Assistant** - NLP-based farming guidance
18
- - **Predictive Analytics** - Time-series forecasting for yields
19
-
20
- ### πŸ“Š Real-Time Monitoring
21
- - **IoT Sensor Integration** - ESP32/Arduino compatibility
22
- - **Live Dashboard** - React-based monitoring interface
23
- - **Automated Alerts** - SMS/Email notifications
24
- - **Historical Analytics** - Trend analysis and insights
25
-
26
- ### πŸ—οΈ Architecture
27
- - **Backend:** FastAPI (Python 3.12) with async/await
28
- - **Frontend:** React 18 with TypeScript + Vite
29
- - **ML Stack:** TensorFlow 2.18, PyTorch 2.5, Transformers
30
- - **Background Tasks:** Celery with Redis broker
31
- - **Database:** MongoDB (production) / SQLite (development)
32
-
33
- ---
34
-
35
- ## 🌐 Live Demo
36
-
37
- **Access the application:**
38
- ```
39
- https://huggingface.co/spaces/<your-username>/agrisense-app
40
- ```
41
-
42
- **API Documentation (Swagger):**
43
- ```
44
- https://huggingface.co/spaces/<your-username>/agrisense-app/docs
45
- ```
46
-
47
- ---
48
-
49
- ## πŸ“– Quick Start
50
-
51
- ### Prerequisites
52
- - Python 3.12+
53
- - Node.js 18+
54
- - MongoDB (Atlas M0 free tier)
55
- - Redis (Upstash free tier)
56
-
57
- ### Local Development
58
-
59
- ```bash
60
- # Clone repository
61
- git clone https://github.com/ELANGKATHIR11/AGRISENSEFULL-STACK.git
62
- cd AGRISENSEFULL-STACK
63
-
64
- # Backend setup
65
- cd agrisense_app/backend
66
- python -m venv venv
67
- source venv/bin/activate # Windows: venv\Scripts\activate
68
- pip install -r requirements.txt
69
-
70
- # Frontend setup
71
- cd ../frontend/farm-fortune-frontend-main
72
- npm install
73
- npm run build
74
-
75
- # Start services
76
- # Terminal 1: Backend
77
- cd agrisense_app/backend
78
- uvicorn main:app --reload --port 8004
79
-
80
- # Terminal 2: Celery
81
- celery -A celery_config worker --loglevel=info
82
-
83
- # Terminal 3: Frontend (dev mode)
84
- cd agrisense_app/frontend/farm-fortune-frontend-main
85
- npm run dev
86
- ```
87
-
88
- ---
89
-
90
- ## 🐳 Docker Deployment
91
-
92
- ### Build & Run Locally
93
-
94
- ```bash
95
- # Build Docker image
96
- docker build -f Dockerfile.huggingface -t agrisense .
97
-
98
- # Run container
99
- docker run -p 7860:7860 \
100
- -e MONGO_URI="mongodb+srv://user:pass@cluster.mongodb.net/agrisense" \
101
- -e REDIS_URL="redis://default:pass@host:6379" \
102
- -e AGRISENSE_ADMIN_TOKEN="your-secret-token" \
103
- agrisense
104
- ```
105
-
106
- ### Deploy to Hugging Face Spaces
107
-
108
- See complete guide: [HF_DEPLOYMENT_GUIDE.md](HF_DEPLOYMENT_GUIDE.md)
109
-
110
- **Quick Steps:**
111
- 1. Create Space with Docker SDK
112
- 2. Add secrets (`MONGO_URI`, `REDIS_URL`, `AGRISENSE_ADMIN_TOKEN`)
113
- 3. Push code to Space repository
114
- 4. Wait for build (~10-15 minutes)
115
-
116
- ---
117
-
118
- ## πŸ” Environment Variables
119
-
120
- ### Required
121
- | Variable | Description | Example |
122
- |----------|-------------|---------|
123
- | `MONGO_URI` | MongoDB connection string | `mongodb+srv://user:pass@cluster.mongodb.net/agrisense` |
124
- | `REDIS_URL` | Redis connection URL | `redis://default:pass@host:6379` |
125
- | `AGRISENSE_ADMIN_TOKEN` | Admin API token | `sk-agrisense-xyz123` |
126
-
127
- ### Optional
128
- | Variable | Default | Description |
129
- |----------|---------|-------------|
130
- | `AGRISENSE_DISABLE_ML` | `0` | Set to `1` to disable ML models |
131
- | `WORKERS` | `2` | Number of Uvicorn workers |
132
- | `CELERY_WORKERS` | `2` | Number of Celery workers |
133
- | `LOG_LEVEL` | `info` | Logging level |
134
-
135
- ---
136
-
137
- ## πŸ“Š API Endpoints
138
-
139
- ### Health & Status
140
- - `GET /health` - Health check
141
- - `GET /docs` - API documentation
142
-
143
- ### Sensors
144
- - `POST /api/sensors/readings` - Submit sensor data
145
- - `GET /api/sensors/readings` - Fetch sensor history
146
-
147
- ### AI/ML
148
- - `POST /api/predict/disease` - Crop disease detection
149
- - `POST /api/recommendations` - Get farming recommendations
150
- - `POST /api/chat` - Chatbot interaction
151
-
152
- ### User Management
153
- - `POST /api/auth/register` - User registration
154
- - `POST /api/auth/login` - User login
155
-
156
  ---
157
-
158
- ## πŸ§ͺ Testing
159
-
160
- ```bash
161
- # Backend tests
162
- cd agrisense_app/backend
163
- pytest tests/ -v --cov
164
-
165
- # Frontend tests
166
- cd agrisense_app/frontend/farm-fortune-frontend-main
167
- npm run test
168
-
169
- # E2E tests
170
- npm run test:e2e
171
- ```
172
-
173
- ---
174
-
175
- ## πŸ“ˆ Performance
176
-
177
- ### Resource Usage (16GB RAM Container)
178
- - **Idle:** ~2GB RAM
179
- - **With ML Models Loaded:** ~6-8GB RAM
180
- - **Under Load:** ~10-12GB RAM
181
- - **CPU:** 2-4 cores typical usage
182
-
183
- ### Optimization Tips
184
- 1. Enable model lazy loading
185
- 2. Use TensorFlow Lite for inference
186
- 3. Implement Redis caching
187
- 4. Optimize database queries
188
-
189
  ---
190
 
191
- ## πŸ› οΈ Tech Stack
192
-
193
- ### Backend
194
- - **Framework:** FastAPI 0.115+
195
- - **Language:** Python 3.12.10
196
- - **ML/AI:** TensorFlow 2.18, PyTorch 2.5, Transformers 4.47
197
- - **Task Queue:** Celery 5.4 with Redis
198
- - **Database:** MongoDB (Motor), SQLite (SQLAlchemy)
199
- - **Authentication:** JWT with FastAPI-Users
200
-
201
- ### Frontend
202
- - **Framework:** React 18.3
203
- - **Language:** TypeScript 5.3
204
- - **Build Tool:** Vite 5.0
205
- - **UI Components:** Radix UI, Tailwind CSS
206
- - **State Management:** TanStack Query
207
- - **Testing:** Vitest, Playwright
208
-
209
- ### Infrastructure
210
- - **Compute:** Hugging Face Spaces (Docker SDK)
211
- - **Database:** MongoDB Atlas M0 (free tier)
212
- - **Cache/Broker:** Upstash Redis (free tier)
213
- - **Monitoring:** Prometheus, Sentry (optional)
214
 
215
- ---
216
 
217
- ## πŸ“ Project Structure
218
-
219
- ```
220
- AGRISENSEFULL-STACK/
221
- β”œβ”€β”€ agrisense_app/
222
- β”‚ β”œβ”€β”€ backend/
223
- β”‚ β”‚ β”œβ”€β”€ main.py # FastAPI application
224
- β”‚ β”‚ β”œβ”€β”€ celery_config.py # Celery configuration
225
- β”‚ β”‚ β”œβ”€β”€ requirements.txt # Python dependencies
226
- β”‚ β”‚ β”œβ”€β”€ api/ # API routes
227
- β”‚ β”‚ β”œβ”€β”€ core/ # Business logic
228
- β”‚ β”‚ β”œβ”€β”€ ml/ # ML model loaders
229
- β”‚ β”‚ └── tasks/ # Celery tasks
230
- β”‚ └── frontend/
231
- β”‚ └── farm-fortune-frontend-main/
232
- β”‚ β”œβ”€β”€ src/ # React source code
233
- β”‚ β”œβ”€β”€ package.json # Node dependencies
234
- β”‚ └── vite.config.ts # Vite configuration
235
- β”œβ”€β”€ ml_models/ # Trained ML models
236
- β”œβ”€β”€ Dockerfile.huggingface # Multi-stage Dockerfile
237
- β”œβ”€β”€ start.sh # Container startup script
238
- └── HF_DEPLOYMENT_GUIDE.md # Deployment guide
239
- ```
240
 
241
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
 
243
  ## 🀝 Contributing
244
 
245
- Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) first.
246
-
247
- 1. Fork the repository
248
- 2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
249
- 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
250
- 4. Push to the branch (`git push origin feature/AmazingFeature`)
251
- 5. Open a Pull Request
252
-
253
- ---
254
 
255
  ## πŸ“ License
256
 
257
- This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
258
-
259
- ---
260
 
261
- ## πŸ™ Acknowledgments
262
 
263
- - **Hugging Face** - Free 16GB RAM hosting
264
- - **MongoDB Atlas** - Free M0 tier database
265
- - **Upstash** - Free Redis hosting
266
- - **FastAPI** - Modern Python web framework
267
- - **React** - Frontend library
268
 
269
  ---
270
 
271
- ## πŸ“§ Contact
272
-
273
- **Project Maintainer:** ELANGKATHIR11
274
-
275
- - GitHub: [@ELANGKATHIR11](https://github.com/ELANGKATHIR11)
276
- - Repository: [AGRISENSEFULL-STACK](https://github.com/ELANGKATHIR11/AGRISENSEFULL-STACK)
277
-
278
- ---
279
-
280
- ## πŸ”— Links
281
-
282
- - **Documentation:** [Full Documentation](HF_DEPLOYMENT_GUIDE.md)
283
- - **API Docs:** [Swagger UI](https://your-space.hf.space/docs)
284
- - **GitHub:** [Source Code](https://github.com/ELANGKATHIR11/AGRISENSEFULL-STACK)
285
- - **Hugging Face:** [Live Demo](https://huggingface.co/spaces/<username>/agrisense-app)
286
-
287
- ---
288
 
289
- **Built with ❀️ for sustainable agriculture**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: AgriSense
3
+ emoji: 🌾
4
+ colorFrom: green
5
+ colorTo: green
6
+ sdk: docker
7
+ pinned: true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  ---
9
 
10
+ # 🌾 AgriSense - AI-Powered Smart Farming Platform
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
+ **AgriSense** is a comprehensive full-stack agricultural IoT platform combining real-time sensor monitoring, AI-powered crop disease detection, weed management, and intelligent farming recommendations.
13
 
14
+ ## ✨ Features
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ ### πŸ“Š Real-Time Monitoring
17
+ - **IoT Sensor Integration**: ESP32 & Arduino-based environmental sensors
18
+ - **Live Dashboard**: Real-time temperature, humidity, soil moisture, pH tracking
19
+ - **Data Visualization**: Interactive charts and field maps
20
+ - **Weather Integration**: Current weather and crop-specific recommendations
21
+
22
+ ### πŸ€– AI/ML Capabilities
23
+ - **Disease Detection**: CNN-powered plant disease identification
24
+ - **Weed Management**: Computer vision for weed identification and control
25
+ - **Yield Prediction**: ML models for crop yield forecasting
26
+ - **Smart Farming**: Crop-specific optimization recommendations
27
+ - **Conversational AI**: AgriBot chatbot for farming advice
28
+
29
+ ### πŸ’Ύ Data Management
30
+ - **MongoDB Atlas** backend for scalable data storage
31
+ - **Redis caching** for high-performance queries
32
+ - **Celery workers** for asynchronous background tasks
33
+ - **RESTful API** with FastAPI
34
+
35
+ ### 🎨 Modern Frontend
36
+ - **React 18** with TypeScript
37
+ - **Real-time updates** via WebSocket
38
+ - **Responsive Design** for desktop and mobile
39
+ - **Multi-language support** (English, Hindi, Tamil, Telugu, Kannada)
40
+ - **Progressive Web App** capabilities
41
+
42
+ ## πŸš€ Technology Stack
43
+
44
+ | Component | Technology |
45
+ |-----------|-----------|
46
+ | **Backend** | FastAPI 0.115+ (Python 3.12.10) |
47
+ | **Frontend** | React 18.3 + Vite 5.0 + TypeScript |
48
+ | **Database** | MongoDB Atlas M0 (FREE) |
49
+ | **Cache** | Upstash Redis (FREE) |
50
+ | **Job Queue** | Celery 5.4 |
51
+ | **ML/AI** | TensorFlow 2.18, PyTorch 2.5, Transformers 4.47 |
52
+ | **Compute** | Hugging Face Spaces Docker (16GB RAM) |
53
+
54
+ ## πŸ“± Live API Documentation
55
+
56
+ Once deployed:
57
+ - **API Docs**: `/docs` (Swagger UI)
58
+ - **Alternative Docs**: `/redoc` (ReDoc)
59
+ - **Health Check**: `/health`
60
+
61
+ ## πŸ”Œ API Endpoints
62
+
63
+ ### Sensor Data
64
+ - `POST /api/v1/sensors/readings` - Submit sensor readings
65
+ - `GET /api/v1/sensors/{device_id}/latest` - Get latest readings
66
+ - `GET /api/v1/sensors/{device_id}/history` - Historical data
67
+
68
+ ### AI/ML Models
69
+ - `POST /api/v1/ai/disease-detection` - Detect plant diseases
70
+ - `POST /api/v1/ai/weed-detection` - Identify weeds
71
+ - `POST /api/v1/ai/recommendations` - Get farming recommendations
72
+ - `POST /api/v1/ai/chat` - Talk to AgriBot chatbot
73
+
74
+ ### Analytics
75
+ - `GET /api/v1/analytics/yield-prediction` - Predict yield
76
+ - `GET /api/v1/analytics/crop-health` - Health metrics
77
+ - `GET /api/v1/analytics/field-summary` - Field statistics
78
+
79
+ ## πŸ› οΈ Deployment Configuration
80
+
81
+ This Space uses:
82
+ - **Docker SDK**: Full Python + Node.js environment
83
+ - **Environment Variables**: MongoDB, Redis URLs (set in Secrets)
84
+ - **Multi-process**: FastAPI + Celery workers + Nginx
85
+
86
+ ## πŸ“Š Free Tier Stack
87
+
88
+ | Service | Tier | Cost |
89
+ |---------|------|------|
90
+ | Hugging Face Spaces | CPU Basic (16GB) | FREE |
91
+ | MongoDB Atlas | M0 Sandbox (512MB) | FREE |
92
+ | Upstash Redis | Free tier | FREE |
93
+ | **TOTAL MONTHLY COST** | | **$0** βœ… |
94
+
95
+ ## 🌐 Access Points
96
+
97
+ - **Frontend UI**: `/ui/` (React app)
98
+ - **API Server**: FastAPI on port 8000
99
+ - **API Docs**: `/docs`
100
+ - **Health**: `/health`
101
+
102
+ ## πŸ“ˆ Monitoring & Logs
103
+
104
+ Monitor the Space build and runtime:
105
+ - Check logs in the Space settings
106
+ - Monitor API health at `/health`
107
+ - View real-time metrics in dashboard
108
+
109
+ ## πŸ”§ Configuration
110
+
111
+ The application uses these environment secrets:
112
+ - `MONGO_URI` - MongoDB Atlas connection string
113
+ - `REDIS_URL` - Upstash Redis URL
114
+ - `AGRISENSE_ADMIN_TOKEN` - Admin authentication token
115
+
116
+ ## πŸ“š Documentation
117
+
118
+ - [API Documentation](./docs/)
119
+ - [Installation Guide](./INSTALLATION.md)
120
+ - [Deployment Guide](./DEPLOYMENT.md)
121
+ - [Architecture Overview](./ARCHITECTURE.md)
122
 
123
  ## 🀝 Contributing
124
 
125
+ Contributions welcome! Please ensure:
126
+ - Code follows PEP 8 (Python) and Prettier (TypeScript)
127
+ - All tests pass before submitting PR
128
+ - Documentation is updated
 
 
 
 
 
129
 
130
  ## πŸ“ License
131
 
132
+ MIT License - See LICENSE file for details
 
 
133
 
134
+ ## πŸ™‹ Support & Contact
135
 
136
+ For issues, feature requests, or questions:
137
+ - Open an issue on GitHub
138
+ - Contact: agrisense@example.com
 
 
139
 
140
  ---
141
 
142
+ **Made with πŸ’š for sustainable agriculture**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
 
144
+ *AgriSense helps farmers make data-driven decisions to increase crop yields, reduce waste, and optimize resource usage.*