Architecture

5-layer Anthropic-native engine architecture for Databayt

Architecture

Kun is a configuration engine — not a server. It sits as the configuration layer on top of Anthropic's product suite, running both technical and business sides of Databayt.

5-Layer Architecture

Layer 5: Company Operations
  Cowork | Claude Apps | Enterprise Connectors
  Business (Aseel, Moutaz, Moed) | Content (Samia) | Ops (Sedon)

Layer 4: Coordination & Automation
  Agent Teams | Scheduled Tasks | CI/CD | Channels

Layer 3: KUN CONFIGURATION ENGINE (core value)
  CLAUDE.md | Agents | Skills | MCP Servers
  Rules | Hooks | Memory | Keywords
  (live counts: .claude/engine.json — /health flags drift)

Layer 2: Developer Surfaces (Anthropic-provided)
  CLI | VS Code | JetBrains | Desktop | Web | iOS

Layer 1: Foundation (Anthropic-provided)
  Fable 5 | Opus 4.8 | Sonnet 5 | Haiku 4.5 | 1M Context | Subscription

Team Roles

MemberRole
AbdoutFounder & Tech Lead
IbrahimSenior Fullstack & Mobile Engineer
MoutazProduct Engineer (business + sales + AI)
Ali AseelQA + Sales
MoedBusiness Development + Copywriting
SamiaR&D
SedonOps — DevOps, execution

