Open Source ยท Python ยท Google ADK

Point at a database.
Get an agentic backend.

NinjaStack auto-generates AI agents, GraphQL APIs, authentication, and UI from your schema. Define once, generate everything.

terminal
# Connect to your database, generate everything
$ ninjastack introspect --db postgres://localhost/myapp
โ†’ Discovered 12 entities, 8 relationships, 3 domains

$ ninjastack sync
โ†’ Generated: 12 models, 18 agents, 12 GraphQL types
โ†’ Wired: 3 domain agents + coordinator
โ†’ Auth: JWT + RBAC configured

$ ninjastack serve
โ†’ ๐Ÿฅท Agentic backend running at http://localhost:8000
โ†’ GraphQL playground at /graphql
โ†’ Agent chat at /chat

The problem with building agentic backends

Every team building AI agents rewrites the same boilerplate: data access, tool definitions, permission checks, API layers, agent orchestration.

The result? Months of plumbing before any agent does anything useful. Fragile hand-wired tool registrations. Auth bolted on as an afterthought. No clear ownership boundaries between agents.

Schema-first changes everything

NinjaStack starts from what you already have โ€” your database schema. From that single source of truth, it generates the entire agentic stack.

Agents get scoped tools per entity. Domains define ownership boundaries. RBAC is declarative. GraphQL is automatic. You focus on business logic, not wiring.

Built for real backends

Not a toy. A production framework for schema-driven agentic systems.

๐Ÿ”

Database Introspection

Connect to SQL, MongoDB, Neo4j, or vector stores. NinjaStack discovers entities, fields, relationships, and constraints automatically.

๐Ÿค–

ADK Agent Generation

Auto-generates Google ADK agents with scoped CRUD tools per entity. Data agents are deterministic (no LLM). Domain agents use Gemini for reasoning.

๐Ÿงฌ

Agentic Schema Definition

A typed, composable schema language for entities, relationships, domains, and agent configs. Your single source of truth.

๐Ÿ”

Auth & RBAC

Pluggable auth (OAuth2, JWT, API keys) with role-based access control at the domain and entity level. Declarative, not bolted on.

๐Ÿ“Š

GraphQL Generation

Strawberry GraphQL types, queries, mutations, and inputs generated from your schema. Permission-enforced at the resolver level.

๐Ÿ’ฌ

Conversational Setup

Don't have a database yet? Chat with the Setup Assistant (real Gemini-powered LlmAgent) to design your schema through natural dialogue.

๐ŸŽฏ

Tool Scoping

Each agent sees only its own tools. Data agents own one entity. Domain agents own one domain. The coordinator routes across domains. No leaking.

๐Ÿš€

K8s Deployment

Helm charts and deployment manifests generated automatically. Deploy your agentic backend to GKE, EKS, or any Kubernetes cluster.

๐Ÿ”„

Polyglot Persistence

Unified persistence layer across SQL, NoSQL, graph, and vector databases. Entities declare their storage engine; the framework handles the rest.

Three paths to an agentic backend

Start from an existing database, from conversation, or both.

๐Ÿ”Œ

Bolt-on Mode

Connect to an existing database. NinjaStack introspects your schema and generates the full stack around it.

ninjastack introspect \
  --db postgres://...
  --db mongo://...
  --db neo4j://...
๐Ÿ’ฌ

Greenfield Mode

No database? Chat with the AI setup assistant to design your domain model through natural conversation.

ninjastack init --interactive

# "I need a bookstore with
#  books, customers, orders,
#  and reviews..."
๐Ÿ”€

Hybrid Mode

Bolt-on to an existing system, then expand the schema conversationally. Best of both worlds.

ninjastack introspect --db ...
ninjastack assistant
# "Add a Reviews entity
#  with semantic search..."

Agent hierarchy with clear boundaries

Every agent has a scope. No tool leaking. No implicit state. Explicit ownership at every level.

