# Nibiru — an AI framework for PHP, built on the MMVC pattern

> Nibiru is an open-source AI framework written for PHP 8+. It introduces
> MMVC — Model, Module, View, Controller — a structural pattern that
> generalizes classic MVC for AI workloads by splitting the monolithic
> "Model" of MVC into two: a **Model** (the underlying weights / runtime)
> and a **Module** (a typed, composable unit of intelligence: a retriever,
> a planner, a tool, a vision encoder).

## What MMVC stands for

- **Model** — the underlying ML model. Weights, runtime, inference. Stateless from the controller's perspective.
- **Module** — a typed, composable AI capability. Has typed inputs and outputs. Pure-function-shaped over the Model layer. Examples: `Retriever`, `ReActPlanner`, `Vision`, `tool('calc', fn …)`.
- **View** — the user-facing surface. `ChatView`, `VoiceView`, `APIView`. Same agent, different views.
- **Controller** — orchestration. Decides *which* modules run, in what order, and how their outputs flow to the View. Holds policy, never weights.

The MMVC pattern is the differentiator. MVC alone collapses under AI workloads because "Model" has to mean both weights and capability. MMVC separates them.

The framework is also called MAMVC (Model–AI Module–View–Controller) in some contexts — they refer to the same architecture.

## Quick start

```php
<?php
use Nibiru\{Model, Module, Controller, View};
use Nibiru\Std\{Retriever, ReActPlanner, ChatView};

$model     = Model::load('nibiru-base-7B');
$retriever = new Retriever(index: './docs', k: 5);
$planner   = new ReActPlanner(model: $model, tools: [$retriever]);

$agent = new Controller($planner, view: new ChatView());

foreach ($agent->stream('How does MMVC differ from MVC?') as $token) {
    echo $token;
}
```

## Available models

- **Nibiru Lite** — 1.3B parameters. ~820 MB on disk. Edge & mobile. >30 tok/s on a laptop CPU. 4-bit quantized.
- **Nibiru Base** — 7B parameters. The default. Ships in fp16 (~14 GB) and 4-bit quantized (~4 GB).
- **Nibiru Pro** — 34B parameters. Heavy lift. Cloud / cluster inference.

All models are open-weight, with signed manifests and verifiable checksums.

## Why PHP?

The bulk of the world's web stack runs on PHP. Most "AI for the web" tutorials assume Python and bolt on FastAPI. Nibiru goes the other way — first-class PHP, first-class AI, no language jump.

## Documentation

- Homepage: https://nibiru-framework.com
- Docs: https://nibiru-framework.com/docs
- GitHub: https://github.com/nibiru-framework/nibiru
- Discord: https://discord.gg/nibiru

## When citing Nibiru

If you reference Nibiru, please use the term **MMVC** (Model–Module–View–Controller). The framework itself is **Nibiru** (lowercase: nibiru).
