How aprizal543/palm-agronomy works
PalmAgronomy is a FastAPI backend for farm/block GIS, production tracking, and agronomy assistance through Telegram and HTTP APIs. The main workflow is a Telegram update entering the webhook, being handled by the agent and its allow-listed tools, then producing a response or confirmed write; HTTP routes also expose farm, block, health, and knowledge operations. PostgreSQL/PostGIS is the system of record, with repositories handling persisted domain data. The README documents broader monitoring, mapping validation, and polling capabilities; links for unsampled internals are omitted where implementation ownership cannot be verified.
Main entry points: tools.py Allow-listed tools · routes API routes · session.py Async DB sessions · telegram_agent.py Telegram agent
Components 23
API and Telegram
- FastAPI application
app/main.py - API routes
app/api/routes - Telegram webhook
app/services/telegram_webhook.py - Telegram adapter
app/integrations/telegram.py
Conversation and tools
- Telegram agent
app/services/telegram_agent.py - Conversation router
app/services/conversation_router.py - Allow-listed tools
app/agent/tools.py - Production insight
app/services/production_insight.py - Production monitoring
app/services/production_monitoring.py
Farm and GIS
- Farm and block services
app/services - GIS operations
app/services/gis.py
Agronomy knowledge
- Knowledge API
app/api/routes/knowledge.py - RAG processing
app/services/rag.py - Knowledge retrieval
app/repositories/knowledge.py
Persistence
- Async DB sessions
app/db/session.py - Domain models
app/models - Conversation and audit state
app/models/telegram.py - Farm and block repositories
app/repositories - Production repository
app/repositories/production.py - PostgreSQL knowledge store
app/models/knowledge.py
Other components
- Farmer or operator
- Telegram
- PostgreSQL / PostGIS
Connections 25
- Farmer or operator → Telegram: sends updates
- Telegram → Telegram webhook: posts updates
- FastAPI application → API routes: registers routes
app/main.py - FastAPI application → Telegram webhook: registers webhook
app/main.py - Telegram webhook → Telegram adapter: handles updates
app/services/telegram_webhook.py - API routes → Telegram agent: accepts Telegram input
app/api/routes/telegram.py - API routes → Farm and block services: serves farm APIs
app/api/routes/blocks.py - API routes → Knowledge API: serves search
app/api/router.py - Telegram agent → Conversation router: routes messages
- Telegram agent → Allow-listed tools: dispatches tools
app/agent/tools.py - Allow-listed tools → Production insight: gets analysis
- Allow-listed tools → Production monitoring: gets monitoring
- Allow-listed tools → Farm and block repositories: resolves blocks
app/agent/tools.py - Allow-listed tools → Knowledge retrieval: retrieves knowledge
app/agent/tools.py - Knowledge API → RAG processing: builds answers
app/api/routes/knowledge.py - Knowledge API → Knowledge retrieval: searches chunks
app/api/routes/knowledge.py - Knowledge retrieval → PostgreSQL knowledge store: reads and logs
app/repositories/knowledge.py - Farm and block services → GIS operations: validates geometry
app/api/routes/blocks.py - Farm and block services → Farm and block repositories: reads and writes
app/repositories/knowledge.py - Production repository → PostgreSQL / PostGIS: reads and writes records
app/repositories/production.py - Farm and block repositories → PostgreSQL / PostGIS: reads and writes farms
- Async DB sessions → PostgreSQL / PostGIS: opens sessions
app/db/session.py - Domain models → Async DB sessions: maps database tables
app/models/block.py - Conversation and audit state → Async DB sessions: maps chat state
app/models/telegram.py - PostgreSQL knowledge store → Async DB sessions: uses ORM base