MBS Mohammed Baobaid
All projects
Project
Public release Open Source Software Created 20 May 2026

ModelMind AI Chat Package

A reusable Laravel package that installs a secure, model-aware AI chat assistant into any application.

Created 20 May 2026, ModelMind is my reusable Laravel AI chat package published as mbs047/model-mind. It gives any Laravel application a polished Blade and Tailwind chat modal, OpenAI Responses API integration, persisted chat history, safe Eloquent model context, route action buttons, learning memory, multilingual answers, configurable sessions, publishable assets, and documentation designed for real package adoption.

Laravel 11-13 PHP 8.3+ Blade Tailwind CSS Eloquent OpenAI Responses API Composer Package Orchestra Testbench PHPUnit GitHub Actions Packagist
Narrated walkthrough

This audio is not a word-for-word copy of the case below. You can read the written case while listening to me explain the project in more detail.

0:00 / 0:00
Speed
ModelMind AI Chat Package project preview
mbs047/model-mind Package
v1.0.9 Latest release
11-13 Laravel support

Role

Package author, Laravel product engineer, open-source maintainer, and documentation writer

Outcome

I turned the original AI assistant idea into a Composer-ready package with Laravel auto-discovery, install commands, configuration, one-file migrations, tests, GitHub templates, release notes, Packagist metadata, a Market Lane Store demo, and enough extension points for developers to safely install the assistant inside very different applications.

The Challenge

The hard part was not only adding an AI chat box. The package needed to be safe enough for real Laravel applications, flexible enough to install in unrelated projects, easy enough for a developer to start with one Blade directive, and advanced enough to understand configured models, return approved links, remember useful knowledge, reset sessions, support multiple languages, and let teams replace the entire UI without forking the package.

The Approach

I designed ModelMind as a Laravel-native package instead of an app-specific feature. The service provider registers config, routes, views, migrations, commands, and Blade directives. A context builder turns explicitly enabled Eloquent models into controlled prompt context. A route action registry converts approved model records into safe Laravel route buttons. A learning repository stores useful answers and manual knowledge. The UI layer is publishable and can also be swapped through config. The docs are split into focused files so installation, models, themes, assets, routes, learning, security, and advanced examples are easy to maintain.

How it works

I turned an app feature into a reusable Laravel package

ModelMind started from a practical product need: an application should be able to ask questions about its own safe data without every project rebuilding the same AI chat modal, controller, prompt, database tables, and security filters. I moved that idea into a package so installation becomes a Laravel workflow instead of a copy-paste feature.

The package is published as mbs047/model-mind, uses Laravel package auto-discovery, and gives developers a first path that feels familiar: composer require, php artisan model-mind:install, php artisan migrate, then add @modelMind or the separate @modelMindStyles, @modelMindModal, and @modelMindScripts directives to a Blade layout.

ModelMind package cover artwork for a Laravel AI assistant
ModelMind cover artwork showing the package brand and core promise: secure model-aware chat that can ask questions and take approved actions.

The package stays configuration-first

I wanted the assistant to be advanced without forcing developers to touch package internals. Almost every important behavior is configurable from config/model-mind.php or environment variables: the assistant name, MBS brand mark, subtitle, launcher label, placeholder, initial message, fallback answer, tone, language behavior, OpenAI model, organization, timeout, route prefix, table prefix, session duration, retrieval limits, UI position, default questions, and public asset mode.

That matters because reusable packages live inside other teams' applications. A store may want the widget at bottom-right, an admin panel may need center-right, and a dense dashboard may want a smaller width or a custom placeholder. ModelMind treats those as first-class settings rather than hardcoded design decisions.

Model awareness is explicit and safe by default

The assistant does not automatically read the entire application. Developers must enable each model in the models config array. For each model they can define a label, description, columns, include and exclude lists, relations, row limits, sorting, and route actions.

When columns is set to auto, ModelMind inspects the model but still filters risky fields. The security layer blocks common sensitive names such as password, remember_token, api_token, secret, recovery codes, private keys, OTP fields, card data, bank fields, salary fields, encrypted casts, hashed casts, and any hidden values the model already protects. The result is a controlled assistant context, not a raw database dump.

The trait lets models customize their own AI shape