Layer 3: The Engine (Kun's Core)

CLAUDE.md Hierarchy

Priority (High → Low):
1. Project-level  ~/project/CLAUDE.md         — Project context
2. Repo-level     ~/project/.claude/CLAUDE.md  — Keywords, workflows
3. User-level     ~/.claude/CLAUDE.md          — Stack, preferences
4. Pattern library /Users/abdout/codebase/     — Core patterns

Agent Fleet (46 agents, two plugins)

captain (company brain — allocates, decides, never writes code)
├── Business:   revenue, growth, support, analyst
├── Delivery:   product, tech-lead, ops, guardian
├── Engine:     quality, report, analyze, learn, package, clone
└── Reference:  hogwarts, souq, mkan, shifa
        └── kun-stack → 27 specialist agents
FleetPluginAgents
Company (19)kun-companycaptain, revenue, growth, support, analyst, product, tech-lead, ops, guardian, quality, report, analyze, learn, package, clone, hogwarts, souq, mkan, shifa
Stack (27)kun-stacknextjs, react, typescript, tailwind, prisma, shadcn, authjs, architecture, orchestration, pattern, structure, atom, template, block, icon, semantic, build, deploy, test, git, github, middleware, internationalization, sse, optimize, performance, comment

Full breakdown: Agents.

MCP Ecosystem (20 live)

CategoryServers
Browserbrowser, browser-headed, chrome-devtools
Designfigma, figma-desktop, shadcn, claude-design
DevOpsgithub, sentry
DataNeon, stripe
Workspacelinear, slack, notion, posthog
Knowledgeref, context7, markitdown, filesystem
Mediahiggs

Plus the claude.ai connectors (Gmail, Calendar, Drive, PlanetScale, Vercel). Registration lives in ~/.claude.jsonnot ~/.claude/mcp.json, which is only a catalog. See MCP.

Rules Engine (37 domain rules + 5 cross-cutting)

Domain rules auto-load via a paths glob: react-perf (8), next-16 (5), react-19 (5), prisma-6 (4), tailwind-v4 (4), typescript-strict (4), authjs (3), neon (2), s3 (2). Five more load unconditionally: github-workflow, block-protocol, patterns, cowork-bridge, engine-parity.

Hook Automation (9 hooks)

EventAction
SessionStartInject engine context — sync drift, bridge handoffs, open reports
SessionStartNag on a stale or RED maintain heartbeat
ConfigChangeWarn when vocabulary.json drifts from generated docs
PreToolUse (pnpm dev)Kill port 3000
PreToolUse (Bash)Block destructive commands
PostToolUse (pnpm dev)Open Chrome
PostToolUse (Write/Edit)Run Prettier
StopLog session end
NotificationmacOS alert when Claude needs attention

Layer 4: Coordination

Agent Teams (Experimental)

Lead agent coordinates teammate agents, each in isolated git worktrees. No merge conflicts. Consolidated PR.

Cross-Device Flow

Phone (iOS) ──Dispatch──▶ Desktop App ──/teleport──▶ Terminal (CLI)
     ◀──────── Remote Control ──────────────────────────────┘

Scheduled Tasks

TypeRuns OnUse Case
CloudAnthropic infra (computer off)Health checks, dependency updates
DesktopLocal (app open)Recurring builds
/loopActive sessionPoll deploy status

3-Channel Communication

ChannelMediumDirectionPurpose
Native push + bridgePushNotification (Anthropic mobile) + ~/.claude/bridge.md + GitHub Issues (from-captain / from-abdout)Async, bidirectionalUpdates, decisions, handoffs
GitHub Issuesdatabayt/*/issuesStructured work itemsTasks with labels, milestones, assignees
Claude NativeCode / Cowork / VoiceReal-timeBuilding, planning, quick decisions

Cowork ↔ Code Bridge

Cowork (think): plan → create issues → append to ~/.claude/bridge.md
Code (do):      read bridge.md → pick up issues → execute → write results back to bridge.md

Shared state: ~/.claude/ (agents, memory, settings, rules). Same brain, two modes.

Layer 5: Business Operations

Team Workflows

MemberRolePrimary Workflows
AbdoutFounder & Tech Leaddev → build → push → deploy
IbrahimSenior Fullstack & Mobilefeature build, mobile lane, code review
MoutazProduct EngineerSpecs, Albayan pilot, customer feedback
Ali AseelQA + SalesTesting, issue reports, outreach (sales@databayt.org), CRM pipeline
MoedBusiness DevelopmentCopywriting, networking, outbound with Aseel
SamiaR&DClaude/Anthropic research, sharing economy, voice-over
SedonOps — DevOps, executionFacilitates business team, reality-checks, clears blockers

Hogwarts Pilot (King Fahad Schools)

Developer: handover admission → 5-pass QA → deploy to ed.databayt.org
Business:  Cowork → onboarding plan → Arabic welcome email → training agenda
Content:   Cowork → Arabic user guide → screenshots → voiceover

Repository Map

databayt/ (17 repos)
├── Products
│   ├── hogwarts     — Education SaaS (FLAGSHIP, daily commits)
│   ├── mkan         — Rental marketplace (Phase 1 done)
│   ├── souq         — E-commerce (MVP, paused)
│   └── shifa        — Medical platform (early, paused)
├── Libraries
│   ├── codebase     — Pattern library (54 ui + 62 atoms + 31 templates)
│   ├── shadcn       — UI components (shadcn/ui fork)
│   └── radix        — UI primitives (Radix fork)
├── Engine
│   └── kun          — Configuration engine (this repo)
├── Mobile & Marketing
│   ├── ios-app      — iOS app (Swift/SwiftUI)
│   ├── android-app  — Android app (Kotlin)
│   └── marketing    — Landing pages
└── Other
    ├── crm          — Self-hosted CRM (4 workspaces on *.crm.databayt.org)
    ├── spma         — Internal tool
    ├── apple        — Design R&D
    ├── lab          — Experiments
    ├── distributed-computer — Rust/blockchain concept
    └── .github      — Org profile

Security

LayerMechanism
AnthropicSSO/SCIM, audit logging, SOC 2, no training on data
Kun config4 deny rules (rm -rf, DROP TABLE, etc.), 38 explicit allow rules
HooksPreToolUse guards validate before execution
SecretsmacOS Keychain MCP, never in git
AccessibilityScreen reader compatibility, VoiceOver testing

Architecture Decision Records

ADR-001: Configuration Over Infrastructure

Decision: Use Anthropic's products as-is, configure don't build. Rationale: 7-person team can't maintain custom infrastructure alongside 5+ products.

ADR-002: Opus Default

Decision: Use Opus (currently 4.8) for all agents, Haiku only for explore subagents. Rationale: Quality over speed for a small team where every output matters.

ADR-003: Single Subscription Model

Decision: One Max 5x ($100/month) shared via Desktop/Web — subscription-only, no API-key spend. Rationale: $500/month burn with $5K capital = 10 months runway. Add Pro seats ($20) when revenue grows.

ADR-004: Hogwarts-First Development

Decision: All engine features validated through Hogwarts pilot first. Rationale: King Fahad Schools is the revenue pipeline. Ship what pays.

ADR-005: Shared Component Library

Decision: All products pull from databayt/codebase. Rationale: 54 UI + 62 atoms + 31 templates = don't rebuild across 5 products.

Architecture Principles

  1. Configuration over infrastructure — Don't build what Anthropic ships
  2. Architecture-first — Humans design, AI generates within constraints
  3. Guardrails as training data — CLAUDE.md, agents, rules shape output
  4. Full spectrum — Technical AND business operations
  5. Anthropic-native — Use products as designed