Your backend architecture,
readable by machines.
SysMARA is a TypeScript framework where system architecture is a formal, machine-readable graph — not scattered across code, comments, and tribal knowledge. AI agents read your specs, understand constraints, and make safe changes.
AI agents see files, not architecture.
AI coding agents are powerful, but they operate blind. They can generate code, but they cannot reason about what a change will break, which invariants must hold, or which modules they should not touch.
Traditional frameworks — Express, NestJS, Rails, Django — were designed for human developers who carry the system's architecture in their heads. Decorators, middleware chains, and implicit conventions work when the person writing code already understands the system. AI agents do not have that context.
The result: AI-generated code that compiles but violates business rules, crosses module boundaries, breaks invariants, and requires constant human review to catch architectural mistakes.
Explicit system truth.
SysMARA makes your architecture a formal artifact. Every entity, capability, policy, invariant, module boundary, and data flow is declared in YAML specs, validated with Zod schemas, and compiled into a typed system graph. There is nothing to guess. There is nothing hidden.
When an AI agent needs to add a capability, it reads the system graph, checks which entities are involved, which invariants must hold, which policies govern access, and which module boundaries it must respect. Before writing any code, it can generate a change plan with impact analysis and risk classification.
Four pillars.
AI System Graph
A formal directed graph of your system: entities, capabilities, modules, policies, invariants, and flows as typed nodes with typed edges. A queryable, traversable graph that AI agents use to understand your system before changing it.
Learn more →Capability Compiler
Reads your capability specs along with their entity, policy, and invariant bindings, then generates route handler stubs, test scaffolds, and capability metadata with SHA-256 checksums. Generated code is deterministic and regenerable.
Learn more →Change Protocol
Before mutating code, generate a formal Change Plan: what changes, what's affected, what risk level, which invariants are at stake, and whether human review is required. AI agents plan changes before making them.
Learn more →Database Layer
Pluggable database adapters for Prisma, Drizzle, and TypeORM — plus SysMARA ORM, an AI-first ORM where schema is the system graph, every query is a capability, invariants become DB constraints, and every operation is logged as structured JSON.
Learn more →What you declare.
Entities
Domain objects with typed fields, constraints, and module assignments. The nouns of your system.
Capabilities
Named operations with typed inputs/outputs, entity bindings, policy gates, and invariant checks. The verbs.
Policies
Access control rules with actor conditions, priority ordering, and allow/deny effects.
Invariants
Business rules that must hold. Bound to entities and capabilities. Enforced at compile time, runtime, or both.
Modules
Boundary enforcement. Explicit allowed/forbidden dependencies. Cycle detection. Ownership of entities and capabilities.
Safe Edit Zones
File ownership: generated (don't touch), editable (your code), protected (needs review), human-review-only.
SysMARA ORM: the AI-first database layer.
Traditional ORMs hide SQL behind abstraction layers designed for humans. SysMARA ORM does the opposite — it makes every database operation transparent, bounded, and machine-readable.
Schema IS the Graph
No separate ORM schema. SysMARA ORM reads your system graph and generates SQL directly from entity specs.
Capability-Scoped Queries
No arbitrary queries. Every database operation is scoped to a declared capability with typed inputs and outputs.
Machine-Readable Log
Every operation logged as structured JSON: capability, entity, invariants checked, duration, affected rows.
Impact-Aware Migrations
Migrations that know which capabilities and invariants are affected. Risk classification before any schema change.
Flow Execution Engine: flows that actually run.
Declared flows are no longer just documentation. The Flow Execution Engine executes multi-step workflows with saga compensation, retry with exponential backoff, condition evaluation, and AI-readable execution logs.
Saga Compensation
When a step fails, compensation runs in reverse order for all completed steps. Full rollback, properly recorded. Learn about flows →
Context Threading
Output from step N flows automatically to step N+1. No manual wiring required.
Safe Conditions
Step conditions evaluated with a recursive descent parser. No eval(). Supports property access and comparisons.
Execution Log
Every execution produces structured JSON with success rates, durations, and AI-readable summaries.
Build from one prompt.
Write a single product description. An AI agent reads BOOTSTRAP.md, generates all YAML specs,
validates, compiles, implements capability handlers, and starts a running server. One prompt — full backend.
# The actual prompt sent to Claude Code:
"Use SysMARA (@sysmara/core). Build a SaaS task manager.
npm init -y && npm install @sysmara/core && npx sysmara init
Create system/ specs: entities (User, Workspace, Task, Comment),
capabilities (create_workspace, invite_member, create_task,
assign_task, complete_task, add_comment), policies, invariants,
modules, flows. Then: npx sysmara build && npx sysmara compile"
# What happened (verified, 0 errors):
$ npx sysmara build
✓ 0 errors 1 warning (cosmetic)
$ npx sysmara compile
✓ 18 files generated
✓ 6 route handlers 6 test scaffolds 6 metadata files
✓ system-graph.json — 20 nodes, 27 edges SaaS Task Manager
5 entities, 6 capabilities, 2 modules, 1 flow. 18 files generated. 0 errors.
E-Commerce API
6 entities, 7 capabilities, 4 modules, 1 flow. 21 files generated. 0 errors.
Blog Platform
5 entities, 8 capabilities, 3 modules, 1 flow. 24 files generated. 0 errors.
Scaffold: from specs to code in one step.
After sysmara build, your app/ directory is no longer empty. The scaffold generator
reads your YAML specs and produces starter TypeScript implementation files — typed entity interfaces,
capability handlers, policy enforcers, invariant validators, and module service classes.
Entity Interfaces
Typed TypeScript interfaces with field definitions and runtime validation helpers, generated from system/entities.yaml.
Capability Handlers
Handler functions with typed input/output imports from generated routes, and TODO comments for each policy and invariant.
Policy & Invariant Stubs
Enforcement functions and validation logic with condition comments derived directly from your YAML specs.
Never Overwrites
Scaffold files are written once. Re-running build or scaffold skips existing files — your edits are safe.
What it looks like.
Declare an entity
# system/entities.yaml
- name: subscription
description: A recurring billing subscription
module: billing
fields:
- name: plan_id
type: string
required: true
- name: status
type: string
required: true
constraints:
- type: enum
value: [active, paused, cancelled, past_due]
- name: current_period_end
type: datetime
required: true
invariants:
- cannot_downgrade_with_unpaid_invoices Declare a capability
# system/capabilities.yaml
- name: cancel_subscription
description: Cancel an active subscription
module: billing
entities: [subscription, invoice]
input:
- name: subscription_id
type: string
required: true
- name: reason
type: string
required: false
output:
- name: subscription
type: object
required: true
policies: [billing_admin, owner_transfer]
invariants: [cannot_downgrade_with_unpaid_invoices]
sideEffects: [send_cancellation_email, prorate_final_invoice] Build and inspect
$ sysmara validate
[OK] Parsed 4 entities, 14 capabilities, 5 policies, 8 invariants, 3 modules, 3 flows
$ sysmara impact entity subscription
Target: entity:subscription
Affected modules: billing, workspaces
Affected capabilities: cancel_subscription, upgrade_subscription, downgrade_subscription
Affected invariants: cannot_downgrade_with_unpaid_invoices
Impact radius: 12 nodes
$ sysmara plan create "Add team billing"
[OK] Change plan written to .framework/plans/plan-a1b2c3d4e5f6.yaml
Risk: medium | Affected nodes: 8 | Human review: yes Real-world systems.
SaaS Billing
Users, workspaces, subscriptions, invoices. Includes a sample change plan for adding team billing.
Admin Approvals
Multi-step approval workflows with audit trails and human-review-only safe edit zones.
Content Publishing
Article lifecycle state machine, media assets, moderation policies.
Ship AI-safe backends.
SysMARA is open source, MIT licensed, and designed for teams building with AI agents.