Config is useful, but larger Laravel apps often need behavior to live beside the model. ModelMind includes the HasModelMindContext trait so an Eloquent model can define methods such as modelMindLabel(), modelMindDescription(), modelMindContextColumns(), modelMindHiddenColumns(), modelMindContextRelations(), modelMindRouteActions(), and modelMindContextQuery().

That makes the package scalable. A product model can expose public catalog fields and storefront routes. An order model can scope the query to the current customer or hide operational notes. A content model can expose only published records. The package gives the application a central config, but it also lets each model own the details when that is the cleaner boundary.

The chat UI is ready by default but replaceable by design

The default modal is a polished Blade and Tailwind-friendly widget with light, dark, and auto theme support. It has a launcher, header, configured brand mark, initial assistant message, default question buttons, message history, input composer, send button, helpful and not helpful feedback states, route action buttons, and responsive positioning.

The professional part is that the default UI is not a trap. Developers can publish the Blade views, publish public CSS and JavaScript assets, or point views.modal, views.styles, and views.scripts to a completely new design. That means a team can start with @modelMind today and later ship a branded modal without editing vendor files.

Route actions turn answers into approved application links

A useful assistant should not only answer; it should help the user continue. ModelMind supports safe named-route actions. The developer configures approved route names and parameter mappings, for example a product action that maps products.show with ['product' => 'id'].

The package then creates buttons only from those approved definitions. It can use a static label, a label_column, or a label_template such as View {name}. This keeps links professional and safe: the AI cannot invent arbitrary URLs, but it can offer useful actions when the answer mentions configured records.

Multilingual behavior was treated as a real product requirement

ModelMind is designed for visitors who may not ask in the same language used by the database. The assistant has language instructions that answer in the visitor's latest language, while the retrieval and route-action layers still work against the configured application data.

This became important in the Market Lane Store demo. A visitor can ask in Arabic about products whose names and descriptions are stored in English, and ModelMind can still recover the configured product route actions when the answer mentions the relevant records. The package supports multilingual conversation without requiring every database column to be translated first.

Memory is useful, bounded, and configurable

The package stores sessions and messages so the assistant does not forget the conversation after every request. It also supports browser history restoration, a recent-message prompt window, a browser-message display limit, message character limits, and MODEL_MIND_SESSION_LIFETIME_MINUTES so stale conversations can be reset after a chosen period.

For learning, ModelMind can remember assistant answers, liked answers, and manually fed texts. The learning system has minimum character limits, context limits, source metadata, and blocked patterns for secrets such as API keys, passwords, tokens, and private keys. That gives the assistant continuity without turning every chat message into uncontrolled permanent knowledge.

Performance work focused on reducing the slow path

AI features can feel slow when every request rebuilds the same context and sends too much text to the provider. ModelMind keeps the default provider settings lean, uses a small default model option, sets connect and request timeouts, limits output tokens, caches application context, limits model rows, caps context characters, and adds question-aware retrieval so relevant records can be fetched without flooding the prompt with every configured row.

The package also includes model-mind:inspect-context and model-mind:clear-context. Those commands help developers see exactly what the assistant can read and clear cached context after changing configuration, routes, or data.

The database layer is package-owned and configurable

ModelMind stores its own sessions, messages, feedback, and learned knowledge. I consolidated the package tables into a single migration for fresh installs and added a configurable table prefix through MODEL_MIND_TABLE_PREFIX.

That detail matters in professional packages. Some applications want all package tables grouped with a prefix. Others need to avoid naming conflicts with existing tables. By making the prefix configurable, ModelMind can fit into more database policies without requiring custom migration edits.

The documentation was split into feature guides

The README is intentionally a starting guide: install, publish assets, configure OpenAI, render the Blade widget, enable a model, inspect context, and ask questions. The deeper documentation is split by feature so developers can jump directly to what they need.

The docs include guides for installation, Blade rendering, themes, public assets, model configuration, custom modal design, multilingual answers, retrieval, route actions, default questions, sessions, security, learning memory, feedback, table prefixes, provider settings, performance, testing, and complete simple and advanced examples. This makes the package feel closer to established Laravel ecosystem packages instead of a one-off repository.

The GitHub side was prepared for real open-source maintenance

I did not stop at source code. The repository includes a changelog, MIT license, contribution guide, security policy, issue templates, pull request template, funding metadata for sponsorship, CI workflow, Dependabot configuration, and PHPUnit tests through Orchestra Testbench.

