Architecture Overview
System Design
The AI Accountant uses a two-layer AI architecture with IDesign internally:
┌─────────────────────────────────────────────────┐
│ Channels: Slack | Teams | Web | Email │
└──────────────────────┬──────────────────────────┘
│
┌──────────────────────▼──────────────────────────┐
│ Conversation Agent (LLM + Memory) │
│ Multi-turn chat, context tracking, clarifying │
│ questions, persona. Routes tasks to API below. │
└──────────────────────┬──────────────────────────┘
│ POST /solve {task, files}
┌──────────────────────▼──────────────────────────┐
│ Accounting API (ASP.NET Core 10, IDesign) │
│ │
│ Clients: API Controllers │
│ Managers: Task, Agent, Monitor, Audit │
│ Engines: Rules, Classify, Amount, Compliance │
│ Resources: AccountingProviders, LLM, DB │
└──────────┬──────────────────────┬───────────────┘
│ │
┌──────────▼──────────┐ ┌────────▼────────────────┐
│ Tripletex API v2 │ │ Fiken API v2 │
└─────────────────────┘ └─────────────────────────┘
The Conversation Agent handles the messy human interaction — multi-turn context, "what do you mean?", remembering yesterday's receipt. The Accounting API is stateless — receives a complete task, executes it, returns result.
Key Design Decisions
1. Hybrid AI — Deterministic + Agent
Simple tasks (create customer, register payment) use regex classification and deterministic handlers — instant, predictable, zero LLM cost.
Complex tasks (year-end closing, bank reconciliation, project lifecycle) use an LLM agent loop with function-calling. The agent sees API errors and recovers automatically.
2. Multi-Provider Architecture
Accounting system access is abstracted behind IAccountingProvider. Each provider (TripletexProvider, FikenProvider) implements the same interface:
- Swappable — add new accounting systems without changing agent logic
- Testable — mock the provider interface for unit tests
- Per-company — each company connects to their own accounting system
3. Rules Engine — Not Just AI
Company policies are configured as YAML rules, not LLM prompts. The rules engine evaluates deterministically:
travel_expense:
max_daily_rate: 800
receipt_required_above: 500
approval_required_above: 5000
The LLM handles language understanding. The rules engine handles compliance. Clear separation.
4. Audit Trail — Norwegian Law Compliant
Every API call is logged with timestamp, user, action, and result. Required by bokforingsloven (Norwegian Bookkeeping Act). Every action can be undone within 24 hours.