How organizacao-dukamp/ia-dukamp works
TPEC-IA is a Brazilian livestock-focused AI assistant with an institutional landing page and WhatsApp as its user-facing channel. The documented message workflow runs from the WhatsApp webhook through the private backend and conversation handling into the chat core, which combines internal data and RAG with optional current-web research before producing one reply. The product also includes weather-aware answers, media analysis, market quotes, a read-only DuKamp catalog integration, and authenticated administration for knowledge, products, AI health, and quotes. Some subsystem links are documented only at a high level; unverified connections are dashed.
Main entry points: core.server.ts Chat core · client.server.ts TPEC Supabase client · backend.server.ts WhatsApp backend · query-router.server.ts Query and intent routing
Components 28
User channels
- Institutional landing
src/routes/index.tsx - WhatsApp webhook
src/routes/api/public/whatsapp.ts - WhatsApp HTTP handler
src/lib/whatsapp/enhanced-http.server.ts - WhatsApp backend
src/lib/whatsapp/backend.server.ts - Conversation handling
src/lib/whatsapp/conversation.server.ts - Media processing
src/lib/whatsapp/media.server.ts
Assistant runtime
- Chat core
src/lib/chat/core.server.ts - Query and intent routing
src/lib/chat/query-router.server.ts - AI orchestration
src/lib/ai/orchestrator.server.ts - Model providers
src/lib/ai/providers - Weather intelligence
src/lib/chat/weather-intelligence.server.ts
Knowledge and data
- Knowledge retrieval
src/lib/rag/search.server.ts - Knowledge ingestion
src/lib/rag/ingest.server.ts - DuKamp knowledge tools
src/lib/rag/dukamp-package.ts - Livestock quotes
src/lib/market/livestock.server.ts - Market data
src/lib/market/market.server.ts - Market ingestion
src/lib/market/ingest.server.ts - DuKamp catalog lookup
src/lib/site/site-lookup.server.ts - TPEC Supabase client
src/integrations/supabase/client.server.ts - DuKamp Supabase client
src/lib/site/site-client.server.ts
Operations and admin
- Admin access
src/integrations/supabase/auth-middleware.ts - Knowledge admin
src/routes/_authenticated/admin.base-conhecimento.tsx - Product admin
src/routes/_authenticated/admin.produtos.tsx - AI health admin
src/routes/_authenticated/admin.ia.tsx - Quote admin
src/routes/_authenticated/admin.cotacoes.tsx - Market ingest endpoint
src/routes/api/public/market-ingest.ts
Other components
- Producer
- Meta WhatsApp
Connections 30
- Producer → Institutional landing: views
README.md - Institutional landing → Meta WhatsApp: opens conversation
README.md - Meta WhatsApp → WhatsApp webhook: posts message
README.md - WhatsApp webhook → WhatsApp HTTP handler: dispatches
README.md - WhatsApp HTTP handler → WhatsApp backend: dispatches
README.md - WhatsApp backend → Conversation handling: handles conversation
README.md - WhatsApp backend → Chat core: calls core
README.md - WhatsApp backend → Media processing: processes media
- Chat core → Query and intent routing: routes queries
- Chat core → Knowledge retrieval: retrieves evidence
README.md - Chat core → AI orchestration: generates answer
- AI orchestration → Model providers: uses models
- Chat core → Weather intelligence: handles weather
- Knowledge ingestion → TPEC Supabase client: stores embeddings
src/lib/rag/ingest.server.ts - Knowledge retrieval → TPEC Supabase client: reads knowledge
- Market ingestion → Market data: writes quotes
src/lib/market/ingest.server.ts - Market ingestion → TPEC Supabase client: persists data
src/lib/market/ingest.server.ts - Market ingest endpoint → Market ingestion: dispatches sync
src/routes/api/public/market-ingest.ts - Market ingest endpoint → Livestock quotes: dispatches quotes
src/routes/api/public/market-ingest.ts - Livestock quotes → TPEC Supabase client: reads quotes
- Query and intent routing → Market data: checks market intent
src/lib/chat/query-router.server.ts - Query and intent routing → Livestock quotes: checks market intent
src/lib/chat/query-router.server.ts - Query and intent routing → DuKamp catalog lookup: looks up catalog
src/lib/chat/query-router.server.ts - DuKamp catalog lookup → DuKamp Supabase client: reads public data
- Knowledge admin → Knowledge ingestion: manages ingestion
- Knowledge admin → DuKamp knowledge tools: manages packages
- Admin access → TPEC Supabase client: authenticates users
- Product admin → DuKamp catalog lookup: manages catalog
- AI health admin → AI orchestration: checks AI health
- Quote admin → Livestock quotes: views quotes