Update Docker Compose ports to 8081 and add new apps and URL routes for crop zoning, plant simulator, pest detection, irrigation recommendation, fertilization recommendation, and farm AI assistant.

This commit is contained in:
2026-02-25 12:21:53 +03:30
parent 608252714b
commit 2a77f90ccd
46 changed files with 4142 additions and 2 deletions
View File
+7
View File
@@ -0,0 +1,7 @@
from django.apps import AppConfig
class PestDetectionConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "pest_detection"
verbose_name = "Pest Detection"
+11
View File
@@ -0,0 +1,11 @@
"""
Static mock data for Pest Detection API.
No database, no dynamic values. Used for analyze endpoint response.
"""
ANALYZE_RESPONSE_DATA = {
"pest": "شپشک",
"confidence": 92,
"description": "حشرات کوچک مکنده شیره که باعث پیچ خوردگی برگ می‌شوند.",
"treatment": "یک بار در هفته از اسپری روغن نیم استفاده کنید.",
}
@@ -0,0 +1 @@
{"info":{"name":"Pest Detection","schema":"https://schema.getpostman.com/json/collection/v2.1.0/collection.json","description":"Pest Detection API. POST analyze (optional body). Returns static pest result. No database."},"item":[{"name":"Analyze image (POST)","request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{}"},"url":"{{baseUrl}}/api/pest-detection/analyze/","description":"POST with optional body (e.g. image reference). Returns static pest, confidence, description, treatment. Input not processed."},"response":[{"name":"Success","status":"OK","code":200,"body":"{\n \"status\": \"success\",\n \"data\": {\n \"pest\": \"شپشک\",\n \"confidence\": 92,\n \"description\": \"حشرات کوچک مکنده شیره که باعث پیچ خوردگی برگ می‌شوند.\",\n \"treatment\": \"یک بار در هفته از اسپری روغن نیم استفاده کنید.\"\n }\n}"}]}],"variable":[{"key":"baseUrl","value":"http://localhost:8000"}]}
+7
View File
@@ -0,0 +1,7 @@
from django.urls import path
from .views import AnalyzeView
urlpatterns = [
path("analyze/", AnalyzeView.as_view(), name="pest-detection-analyze"),
]
+43
View File
@@ -0,0 +1,43 @@
"""
Pest Detection API views.
Plain Django only; no DRF. No database. All responses are static mock data.
Response format: {"status": "success", "data": <payload>}. HTTP 200 only.
No processing, validation, or use of input parameters in responses.
CSRF exempt so frontend can call POST without token.
"""
from django.http import JsonResponse
from django.utils.decorators import method_decorator
from django.views import View
from django.views.decorators.csrf import csrf_exempt
from .mock_data import ANALYZE_RESPONSE_DATA
@method_decorator(csrf_exempt, name="dispatch")
class AnalyzeView(View):
"""
POST endpoint for pest detection analysis.
Purpose:
Returns a static pest detection result (pest name, confidence,
description, treatment). Used when the user uploads a plant image
and requests analysis. No processing is performed on the request.
Input parameters:
- body (optional): JSON or form-data; may contain image or file.
Data type: object. Location: body. Not read or validated; not used in response.
Response structure:
- status: string, always "success".
- data: object with keys pest (string), confidence (number),
description (string), treatment (string).
No processing or validation is performed on inputs.
"""
def post(self, request):
return JsonResponse(
{"status": "success", "data": ANALYZE_RESPONSE_DATA},
status=200,
)