๐ŸŽฏ Coordinator Agent
Routes requests across domains ยท LLM-powered intent classification
โ†“
๐Ÿ“š Catalog Domain Agent
Gemini 2.5 Flash ยท Medium reasoning
๐Ÿ“– Book
6 CRUD tools
โญ Review
6 CRUD tools + semantic
๐Ÿ›’ Commerce Domain Agent
Gemini 2.5 Pro ยท High reasoning
๐Ÿ‘ค Customer
6 CRUD tools
๐Ÿ“ฆ Order
6 CRUD tools
โ†“
๐Ÿ—„๏ธ Unified Persistence Layer
PostgreSQL MongoDB Neo4j ChromaDB
Data Agents

Deterministic. No LLM. One entity, scoped tools. Fast, predictable CRUD.

Domain Agents

LLM-powered. Owns a business domain. Delegates to data agents. Configurable reasoning level.

Coordinator

Top-level router. Classifies intent. Delegates to the right domain. Synthesizes cross-domain results.

See it in action

Real code from the bookstore example. No pseudo-code.

01

Define your schema

from ninja_core.schema.entity import EntitySchema, FieldSchema, FieldType, StorageEngine
from ninja_core.schema.domain import DomainSchema

book = EntitySchema(
    name="Book",
    storage_engine=StorageEngine.SQL,
    fields=[
        FieldSchema(name="id", field_type=FieldType.UUID, primary_key=True),
        FieldSchema(name="title", field_type=FieldType.STRING, indexed=True),
        FieldSchema(name="author", field_type=FieldType.STRING),
        FieldSchema(name="price", field_type=FieldType.FLOAT),
    ],
)

catalog = DomainSchema(
    name="Catalog",
    entities=["Book", "Review"],
    agent_config=AgentConfig(reasoning_level=ReasoningLevel.MEDIUM),
)
02

Agents wire automatically

from ninja_agents.base import DataAgent, DomainAgent, CoordinatorAgent

# Data agents: deterministic CRUD, no LLM
book_agent = DataAgent(entity=book)
book_agent.execute("book_get", id="abc-123")  # Instant, no API call

# Domain agents: LLM-powered orchestration
catalog = DomainAgent(domain=catalog_domain, data_agents=[book_agent, review_agent])

# Coordinator: routes across all domains
coordinator = CoordinatorAgent(domain_agents=[catalog, commerce])
coordinator.route("Find sci-fi books", target_domains=["Catalog"])
03

Declarative auth & permissions

from ninja_auth.rbac import RBACConfig, RBACPolicy, RoleDefinition

policy = RBACPolicy(config=RBACConfig(roles={
    "customer": RoleDefinition(permissions=[
        "read:Catalog",             # Browse books and reviews
        "write:Catalog.Review",     # Write reviews only
        "read:Commerce.Order",      # View own orders
    ]),
}))

# Built-in: admin (*:*), editor (read:* + write:*), viewer (read:*)
policy.check(user_perms, "write", "Catalog", "Book")  # โ†’ PermissionError!

The stack

Built on proven foundations. No custom runtime. No vendor lock-in.

๐Ÿ
Python 3.12+
Pydantic v2
๐Ÿค–
Google ADK
Agent framework
โšก
FastAPI
API server
๐Ÿ“
Strawberry
GraphQL
๐Ÿ”ฎ
LiteLLM
Model-agnostic
๐Ÿ”‘
JWT + OAuth2
Auth strategies
โ˜ธ๏ธ
Kubernetes
Helm deploy
๐Ÿ“ฆ
uv
Package management

Modular monorepo

15 focused packages. Use what you need.

libs/
ninja-core ASD schemas
ninja-introspect DB discovery
ninja-codegen Code generation
ninja-agents ADK agents
ninja-auth Auth + RBAC
ninja-gql GraphQL layer
ninja-persistence Polyglot DB
ninja-boundary Data coercion
 
ninja-graph Graph-RAG
ninja-models Model gen
ninja-deploy K8s/Helm
ninja-ui UI generation
ninja-cli CLI tooling
apps/
ninja-api FastAPI server
ninja-setup-assistant Gemini wizard

Stop wiring. Start building.

NinjaStack is open source and ready to use. Define your schema, generate your stack, ship your agents.

pip install agentic-backend