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
| Member | Role |
|---|---|
| Abdout | Founder & Tech Lead |
| Ibrahim | Senior Fullstack & Mobile Engineer |
| Moutaz | Product Engineer (business + sales + AI) |
| Ali Aseel | QA + Sales |
| Moed | Business Development + Copywriting |
| Samia | R&D |
| Sedon | Ops — 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
| Fleet | Plugin | Agents |
|---|---|---|
| Company (19) | kun-company | captain, revenue, growth, support, analyst, product, tech-lead, ops, guardian, quality, report, analyze, learn, package, clone, hogwarts, souq, mkan, shifa |
| Stack (27) | kun-stack | nextjs, 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)
| Category | Servers |
|---|---|
| Browser | browser, browser-headed, chrome-devtools |
| Design | figma, figma-desktop, shadcn, claude-design |
| DevOps | github, sentry |
| Data | Neon, stripe |
| Workspace | linear, slack, notion, posthog |
| Knowledge | ref, context7, markitdown, filesystem |
| Media | higgs |
Plus the claude.ai connectors (Gmail, Calendar, Drive, PlanetScale, Vercel). Registration lives in ~/.claude.json — not ~/.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)
| Event | Action |
|---|---|
| SessionStart | Inject engine context — sync drift, bridge handoffs, open reports |
| SessionStart | Nag on a stale or RED maintain heartbeat |
| ConfigChange | Warn 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 |
| Stop | Log session end |
| Notification | macOS 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
| Type | Runs On | Use Case |
|---|---|---|
| Cloud | Anthropic infra (computer off) | Health checks, dependency updates |
| Desktop | Local (app open) | Recurring builds |
| /loop | Active session | Poll deploy status |
3-Channel Communication
| Channel | Medium | Direction | Purpose |
|---|---|---|---|
| Native push + bridge | PushNotification (Anthropic mobile) + ~/.claude/bridge.md + GitHub Issues (from-captain / from-abdout) | Async, bidirectional | Updates, decisions, handoffs |
| GitHub Issues | databayt/*/issues | Structured work items | Tasks with labels, milestones, assignees |
| Claude Native | Code / Cowork / Voice | Real-time | Building, 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
| Member | Role | Primary Workflows |
|---|---|---|
| Abdout | Founder & Tech Lead | dev → build → push → deploy |
| Ibrahim | Senior Fullstack & Mobile | feature build, mobile lane, code review |
| Moutaz | Product Engineer | Specs, Albayan pilot, customer feedback |
| Ali Aseel | QA + Sales | Testing, issue reports, outreach (sales@databayt.org), CRM pipeline |
| Moed | Business Development | Copywriting, networking, outbound with Aseel |
| Samia | R&D | Claude/Anthropic research, sharing economy, voice-over |
| Sedon | Ops — DevOps, execution | Facilitates 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
| Layer | Mechanism |
|---|---|
| Anthropic | SSO/SCIM, audit logging, SOC 2, no training on data |
| Kun config | 4 deny rules (rm -rf, DROP TABLE, etc.), 38 explicit allow rules |
| Hooks | PreToolUse guards validate before execution |
| Secrets | macOS Keychain MCP, never in git |
| Accessibility | Screen 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
- Configuration over infrastructure — Don't build what Anthropic ships
- Architecture-first — Humans design, AI generates within constraints
- Guardrails as training data — CLAUDE.md, agents, rules shape output
- Full spectrum — Technical AND business operations
- Anthropic-native — Use products as designed
On This Page
Architecture5-Layer ArchitectureTeam RolesLayer 3: The Engine (Kun's Core)CLAUDE.md HierarchyAgent Fleet (46 agents, two plugins)MCP Ecosystem (20 live)Rules Engine (37 domain rules + 5 cross-cutting)Hook Automation (9 hooks)Layer 4: CoordinationAgent Teams (Experimental)Cross-Device FlowScheduled Tasks3-Channel CommunicationCowork ↔ Code BridgeLayer 5: Business OperationsTeam WorkflowsHogwarts Pilot (King Fahad Schools)Repository MapSecurityArchitecture Decision RecordsADR-001: Configuration Over InfrastructureADR-002: Opus DefaultADR-003: Single Subscription ModelADR-004: Hogwarts-First DevelopmentADR-005: Shared Component LibraryArchitecture Principles