How 0011ashwin/soil-analyzer works
Project type and purpose
• This is a multi-platform soil analysis application combining:
• A web GUI built with Streamlit (app.py, run.py)
• A native Android app built with Kivy (android_app/)
File structure
• Top-level:
• soil_analyzer/
– app.py, run.py, requirements.txt, soil_report_dataset_500.csv
– android_app/ (Kivy front-end, assets/, main.py, soilanalyzer.kv, report_history.json)
– README.md
• Patterns & roles:
• “app.py” & “run.py” → Streamlit “frontend + backend” in one
• android_app/ → standalone mobile UI + local logic
• Data files: CSV dataset and JSON history
• Build scripts (build.bat, create_icon.py) for Android packaging
• Config & deployment:
• requirements.txt at both levels
• .env for GROQ_API_KEY
• buildozer for Android
README insights
• Technologies: Python 3.8+, Streamlit, Kivy, Groq LLM API (Llama 3 70B)
• Features & flow:
1) UI collects parameters
2) Dataset lookup (nearest neighbors)
3) Groq API call → LLM generates report
4) Visualizations (gauge, radar charts)
5) Persist report history and export as HTML/JSON
Main components
a. Frontend(s):
• Web Client (Browser) → Streamlit Server
• Android Device → Kivy App
b. Backend & Business Logic (common code base):
• Parameter ingestion & validation
• Dataset module (CSV loader + similarity search)
• Groq API integration module
• Report generator & formatter
• History manager (JSON storage)
c. Data Storage:
• Local CSV (soil_report_dataset_500.csv)
• Local JSON (report_history.json in android_app/)
• .env config store for API key
d. External Service:
• Groq LLM API endpoint
e. Visualization & Export:
• Gauge and radar chart components
• HTML/PDF export module
Relationships & interactions
1) User → Frontend (parameter input)
2) Frontend → Dataset module (nearest-neighbor lookup)
3) Backend → Groq API (prompt send/response)
4) Backend → Visualization module → Frontend (render charts)
5) Backend → History manager (persist report)
6) Frontend → Export module (download HTML)
• For the Android path, show offline fallback: if no API key, use pre-generated reports from CSV.
Architectural patterns & principles
• Modular monolith for web: clear separation of UI, business logic, data
• Single-code logic reused across two frontends
• Externalize configuration (API keys in .env)
• Graceful fallback for offline functionality
• MVC-like flow inside Streamlit: UI callbacks → model layer → view rendering
Essential elements
• Arrowheads to indicate request/response flows
• A visible boundary for the “soil_analyzer” codebase
• Notes on fallback logic: “If GROQ_API_KEY missing → use pre-computed CSV report”
• Build process for Android (Buildozer step)