System Architecture
The dLANDiscord system is built on a hierarchical, distributed architecture centered around the Assistant Framework. It is designed to be resilient, autonomous, and secure.
Overall Structure (C4 Diagram)
C4Context
title dLANDiscord System Overview (Fortress Architecture)
Person(user, "User (Dan/Liz/Partners)", "Interfaces via WhatsApp, Discord, Telegram, or Web UI")
System_Boundary(fortress, "Fortress (Go Backend)") {
System(main, "Main Orchestrator (main.go)", "Initializes services, registers modules, starts loops")
System(assistant, "Assistant Framework (assistant/)", "Core reasoning, ReAct loop, and planning")
System(scheduler, "Global Scheduler (scheduler.go)", "Persistent task execution engine")
System(observability, "Observability DB (observability.go)", "Session tracking and analytics")
System(webserver, "Web Server & API (webserver.go)", "Dashboards, SSE Streams, and REST API")
}
System_Boundary(ai_layer, "AI Integration Layer") {
System(llm_local, "Local AI (llama-server)", "Local LLM inference (formerly Ollama)")
System(llm_remote, "Remote AI (OpenRouter / Gemini / Anthropic / Grok / Kimi / DeepSeek / Inception / ZAI)", "Cloud LLM providers")
System(llm_search, "Search (Perplexity Direct)", "Real-time web search via 3-tier fallback")
}
System_Boundary(modules, "Modular Subsystems") {
System(sysadmin, "SysAdmin Module (dsysadmin/)", "Infrastructure monitoring and management")
System(whatsapp, "WhatsApp Module (dwhatsapp/)", "Real-time communication bridge")
System(telegram, "Telegram Module (assistant/telegram.go)", "Telegram bot integration")
System(cctv, "CCTV Monitoring (cctv_monitor.go)", "Reolink NVR 8-camera system")
System(security, "Security Audit (sysafe_security_audit.go)", "Nightly autonomous security audits")
System(memory, "Conversation Intelligence (conversation_intelligence.go)", "3-phase memory: summaries, distillation, playbook discovery")
System(wiki, "Wiki Server (wikiserver/)", "Port 7779, goldmark renderer, navigation API, search, TOC, Mermaid")
System(others, "Other Packages (bitcoin, wowcheck, etc.)", "Specialized feature sets")
}
Rel(user, whatsapp, "Messages/Voice")
Rel(user, telegram, "Messages")
Rel(user, webserver, "Dashboard Access")
Rel(whatsapp, assistant, "Query Ingress")
Rel(assistant, llm_local, "Prompting")
Rel(assistant, llm_remote, "Fallback/Main")
Rel(assistant, llm_search, "Search Queries")
Rel(assistant, modules, "Executes Tools")
Rel(scheduler, assistant, "Triggers Scheduled Queries")
Rel(assistant, observability, "Logs Sessions/Executions")
Rel(assistant, cctv, "Doorbell & Anomaly Alerts")
Rel(assistant, security, "Autonomous Remediation")
Data Flow: The Ingress Loop
- Ingress Point: A message arrives via WhatsApp, Discord, Telegram, or the Web API.
- Context Loading: The
AssistantServicecreates aChatSession, loads user metadata, memory context (3-tier), and previous messages. - Planning: The
AdaptivePlannerdecomposes the request into discrete tasks. - ReAct Loop: The agent (e.g., Nikki, Sasha) enters a Thinking -> Action (Tool) -> Observation (Result) cycle.
- Tool Execution:
- Go Tools: Direct internal function calls (e.g.,
websearch,csf_management). - Shell Tools: Bash scripts executed via
TOOL_ARGSenv var. - Delegation: One agent spawns another as a sub-task.
- Go Tools: Direct internal function calls (e.g.,
- Streaming: Thoughts and tool outputs are streamed to the Web UI via SSE.
- Response: A final persona-aware response is delivered to the original ingress platform.
- Memory: On session end,
generateConversationSummary()creates a structured summary, later distilled byRunMemoryDistillation().
Persistent Infrastructure
Global Scheduler
Backed by scheduler.db (SQLite), it ensures that tasks like "Morning Pulses" or "Security Audits" run even after system restarts. Features "Zombie Cleanup" to handle tasks interrupted by crashes.
Observability Database
The observability.db tracks every session, tool call, and agent decision. It provides the data for Mission Control, the system's administrative dashboard.
Conversation Intelligence
The 3-phase memory system (conversation_intelligence.go) provides long-term recall through structured summaries, 3-tier memory distillation, and autonomous playbook discovery. See Conversation Intelligence.
For more details on the AI engine, see Assistant Framework. For LLM providers, see LLM Providers.