Architecture
A complete map of the Yggdrasil ecosystem β from the Nine Realms directory structure to the REST Gateway, every component that makes Lilith v5.0 work, including Multi-Provider LLM, Swarm Intelligence, MCP, Skills, Batch Mode, and the real-time Dashboard.
Nine Realms Layoutβ
The directory structure follows the Norse cosmology. Each realm is a top-level directory with a strict purpose.
Yggdrasil/
β
βββ Asgard/ β Core Technology (permanent)
β βββ Lilith/ CLI agent, memory, orchestrator
β β βββ Lilith/ Core modules (Core, Swarm, MCP,
β β β Dashboard, Lilith, RAG, Scheduler, Plugins)
β β βββ memory/ Hybrid memory (vector + graph + FTS5)
β β βββ skills/ Hot-reloadable skill packs
β βββ lilith-orchestrator/gateway/ FastAPI REST Gateway
β βββ lilith-v3-master-plan.md Phase roadmap
β
βββ Vanaheim/ β AI Agents & Bots
β βββ Bots_Lilith_v5/
β β βββ telegram/ Telegram bot (owner-only)
β β βββ bridge/ Gateway client bridge
β βββ Agents/ 4 active agents (Shalltear, AdΓ‘n, Eva, OdΓn)
β βββ bifrost/ Cross-realm communication protocol
β βββ Core/ Shared agent libraries
β βββ LLM_Experiments/ Model testing
β
βββ Alfheim/ β UI Prototypes
β βββ VSCode_Extension_Lilith/ IDE integration
β βββ ui-seed/ Visual experiments
β
βββ Svartalfheim/ β Knowledge Base
β βββ Knowledge_Base/ Documentation
β βββ Grimorios/ Architecture decisions
β βββ Playbooks/ Deployment guides
β
βββ Muspelheim/ β Active Development
β βββ AutoMode/ Sprint templates
β βββ Hotfixes/ Emergency patches
β
βββ Niflheim/ β Resources
β βββ Datasets/ Training data
β βββ Models/ LLM checkpoints
β
βββ Midgard/ β Personal Apps
β βββ app/ Completed applications
β
βββ Jotunheim/ β Massive Projects
β βββ projects/ Long-term builds
β
βββ Helheim/ β Graveyard
β βββ Archives_Lilith_Legacy/ Old code
β βββ Quarantine/ Regenerable trash
β
βββ website/ β Documentation site (GitHub Pages)
β βββ index.html
β βββ hermes-lilith.html
β βββ architecture.html
β βββ realms.html
β βββ setup.html
β βββ changelog.html
β βββ js/main.js
β βββ css/style.css
β
βββ REGLAS_YGGDRASIL.md β Realm rules
βββ README.md β Project overview
βββ CHANGELOG.md β Version history
βββ setup_yggdrasil.py β Setup script
βββ yggdrasil_cli.py β CLI tool
βββ start_lilith.bat β Launcher script
Request Lifecycleβ
A single message from Telegram travels through multiple layers before returning with an answer. Here's the full path.
| Step | What Happens |
|---|---|
| 1. Telegram | User sends a message to the bot. The bot validates the sender (owner-only) and forwards the text to the Bridge. |
| 2. Bridge | The Bridge (Python client) packages the message into a JSON payload and POSTs it to the Gateway at localhost:8000/api/telegram/chat. |
| 3. Gateway | FastAPI receives the request, generates a session ID (gateway_{user_id}_{timestamp}), and routes to the appropriate handler. |
| 4. Lilith | The orchestrator loads the conversation context, queries hybrid memory (vector + graph + FTS5) for relevant past interactions, checks Skills for applicable routines, and builds the full prompt. |
| 5. LLM Provider | The prompt is sent to LM Studio (local) via OpenAI-compatible API. If LM Studio is unavailable, the LLM Provider automatically falls back to Kimi or another configured remote provider. |
| 6. Skill / Tool Execution | If the model requests a tool or skill, Lilith dispatches it β native tools, MCP connections, dynamic tool calls, or spawns a Swarm agent for parallel work. |
| 7. Dashboard | Real-time events stream to the web Dashboard at localhost:8080 via WebSocket β showing LLM calls, tool executions, memory operations, and swarm progress. |
| 8. Response | The final answer is returned to the Gateway, which forwards it to the Bridge, which sends it back to Telegram as a reply message. |
| 9. Memory Store | The conversation is compressed and stored across all three memory indices (vector, graph, full-text) for future context retrieval and swarm recall. |
Component Relationshipsβ
How the major packages interact. Arrows indicate dependency or communication direction.
Layer 1: Interfacesβ
| Component | Type |
|---|---|
| α¨ Telegram Bot | Interface |
| α² VSCode Extension | Interface |
| α± CLI | Interface |
β HTTP / REST β
Layer 2: Gatewayβ
| Component | Detail |
|---|---|
| α¦ Gateway | FastAPI Β· Port 8000 |
β Internal API β
Layer 3: Coreβ
| Component | Detail |
|---|---|
| α¦ Lilith | Orchestrator |
| α Memory | Vector + Graph + FTS5 |
| α Scheduler | Cron + SQLite |
| α¦ Plugins | Dynamic tools |
| α Swarm | Specialist Agents |
| αΊ Skills | Hot-reload Packs |
| α MCP | Model Context Protocol |
| α Dashboard | WebSocket Β· Port 8080 |
β Multi-Provider LLM β
Layer 4: LLMβ
| Component | Detail |
|---|---|
| α LM Studio | Local Β· localhost:1234 |
| α¨ Kimi / OpenAI | Remote Fallback |
Security Modelβ
Yggdrasil is designed for a single owner. Security is focused on isolation, local execution, and preventing accidental damage.
Owner-Only Accessβ
The Telegram bot only responds to the configured TELEGRAM_OWNER_CHAT_ID. All other users are silently ignored. There is no multi-user support by design.
Local Executionβ
The LLM runs on localhost via LM Studio. Memory is stored in local SQLite. File operations are confined to the host machine. Nothing leaves your network unless a tool explicitly requests it.
Confirmation Gatesβ
Destructive operations (file deletion, process kill, system changes) require explicit human confirmation via Telegram. The agent cannot act autonomously on dangerous commands.
No Secrets in Codeβ
All tokens, API keys, and sensitive configuration live in .env files (gitignored). The .env.example template shows what is needed without exposing values.