That is part of the quality bar I wanted for ModelMind. A reusable package needs installation confidence, a clear contribution path, visible releases, a safe place to report vulnerabilities, and tests that prove the package can boot, publish, render, configure models, return route actions, restore sessions, learn from feedback, and handle multilingual answers.

The Market Lane Store demo proves the package in context

The demo is installed in Market Lane Store, a sample storefront at https://mbs-sample.on-forge.com/ that showcases MBS packages. It gives ModelMind a real product catalog context, storefront routes, product detail buttons, and a UI surface where the modal can be tested like a visitor would use it.

That demo helped shape several improvements: configurable widget positions, dynamic route labels, multilingual route recovery, faster retrieval, default questions, session expiry, and public asset publishing. Instead of documenting imaginary use cases, the package was refined against a real storefront scenario.

What this project shows

ModelMind shows how I think about professional Laravel packages. I care about developer ergonomics, but not at the expense of security. I care about a polished default UI, but not at the expense of customization. I care about AI usefulness, but not at the expense of letting the model invent data, expose secrets, or generate unsafe links.

The result is a package that feels small to install and large in capability: one directive can render the assistant, but the system behind it includes safe Eloquent context, model traits, route actions, learning memory, feedback, multilingual behavior, configurable sessions, public assets, custom designs, tests, release notes, and a public demo.

Results

  • Published the package as `mbs047/model-mind` with MIT license metadata, Laravel auto-discovery, Packagist compatibility, and a documented install path
  • Released the first version series through `v1.0.9`, moving from a basic chat modal to a configurable assistant with route actions, learning memory, assets, docs, multilingual support, and session controls
  • Built a secure model context layer that only reads models explicitly enabled in config and filters sensitive fields before the assistant can see them
  • Added the `HasModelMindContext` trait so application models can own their assistant label, description, columns, hidden fields, relations, route actions, and query scope
  • Added dynamic named-route actions so answers can include buttons such as `View Samsung Galaxy S24 Ultra` instead of repeating a generic `View product` label
  • Added multilingual route recovery so Arabic or other-language answers can still produce approved route buttons when records are mentioned naturally
  • Added learning memory from assistant answers, liked answers, and manually fed texts while blocking common sensitive secrets from being learned
  • Added configurable default questions and session lifetime so the package can feel guided in simple stores and reset stale conversations after a chosen duration
  • Added public asset publishing and publishable views so teams can either use the default Tailwind design or replace the modal with their own theme
  • Created a Market Lane Store demo where visitors can test ModelMind against a product catalog and see the package working inside a real Laravel storefront
  • Prepared the GitHub side with issue templates, pull request template, funding metadata, CI workflow, Dependabot configuration, contribution docs, and a package test suite

Key features

01 Drop-in Blade directives: `@modelMind`, `@modelMindModal`, `@modelMindStyles`, and `@modelMindScripts`
02 Tailwind-friendly default modal with configurable light, dark, and auto themes
03 Configurable launcher position, width, offsets, z-index, labels, subtitles, placeholders, brand mark, and default questions
04 Publishable Blade views for replacing the modal, styles, or scripts with a custom design
05 Public asset publishing through a dedicated package asset command and install option
06 Explicit Eloquent model registry where only enabled models are exposed to the assistant
07 Auto-discovered columns with blocked sensitive columns, blocked patterns, hidden casts, `$hidden`, and `$visible` awareness
08 `HasModelMindContext` trait for model-level labels, descriptions, columns, relations, routes, and query scoping
09 Question-aware retrieval so the assistant can find relevant enabled records outside the static context window
10 Safe named-route action buttons with `label_column`, `label_template`, approved route names, and mapped parameters
11 Multilingual answers and multilingual route action recovery for apps whose database content is stored in one language
12 Persisted sessions, browser history restore, configurable session expiry, messages, feedback, learned knowledge, and fed texts
13 Configurable table prefix so package tables can match the host application naming policy
14 OpenAI credentials, organization, model, timeout, token, reasoning, and response storage options
15 Professional GitHub project setup with issue templates, pull request template, funding file, CI, docs, changelog, and tests

Tech stack

Laravel 11-13 PHP 8.3+ Blade Tailwind CSS Eloquent OpenAI Responses API Composer Package Orchestra Testbench PHPUnit GitHub Actions Packagist
Project links

Interested in similar work?

I build systems like this for teams that need reliable engineering, clean interfaces, and measurable outcomes.