# DAARION Architecture Diagram ## Production-Grade Stack with Event Bus ``` ┌──────────────────────────────┐ │ MONITORING │ │ Prometheus :9090 Grafana:3030│ │ Alerts + Queue Lag │ └───────────────┬──────────────┘ │ metrics/logs/alerts │ ┌───────────────────────────────────────┴──────────────────────────────────┐ │ CONTROL PLANE │ │ │ │ Control Plane :9200 │ │ ├── /prompts/{agent_id} — versioned system prompts │ │ ├── /policy/{agent_id} — RBAC, entitlements, modes │ │ ├── /config/{key} — routing rules, feature flags │ │ └── /quotas/{user_id} — rate limits, budgets │ │ │ └───────────────────────────────────────┬──────────────────────────────────┘ │ policy/config fetch (cached) │ ┌───────────────────────────────────────┴──────────────────────────────────┐ │ DATA PLANE │ │ │ │ Gateway (BFF) :9300 │ │ ├── Telegram webhooks │ │ ├── Auth, sessions, throttling │ │ └── Request normalization │ │ │ │ │ ▼ │ │ Router :9102 │ │ ├── Agent routing │ │ ├── Tool orchestration │ │ ├── Policy enforcement │ │ └── LLM calls (DeepSeek/Mistral/Grok/Ollama) │ │ │ │ │ ▼ │ │ Swapper (GPU) :8890 │ │ ├── Vision (qwen3-vl) │ │ ├── STT (faster-whisper) │ │ ├── TTS (edge-tts) │ │ └── Image Gen (FLUX lazy) │ │ │ │ Ingest :8100 ──► [NATS: attachment.created] │ │ Parser :8101 ◄── [NATS: attachment.created] ──► [attachment.parsed] │ │ │ └──────────────────────────────────────────────────────────────────────────┘ │ ┌───────────────────────────────────────┴──────────────────────────────────┐ │ ORCHESTRATION / JOBS │ │ │ │ CrewAI :9010 CrewAI Worker :9011 │ │ ├── Agent definitions ├── [NATS: agent.run.requested] │ │ └── Crew management └── [NATS: agent.run.completed] │ │ │ └──────────────────────────────────────────────────────────────────────────┘ │ ┌───────────────────────────────────────┴──────────────────────────────────┐ │ DATA LAYER │ │ │ │ Memory API :8000 ◄─── ЕДИНСТВЕННАЯ ТОЧКА ДОСТУПА К ДАНИМ │ │ │ │ │ ├──► PostgreSQL :5432 (facts, sessions, quotas, audit) │ │ ├──► Qdrant :6333 (vectors: messages, docs, artifacts) │ │ ├──► Neo4j :7687 (graph: users, topics, relations) │ │ └──► Redis :6379 (cache, sessions) │ │ │ └──────────────────────────────────────────────────────────────────────────┘ ┌──────────────────────────────────────────────────────────────────────────┐ │ EVENT BUS (CROSS-CUTTING) │ │ │ │ NATS JetStream :4222 │ │ │ │ Streams: │ │ ├── MESSAGES (message.received/processed/sent) │ │ ├── ATTACHMENTS (attachment.created/parsed/indexed) │ │ ├── AGENT_RUNS (agent.run.requested/completed/failed) │ │ ├── MEMORY (memory.store/indexed) │ │ └── AUDIT (audit.action/error, ops.health/alert) │ │ │ │ Consumers: │ │ ├── parser-pipeline (attachment.created.>) │ │ ├── crewai-worker (agent.run.requested) │ │ ├── memory-indexer (memory.store.>) │ │ └── audit-logger (audit.>) │ │ │ └──────────────────────────────────────────────────────────────────────────┘ ``` ## Key Principles 1. **NATS is cross-cutting** — connects all layers, not just bottom 2. **Control Plane** — policy/config separate from data plane 3. **Memory API** — single access point to all data stores 4. **Async by default** — Parser, Workers via NATS 5. **Observability** — metrics + logs + trace_id everywhere