How diazperillaj/shaya works
Shaya is a coffee-business management system with a React web app, a FastAPI business API, and a separate analytical-chat service. Staff manage farmer purchases of parchment coffee, processing and roasting, inventory, sales, and fairs; farm users have a distinct cultivation workflow covering farm records, harvest, postharvest, traceability, and quality projections. The chatbot analyzes business data and streams assistant responses. The graph reflects documented routes, service calls, and data access where shown; several farm and frontend subsystem links are necessarily broad because their implementation was not excerpted.
Main entry points: router.py Farm operations API · chat_service.py Turn orchestration · App.tsx Web app routing · base.py PostgreSQL
Components 23
Web application
- Web app routing
frontend/src/App.tsx - Chat interface
frontend/src/features/chat/hooks/useChat.ts
Coffee business API
- Business API
backend/app/api/api_v1/api_v1.py - Parchment inventory
backend/app/api/api_v1/inventory/service.py - Maquila and costing
backend/app/api/api_v1/processes/service.py - Roasted inventory
backend/app/api/api_v1/roasted_coffee/service.py - Inventory movements
backend/app/api/api_v1/roasted_movements/service.py - Sales
backend/app/api/api_v1/sales/service.py - Fair sales
backend/app/api/api_v1/fairs/service.py - Business dashboard
backend/app/api/api_v1/dashboard/service.py
Farm operations
- Farm operations API
backend/app/farm_operations/api/v1/router.py - Farm records
backend/app/farm_operations/api/v1/farms/service.py - Harvest and labor
backend/app/farm_operations/api/v1/harvests/service.py - Postharvest traceability
backend/app/farm_operations/api/v1/traceability/service.py - Quality projection
backend/app/farm_operations/api/v1/quality_projection/service.py
Analytical assistant
- Chat endpoint
chatbot/app/api/v1/chat/router.py - Turn orchestration
chatbot/app/services/chat_service.py - Agent and tools
chatbot/app/agent/loop.py - Conversation memory
chatbot/app/services/memory_service.py
Persistence
- PostgreSQL
backend/app/core/db/base.py
Other components
- Staff or farm user
- LLM provider
- Redis
Connections 23
- Staff or farm user → Web app routing: uses
README.md - Web app routing → Business API: calls business API
README.md - Web app routing → Farm operations API: uses farm routes
frontend/src/App.tsx - Web app routing → Chat interface: routes to chat
frontend/src/App.tsx - Business API → Parchment inventory: dispatches
- Parchment inventory → Maquila and costing: recalculates costs
backend/app/api/api_v1/inventory/service.py - Maquila and costing → Roasted inventory: creates roasted stock
backend/app/api/api_v1/processes/service.py - Maquila and costing → Inventory movements: records stock movement
backend/app/api/api_v1/processes/service.py - Sales → PostgreSQL: reads and writes
backend/app/api/api_v1/sales/service.py - Fair sales → PostgreSQL: reads and writes
backend/app/api/api_v1/fairs/service.py - Business dashboard → PostgreSQL: queries business data
backend/app/api/api_v1/dashboard/service.py - Farm operations API → Farm records: dispatches
- Farm operations API → Harvest and labor: dispatches
- Farm operations API → Postharvest traceability: dispatches
- Farm operations API → Quality projection: dispatches
- Postharvest traceability → Parchment inventory: links drying output
- Chat interface → Chat endpoint: streams chat
README.md - Chat endpoint → Turn orchestration: delegates turn
chatbot/app/api/v1/chat/router.py - Turn orchestration → Agent and tools: runs agent loop
chatbot/app/services/chat_service.py - Turn orchestration → Conversation memory: loads and appends memory
chatbot/app/services/chat_service.py - Turn orchestration → LLM provider: requests completions
chatbot/app/services/chat_service.py - Conversation memory → Redis: uses cache
chatbot/app/services/memory_service.py - Turn orchestration → PostgreSQL: persists conversation
chatbot/app/services/chat_service.py