ferrik-core 0.0.2

Core runtime, triple-response engine, AI discovery, and testing framework for Ferrik
Documentation

Ferrik

CI Coverage License: MIT

Ferrik is an AI-first, full-stack MVC web framework written in Rust, combining Ruby on Rails Convention over Configuration ergonomics with native Agent Experience (AX) alongside human developers.

Quickstart

ferrik new hello_ferrik
cd hello_ferrik
ferrik serve

Starting the development server initializes storage/development.sqlite3, applies pending SeaORM migrations, starts Axum on port 3000, and prints:

Ferrik v0.1.0 running in development mode
-> Human Web UI:    http://127.0.0.1:3000
-> JSON API:        http://127.0.0.1:3000/index.json
-> AI Agent Entry:  http://127.0.0.1:3000/ai
-> Agent Manifest:  http://127.0.0.1:3000/.well-known/ferrik-agent.json

Core Architecture

  1. Single-Handler, Triple-Representation (ActionResponse<T>): Every controller action runs domain logic once and renders HTML (compile-time checked Askama templates, Zero-JS), JSON, or AI-Native Markdown (.ai / /ai/* with YAML frontmatter, compact tables, and JSON Schema action affordances).
  2. Multi-Database Persistence (SeaORM): Zero-config SQLite by default, switchable to PostgreSQL or MySQL via DATABASE_URL and Cargo feature flags (db-sqlite, db-postgres, db-mysql), with dialect-agnostic Rust migrations and automatic .ferrik/schema.json introspection.
  3. Deterministic AI Operability: Every CLI command supports --json, maintains .ferrik/manifest.json and .ferrik/schema.json, serves /.well-known/ferrik-agent.json, and embeds a native MCP (Model Context Protocol) server (stdio and /mcp).
  4. Test-First by Default: Ships with ferrik::testing::TestApp (in-memory SQLite per test) and auto-generates test suites for new, model, controller, scaffold, and agent_auth.

CLI Commands

All commands accept --json for structured, machine-readable output without ANSI codes.

# Project creation & development server
ferrik new <app_name> [--db sqlite|postgres|mysql] [--json]
ferrik serve [--port 3000] [--host 127.0.0.1]

# Code generators (alias: `ferrik g`)
ferrik generate scaffold <ModelName> <field:type...> [--skip-tests] [--json]
ferrik generate model <ModelName> <field:type...> [--skip-tests] [--json]
ferrik generate controller <Name> [actions...] [--skip-tests] [--json]
ferrik generate agent_auth [--skip-tests] [--json]

# Database migrations
ferrik db migrate [--json]
ferrik db rollback [--steps N] [--json]

# Introspection, verification & testing
ferrik inspect [--json]
ferrik check [--json]
ferrik test [--coverage] [--json]

# Native MCP server & Agent API keys
ferrik mcp serve
ferrik agent:create-key --name <name> --scopes <scopes> [--json]
ferrik agent:revoke-key <id> [--json]

Application Directory Structure

my_app/
├── .ferrik/                      # Auto-managed AI metadata (DO NOT edit manually)
│   ├── manifest.json             # Registered routes, controllers, .ai actions & MCP tools
│   └── schema.json               # Current DB schema snapshot (updated on db migrate)
├── config/
│   ├── app.toml                  # Server port, environment, MCP & AI discovery flags
│   └── database.toml             # Pool settings and driver configs
├── migration/                    # Isolated SeaORM migration crate for fast incremental builds
│   ├── Cargo.toml
│   └── src/
│       ├── lib.rs
│       ├── main.rs
│       └── mYYYYMMDD_HHMMSS_*.rs
├── public/
│   └── styles.css                # Minimal semantic/classless CSS
├── storage/                      # Local SQLite database files
├── src/
│   ├── main.rs                   # Entrypoint: config, DB pool, migrations, Axum server
│   ├── lib.rs                    # Library exports for integration testing (TestApp)
│   ├── routes.rs                 # Central route registry (.html, .json, .ai, /mcp)
│   ├── controllers/
│   │   ├── mod.rs
│   │   ├── home_controller.rs    # Default root (/), /index.json, /ai, healthcheck
│   │   └── posts_controller.rs
│   ├── models/
│   │   ├── mod.rs
│   │   └── post.rs               # SeaORM Entity + ActiveModel + InputDTO
│   ├── views/
│   │   ├── mod.rs
│   │   └── posts.rs              # Askama #[derive(Template)] structs
│   └── errors.rs                 # Unified error handler rendering HTML, JSON, or .ai
├── templates/
│   ├── layouts/
│   │   └── application.html      # Base HTML5 layout with AI discovery <link> tags
│   ├── shared/
│   │   └── _errors.html          # Validation errors partial
│   ├── home/
│   │   └── index.html
│   └── posts/
│       ├── index.html
│       ├── show.html
│       ├── new.html
│       ├── edit.html
│       └── _form.html
├── tests/                        # Auto-generated test suite
│   ├── home_test.rs
│   ├── models/
│   ├── controllers/
│   └── scaffolds/
├── .env
├── .env.example
├── Cargo.toml
└── README.md

Documentation

License

MIT