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
+7
View File
@@ -0,0 +1,7 @@
from django.apps import AppConfig
class IrrigationRecommendationConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "irrigation_recommendation"
verbose_name = "Irrigation Recommendation"
+30
View File
@@ -0,0 +1,30 @@
"""
Static mock data for Irrigation Recommendation API.
No database, no dynamic values.
"""
CONFIG_RESPONSE_DATA = {
"farmInfo": {
"soilType": "Loamy",
"waterQuality": "Medium EC",
"climateZone": "Temperate",
},
"cropOptions": [
{"id": "wheat", "labelKey": "wheat", "icon": "tabler-wheat"},
{"id": "corn", "labelKey": "corn", "icon": "tabler-plant-2"},
{"id": "cotton", "labelKey": "cotton", "icon": "tabler-flower"},
{"id": "saffron", "labelKey": "saffron", "icon": "tabler-flower-2"},
{"id": "canola", "labelKey": "canola", "icon": "tabler-leaf"},
{"id": "vegetables", "labelKey": "vegetables", "icon": "tabler-carrot"},
],
}
RECOMMEND_RESPONSE_DATA = {
"plan": {
"frequencyPerWeek": 4,
"durationMinutes": 45,
"bestTimeOfDay": "05:00 - 07:00",
"moistureLevel": 72,
"warning": "Avoid irrigation during midday hours in the coming week due to forecasted high temperatures.",
},
}
@@ -0,0 +1 @@
{"info":{"name":"Irrigation Recommendation","schema":"https://schema.getpostman.com/json/collection/v2.1.0/collection.json","description":"Irrigation Recommendation API. GET config (farm info + crop options). POST recommend (optional body). Returns static plan. No database."},"item":[{"name":"Get config (GET)","request":{"method":"GET","header":[{"key":"Content-Type","value":"application/json"}],"url":"{{baseUrl}}/api/irrigation-recommendation/config/","description":"Returns static farmInfo and cropOptions."},"response":[{"name":"Success","status":"OK","code":200,"body":"{\n \"status\": \"success\",\n \"data\": {\n \"farmInfo\": {\n \"soilType\": \"Loamy\",\n \"waterQuality\": \"Medium EC\",\n \"climateZone\": \"Temperate\"\n },\n \"cropOptions\": [\n {\"id\": \"wheat\", \"labelKey\": \"wheat\", \"icon\": \"tabler-wheat\"},\n {\"id\": \"corn\", \"labelKey\": \"corn\", \"icon\": \"tabler-plant-2\"},\n {\"id\": \"cotton\", \"labelKey\": \"cotton\", \"icon\": \"tabler-flower\"},\n {\"id\": \"saffron\", \"labelKey\": \"saffron\", \"icon\": \"tabler-flower-2\"},\n {\"id\": \"canola\", \"labelKey\": \"canola\", \"icon\": \"tabler-leaf\"},\n {\"id\": \"vegetables\", \"labelKey\": \"vegetables\", \"icon\": \"tabler-carrot\"}\n ]\n }\n}"}]},{"name":"Get recommendation (POST)","request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n \"crop_id\": \"wheat\",\n \"soilType\": \"Loamy\",\n \"waterQuality\": \"Medium EC\",\n \"climateZone\": \"Temperate\"\n}"},"url":"{{baseUrl}}/api/irrigation-recommendation/recommend/","description":"Optional body: crop_id, farm info. Returns static plan. Input not processed."},"response":[{"name":"Success","status":"OK","code":200,"body":"{\n \"status\": \"success\",\n \"data\": {\n \"plan\": {\n \"frequencyPerWeek\": 4,\n \"durationMinutes\": 45,\n \"bestTimeOfDay\": \"05:00 - 07:00\",\n \"moistureLevel\": 72,\n \"warning\": \"Avoid irrigation during midday hours in the coming week due to forecasted high temperatures.\"\n }\n }\n}"}]}],"variable":[{"key":"baseUrl","value":"http://localhost:8000"}]}
+8
View File
@@ -0,0 +1,8 @@
from django.urls import path
from .views import ConfigView, RecommendView
urlpatterns = [
path("config/", ConfigView.as_view(), name="irrigation-recommendation-config"),
path("recommend/", RecommendView.as_view(), name="irrigation-recommendation-recommend"),
]
+71
View File
@@ -0,0 +1,71 @@
"""
Irrigation Recommendation 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 on POST so frontend can call 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 CONFIG_RESPONSE_DATA, RECOMMEND_RESPONSE_DATA
class ConfigView(View):
"""
GET endpoint for irrigation config (farm info and crop options).
Purpose:
Returns static farm info (soilType, waterQuality, climateZone) and
crop options list for the irrigation recommendation form. Used when
loading the irrigation recommendation page.
Input parameters:
None. Query parameters, if sent, are not read or used.
Response structure:
- status: string, always "success".
- data: object with keys farmInfo (object), cropOptions (array of
{ id, labelKey, icon }).
No processing or validation is performed on inputs.
"""
def get(self, request):
return JsonResponse(
{"status": "success", "data": CONFIG_RESPONSE_DATA},
status=200,
)
@method_decorator(csrf_exempt, name="dispatch")
class RecommendView(View):
"""
POST endpoint for irrigation recommendation.
Purpose:
Returns a static irrigation plan (frequencyPerWeek, durationMinutes,
bestTimeOfDay, moistureLevel, warning). Body may contain crop_id
and farm info; not read or used in response.
Input parameters:
- body (optional): JSON. May contain "crop_id", "soilType", "waterQuality",
"climateZone". Data type: object. Location: body. Not read or validated;
not used in response.
Response structure:
- status: string, always "success".
- data: object with key "plan" (object with frequencyPerWeek,
durationMinutes, bestTimeOfDay, moistureLevel, warning).
No processing or validation is performed on inputs.
"""
def post(self, request):
return JsonResponse(
{"status": "success", "data": RECOMMEND_RESPONSE_DATA},
status=200,
)