How timothylee58/naktahu-ai works
NakTahu AI is a Malaysian trilingual civic-answer platform with cited government-source retrieval, specialist agents, and supporting user and developer services. The main workflow runs from a user query through the streaming API, retrieval and answer synthesis, then returns tokens and citations; the web client also supports voice input and answer translation. The README documents additional agent, Warung Watch, parliamentary, history, sharing, and developer-API capabilities. Some of these implementations were not sampled, so their links are shown only where documented, and unsampled details are not inferred.
Main entry points: main.py API application · query.py Streaming query · page.tsx Chat interface · graph.py Answer workflow
Components 32
User experience
- Chat interface
apps/web/src/app/chat/page.tsx - Voice input
apps/web/src/lib/hooks/useVoiceInput.ts - Answer translation
apps/api/routers/translate.py
Answer engine
- Streaming query
apps/api/app/routers/query.py - Answer workflow
apps/api/app/agents/graph.py - Safety scanning
apps/api/app/agents/guard_node.py - Hybrid retrieval
apps/api/rag/retriever.py - LLM client
apps/api/app/services/llm_client.py
Agent services
- Agent endpoints
apps/api/app/routers/agents.py - Grant matching
apps/api/app/routers/eligibility.py - Investor intelligence
apps/api/app/routers/investor.py - Agent runtime
apps/api/app/services/agent_runner.py - Agent sessions
apps/api/app/agents/checkpointer.py - Specialist agents
apps/api/app/agents - Parliament lookup
apps/api/app/agents/parliament_query_node.py
Platform services
- API application
apps/api/app/main.py - Warung Watch
apps/api/routers/warung_watch.py - Developer API
apps/api/routers/developer.py - API key service
apps/api/services/api_key_service.py - Query history
apps/api/routers/history.py - History service
apps/api/services/history.py - Billing
apps/api/routers/billing.py - Billing service
apps/api/services/billing.py - Runtime configuration
apps/api/core/config.py - Rate limiting
apps/api/middleware/rate_limit.py - Plan gating
apps/api/middleware/plan_gate.py - Query metadata
apps/api/routers/_request_fields.py
Data and integrations
- Vector store
apps/api/app/services/vector_store.py - Grant and welfare sources
- Google Places
Other components
- User
- External integrator
Connections 34
- User → Chat interface: asks
- Chat interface → Streaming query: sends query
- Voice input → Chat interface: dictates into
- API application → Streaming query: routes to
apps/api/app/main.py - Streaming query → Answer workflow: runs workflow
apps/api/app/routers/query.py - Answer workflow → Safety scanning: scans safely
- Answer workflow → Hybrid retrieval: retrieves sources
- Hybrid retrieval → Vector store: searches corpus
- Answer workflow → LLM client: synthesises answer
- Streaming query → Chat interface: streams answer
- Answer translation → Chat interface: translates answer
- API application → Agent endpoints: routes to
apps/api/app/main.py - API application → Grant matching: routes to
apps/api/app/main.py - API application → Investor intelligence: routes to
apps/api/app/main.py - Agent endpoints → Agent runtime: runs agents
apps/api/app/routers/agents.py - Grant matching → Agent sessions: loads sessions
apps/api/app/routers/eligibility.py - Grant matching → Specialist agents: invokes matching
apps/api/app/routers/eligibility.py - Grant matching → Grant and welfare sources: matches schemes
- Investor intelligence → Specialist agents: runs intelligence
apps/api/app/routers/investor.py - Specialist agents → Grant and welfare sources: uses grant sources
- Parliament lookup → Streaming query: supports lookup
- API application → Warung Watch: routes to
apps/api/app/main.py - Warung Watch → Google Places: searches nearby
- API application → Developer API: routes to
apps/api/app/main.py - Developer API → API key service: manages keys
apps/api/routers/developer.py - External integrator → Developer API: calls API
- API application → Query history: routes to
apps/api/app/main.py - Query history → History service: reads and writes
apps/api/routers/history.py - API application → Billing: routes to
apps/api/app/main.py - Billing → Billing service: handles billing
apps/api/routers/billing.py - Streaming query → Query metadata: validates metadata
apps/api/app/routers/query.py - API application → Runtime configuration: configures runtime
apps/api/app/main.py - API application → Rate limiting: applies limits
apps/api/app/main.py - Agent endpoints → Plan gating: checks plan
apps/api/app/routers/agents.py