How minxie-ng/trustkaki works
TrustKaki is an AI-assisted check-in and care-coordination system for Active Ageing Centres. A senior initiates the main workflow by messaging through Telegram or WhatsApp; TrustKaki interprets the update with personal context, records care signals, and identifies patterns across time so staff can review a prioritised case and decide how to follow up. Scheduled Telegram outreach is also documented, but depends on an authorised recurring worker invocation.
Components
Messaging and check-ins
• Senior — Path: null (external actor). Sends conversational updates that start the primary workflow.
• Telegram — Path: null (external platform). Carries senior messages and replies; scheduled outreach is documented but not self-activating.
• WhatsApp — Path: null (external platform). Provides a second messaging channel; live delivery depends on external business verification.
• Telegram webhook and service — Path: trustkaki-web/src/app/api/telegram/webhook/route.ts. Receives Telegram webhook events; the repository also has a Telegram service for channel handling.
• WhatsApp webhook and service — Path: trustkaki-web/src/app/api/whatsapp/webhook/route.ts. Receives WhatsApp webhook events; the repository also has a WhatsApp service for channel handling.
• Check-in processing — Path: trustkaki-web/src/lib/checkins/service.ts. Implements check-in service and policy responsibilities; an internal endpoint exposes due-check-in processing.
Understanding, memory, and patterns
• Senior context — Path: trustkaki-web/src/lib/persistence/seniorContextRepository.ts. Loads senior context and, when enabled, retrieves relevant personal memory from the Neon-backed memory application.
• Agent orchestration — Path: trustkaki-web/src/lib/agents/orchestrator.ts. Implements the agent orchestration layer; prompts and contracts define context use and validated decision shapes.
• Personal memory — Path: trustkaki-web/src/lib/memory/applicationRepository.ts. Provides the application-facing memory operations; the context repository uses it for retrieval.
• Pattern Watch — Path: trustkaki-web/src/lib/patterns/patternWatch.ts. Detects supported changes across observations; README describes combining signals across days for staff review.
• Orchestration persistence — Path: trustkaki-web/src/lib/persistence/orchestrationRepository.ts. Persists orchestration results and related signals, and invokes automatic context updates and pattern watching.
Care workspace and staff operations
• Dashboard API — Path: trustkaki-web/src/app/api/dashboard/state/route.ts. Exposes dashboard state to the client.
• Care workspace UI — Path: trustkaki-web/src/components/Dashboard.tsx. Presents staff-facing care work; dashboard subcomponents cover cases, context, contacts, and follow-up.
• Caregiver actions — Path: trustkaki-web/src/app/api/caregiver/queue-action/route.ts. Provides an API entry point for caregiver queue actions.
State and external interfaces
• Supabase persistence — Path: trustkaki-web/src/lib/persistence/persistenceSupport.ts. Supplies the server-side Supabase client and persistence metadata used by persistence modules.
• Neon memory database — Path: trustkaki-web/src/lib/memory/neonDatabase.ts. Implements the Neon database layer for personal memory; the README distinguishes this memory store from operational care records.
• Staff user — Path: null (external actor). Authenticated care staff inspect cases and record follow-up decisions.
• Internal scheduled invoker — Path: null (external actor). Must invoke internal processing endpoints to activate scheduled work.
Relationships
• Senior -> Telegram: sends a check-in message; evidence: README.md.
• Senior -> WhatsApp: sends a check-in message; evidence: README.md.
• Telegram -> Telegram webhook and service: delivers inbound events to the webhook entry point; evidence: trustkaki-web/src/app/api/telegram/webhook/route.ts (inferred from the route’s role; handler-to-service wiring was not excerpted).
• WhatsApp -> WhatsApp webhook and service: delivers inbound events to the webhook entry point; evidence: trustkaki-web/src/app/api/whatsapp/webhook/route.ts (inferred from the route’s role; handler-to-service wiring was not excerpted).
• Telegram webhook and service -> Senior context: resolves messaging identity and assembles context for channel conversations; evidence: trustkaki-web/src/lib/persistence/seniorContextRepository.ts (messaging-identity lookup is shown; caller wiring is not).
• WhatsApp webhook and service -> Senior context: resolves messaging identity and assembles context for channel conversations; evidence: trustkaki-web/src/lib/persistence/seniorContextRepository.ts (messaging-identity lookup is shown; caller wiring is not).
• Senior context -> Personal memory: retrieves relevant Neon personal memory when enabled; evidence: trustkaki-web/src/lib/persistence/seniorContextRepository.ts.
• Telegram webhook and service -> Agent orchestration: processes senior messages through the shared agent workflow; evidence: README.md (the README says channel services call the shared orchestrator directly).
• WhatsApp webhook and service -> Agent orchestration: processes senior messages through the shared agent workflow; evidence: README.md.
• Agent orchestration -> Orchestration persistence: saves validated orchestration outcomes; evidence: README.md (workflow documented; direct call site not sampled).
• Orchestration persistence -> Pattern Watch: invokes pattern detection for a senior; evidence: trustkaki-web/src/lib/persistence/orchestrationRepository.ts.
• Orchestration persistence -> Supabase persistence: writes orchestration-related records and signals; evidence: trustkaki-web/src/lib/persistence/orchestrationRepository.ts.
• Senior context -> Supabase persistence: reads senior and care context; evidence: trustkaki-web/src/lib/persistence/seniorContextRepository.ts.
• Neon memory database -> Personal memory: provides the database layer used by memory operations; evidence: none (inferred from component responsibilities; concrete application wiring was not excerpted).
• Dashboard API -> Supabase persistence: reads dashboard state; evidence: trustkaki-web/src/app/api/dashboard/state/route.ts (persistence call was not excerpted).
• Dashboard API -> Care workspace UI: supplies state for staff dashboard use; evidence: README.md.
• Staff user -> Care workspace UI: reviews prioritised cases and supporting context; evidence: README.md.
• Staff user -> Caregiver actions: submits follow-up or queue actions; evidence: trustkaki-web/src/app/api/caregiver/queue-action/route.ts (external request relationship).
• Internal scheduled invoker -> Check-in processing: invokes due-check-in processing; evidence: README.md.
Coverage limits
The sampled source excerpts do not show the webhook handlers’ service calls, the full agent orchestration implementation, or dashboard and caregiver route persistence calls. Those connections are identified as documented or inferred rather than asserted as directly observed. The README notes that scheduled activation and live channel availability depend on external configuration.
Main entry points: seniorContextRepository.ts Senior context · webhook/route.ts Telegram webhook · webhook/route.ts WhatsApp webhook · orchestrationRepository.ts Orchestration persistence
Components 18
Messaging & Check-ins
- Senior
- Telegram
- WhatsApp · Live delivery depends on external business verification.
- Telegram webhook
trustkaki-web/src/app/api/telegram/webhook/route.ts - WhatsApp webhook
trustkaki-web/src/app/api/whatsapp/webhook/route.ts - Check-in processing
trustkaki-web/src/lib/checkins/service.ts
Understanding & Patterns
- Senior context
trustkaki-web/src/lib/persistence/seniorContextRepository.ts - Agent orchestration
trustkaki-web/src/lib/agents/orchestrator.ts - Personal memory
trustkaki-web/src/lib/memory/applicationRepository.ts - Pattern Watch
trustkaki-web/src/lib/patterns/patternWatch.ts - Orchestration persistence
trustkaki-web/src/lib/persistence/orchestrationRepository.ts
Care Workspace
- Dashboard API
trustkaki-web/src/app/api/dashboard/state/route.ts - Care workspace UI
trustkaki-web/src/components/Dashboard.tsx - Caregiver actions
trustkaki-web/src/app/api/caregiver/queue-action/route.ts - Staff user
State & External Interfaces
- Supabase persistence
trustkaki-web/src/lib/persistence/persistenceSupport.ts - Neon memory database
trustkaki-web/src/lib/memory/neonDatabase.ts - Internal scheduled invoker · Must invoke internal processing endpoints to activate scheduled work.
Connections 19
- Senior → Telegram: sends check-in
README.md - Senior → WhatsApp: sends check-in
README.md - Telegram → Telegram webhook: delivers events · Inferred; not shown in the code that was read.
trustkaki-web/src/app/api/telegram/webhook/route.ts - WhatsApp → WhatsApp webhook: delivers events · Inferred; not shown in the code that was read.
trustkaki-web/src/app/api/whatsapp/webhook/route.ts - Telegram webhook → Senior context: resolves context · Inferred; not shown in the code that was read.
trustkaki-web/src/lib/persistence/seniorContextRepository.ts - WhatsApp webhook → Senior context: resolves context · Inferred; not shown in the code that was read.
trustkaki-web/src/lib/persistence/seniorContextRepository.ts - Senior context → Personal memory: retrieves memory
trustkaki-web/src/lib/persistence/seniorContextRepository.ts - Telegram webhook → Agent orchestration: runs workflow
README.md - WhatsApp webhook → Agent orchestration: runs workflow
README.md - Agent orchestration → Orchestration persistence: saves outcomes
README.md - Orchestration persistence → Pattern Watch: invokes detection
trustkaki-web/src/lib/persistence/orchestrationRepository.ts - Orchestration persistence → Supabase persistence: writes records
trustkaki-web/src/lib/persistence/orchestrationRepository.ts - Senior context → Supabase persistence: reads context
trustkaki-web/src/lib/persistence/seniorContextRepository.ts - Neon memory database → Personal memory: provides database · Inferred; not shown in the code that was read.
- Dashboard API → Supabase persistence: reads state · Inferred; not shown in the code that was read.
trustkaki-web/src/app/api/dashboard/state/route.ts - Dashboard API → Care workspace UI: supplies state
README.md - Staff user → Care workspace UI: reviews cases
README.md - Staff user → Caregiver actions: submits actions
trustkaki-web/src/app/api/caregiver/queue-action/route.ts - Internal scheduled invoker → Check-in processing: invokes processing
README.md