Skip to content

C4 Level 2 — Containers

The technical subsystems and how they communicate. Note the two-layer AI architecture: the Conversation Agent handles multi-turn chat, while the Accounting API handles stateless task execution.

C4 Level 2 — Containers

Containers

Container Technology Purpose
Slack / Teams Adapter Bot API Channel adapter for chat platforms
Web App Next.js + shadcn/ui Chat widget, dashboard, rule config, audit viewer
Email Ingress Webhook Receives forwarded invoices and receipts
Conversation Agent LLM + Memory Store Multi-turn conversation. Context tracking, clarifying questions, persona. Routes tasks to Accounting API.
Accounting API ASP.NET Core 10, C# Stateless task execution. One task per call. Agent orchestrator, rules engine, audit logging.
Scheduler Cron Worker Daily monitoring triggers
Database PostgreSQL / Supabase Audit trail, company config, rules, conversation history
Cache Redis / KV Company context cache (5 min TTL)

Two-Layer AI Architecture

Channel Adapters → Conversation Agent → Accounting API → Tripletex/Fiken
     (Slack,           (Multi-turn,         (Stateless,
      Teams,            context,              one task,
      Web,              clarification,        function-calling,
      Email)            persona)              audit trail)

Why two layers?

Concern Conversation Agent Accounting API
State Stateful (via API history tools) Stateless (one task per call)
LLM use Conversation flow, context resolution Function-calling agent loop
Channels All channel adapters None (pure API)
Memory "You sent a receipt yesterday" None
Clarification "Which Nordvik AS do you mean?" None (must receive complete task)
Database access None (all via Accounting API tools) Sole DB owner
Testability Integration tests Unit tests

Deep dive: how the Conversation Agent works

Data Flows

From To Protocol Data
Slack/Teams Conversation Agent Webhook → Message Chat messages, file uploads
Web App Conversation Agent WebSocket User messages, context
Email Conversation Agent Webhook Parsed email + attachments
Conversation Agent Accounting API HTTPS (function-calling tools) /solve, /query, /conversation, /rules
Conversation Agent LLM SDK Conversation (function-calling)
Scheduler Accounting API HTTP Monitoring triggers
Accounting API LLM SDK Agent loop (function-calling)
Accounting API Tripletex REST (Basic Auth) Accounting CRUD
Accounting API Fiken REST (OAuth2) Accounting CRUD
Accounting API Database SQL Audit trail
Accounting API Cache KV Context cache