# Strutvane 0.2 documentation > Strutvane is a TypeScript framework that follows Laravel’s flow: npm only, MVC, migrations as the source of truth, and an automatic CRUD API and admin UI. ## Prologue - [Release Notes](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/releases.md): What a Strutvane version promises, the support table, and what is new, deprecated and retired in 0.2, with the replacement for everything retired. - [Versioning & Support](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/versioning.md): How Strutvane's version numbers work, how long each line gets fixes, which branch and npm dist-tag each line uses, how the core packages and add-ons are versioned, and how deprecations work. - [Upgrade Guide](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/upgrade.md): Upgrading an app from Strutvane 0.1 to 0.2. Every breaking change, how likely it is to affect you, what to do, and why it changed. - [Deprecations](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/deprecations.md): Everything deprecated in this line, what replaces it and when it will be removed. - [Contribution Guide](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/contributions.md): Help improve Strutvane: report a bug, fix one, improve these docs, propose a feature, or report a security issue privately, with the right branch, commit format, tests and sign-off for each. ## Getting Started - [Introduction](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/introduction.md): What Strutvane is and who it's for, then the whole first hour in order (create an app, start it, make a table, migrate, and use the screens and API you get). With links to every other page. - [Installation](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/installation.md): Create a Strutvane app with one command. Every question the installer asks and its flag, Recommended or Custom setup, what happens step by step, how to resume with npm run setup, and what each exit code means. - [Docker](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/docker.md): Run your whole app in containers, like Laravel Sail. What runs where, how node strut forwards into the container, the services commands, ports and .env keys, Windows, macOS and Linux notes, and the optional production Dockerfile and dev container. - [Configuration](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/configuration.md): How settings work in a Strutvane app. Secrets and per-machine values go in .env, everything else in typed config/*.ts files, and mistakes are reported all at once when the app starts. Includes every .env key the installer writes. - [Directory Structure](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/structure.md): A guided tour of a new Strutvane app. Which folder holds what, which files depend on your installer answers, which files you edit, which ones Strutvane writes for you, what is committed to git, and where to put new code. - [Your First CRUD in 5 Minutes](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/first-crud.md): Build a complete "Posts" feature (a database table, a secured JSON API, admin screens and a sidebar entry) from one migration and two commands, step by step. - [Frontend](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/frontend.md): How the React UI is served next to your API on one port, where its files live, how to restyle it, how to add your own pages and components, how it talks to the API safely, and how to build it for production. - [Designs](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/designs.md): Pick the look of your admin UI when you create the app (Crisp or Vivid), restyle it with your own brand colour, font and corners, switch to another design later, or take full control by ejecting it. - [Starter Kits](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/starter-kits.md): The kinds of app `npm create strutvane@latest` can set up (a full app with generated admin screens, a full app with a blank React UI, or an API only), with the look, the sign-in screens, the flags for each, and how to change your mind later. - [AI Agents](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/ai-agents.md): Work with AI coding assistants (Claude Code, Cursor, Copilot, Codex) on a Strutvane app: the AGENTS.md the installer writes, docs agents can read (llms.txt, Copy as Markdown), commands with JSON output, errors you can paste, the coming agent-tools package, and how to keep agents safe. - [Deployment](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/deployment.md): Put your app on a real server: build it, set production settings, migrate safely, run it on any Node host or as a Docker image, check health with /up, shut down gracefully, and go through a production checklist before launch. ## Architecture Concepts - [Request Lifecycle](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/lifecycle.md): Follow one request through a Strutvane app, from bootstrap/app.ts to your controller and back, so you know where each piece of your code runs and why. - [Service Container](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/container.md): How Strutvane creates and shares services (the database, the logger, your own classes), how constructor injection works without decorators, and how to swap a service in tests. - [Service Providers](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/providers.md): Service providers are where your app (and every package) plugs itself in. Learn the register-then-boot order, what belongs in each, and how packages add routes, commands and menu entries. - [Facades](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/facades.md): Strutvane's facades are typed static accessors (Log, Cache, DB, Route, Mail, Storage, Http, Queue, Event, Bus, Notification, Hash, Crypt, Url) that resolve from the current app's container, so tests can swap them. How they work, how to fake them, and when to inject instead. - [Helpers](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/helpers.md): The plain, fully typed helper functions you can import anywhere (config, route, now, app, redirect, abort, signed URLs, encrypt and decrypt), how they find the current app, what to do outside a request, and the support helpers coming next (Str, Num, retry, once, Pipeline, Benchmark, Sleep, Timebox, Lottery). - [Contracts](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/contracts.md): The interfaces behind the framework's services (`@strutvane/framework/contracts`), how each is bound to a container token, how to provide your own implementation, and when your code should depend on a contract instead of a concrete class. ## The Basics - [Routing](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/routing.md): Map URLs to controllers in routes/web.ts and routes/api.ts. Single routes, names and typed URLs, groups, middleware and opt-outs, signed links, resource routes, slug binding, 405s and the /up health check, plus fallback, singleton, shallow and spoofed-method routes coming in 0.2, each with a complete example. - [Middleware](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/middleware.md): Middleware is code that runs around your controllers. Use the built-in auth, throttle and csrf middleware, write your own, give it an alias, set up rate limiters, and understand the order things run in. - [CSRF Protection](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/csrf.md): How Strutvane stops other websites from sending requests as your signed-in users, the exact rules, what a 419 means, and every way to adjust the check (app-wide, per route, per group, per controller, per function or by hand) with examples. - [Controllers](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/controllers.md): Group request handling into controller classes. Plain controllers, constructor injection, ResourceController with its hooks (indexConstraints, prepareForStore, prepareForUpdate, visible), custom actions, and every make:controller variant. - [Requests](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/requests.md): Read everything about the current request from one object, ctx: path parameters, the query string, the JSON body, headers, the signed-in user and bound models, plus the 400, 413 and 415 errors you get for bad bodies. - [Session](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/session.md): How Strutvane remembers a signed-in browser between requests with the `strutvane_session` cookie, which drivers store sessions, how long they last, how to read and write session values and flash data, regenerate ids, sign everyone out, and block overlapping requests. - [Validation](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/validation.md): Check every request body before it reaches your database. Form requests with Zod schemas, automatic rules from your migrations, unknown fields refused, and the exact 422 problem+json response with one issue per field. - [Precognition](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/precognition.md): Live form validation that uses your server's own rules. What works today (server 422s mapped to fields, client checks from the metadata), and what 0.2 adds (one Zod schema per table shared by server and browser, and a `Precognition` request that checks database rules like unique without saving). - [Responses](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/responses.md): Everything a controller action can send back. JSON with any status and headers, HTML, 204 No Content, 201 with a Location header, and errors as RFC 9457 problem+json by throwing an HTTP error. - [URL Generation](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/urls.md): Build links to your own routes with the typed `route()` helper and `url`, make signed and expiring links with `url.signedRoute()` and `url.temporarySignedRoute()`, read the current and previous URL, add absolute URLs and query strings, and avoid the mistakes that break links. - [Error Handling](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/errors.md): What happens when your code throws. The developer error page with "Copy as Markdown for AI", the JSON debug member, plain 500s with a reference id in production, which errors are logged, and how to customise it all. - [Logging](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/logging.md): Write log messages from your app, choose where they go (one file, a file per day, the terminal, Slack) from .env, follow them live with log:tail, and keep secrets out of them. ## Digging Deeper - [Strut Console](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/strut-console.md): How `node strut` works (listing, help, typo hints, exit codes, Docker forwarding), and how to write, register and test your own commands with typed arguments and options. - [Broadcasting](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/broadcasting.md): Push changes to open browser tabs as they happen: live-updating tables, notifications that appear without a reload, who's-online lists. How @strutvane/realtime will work, with public, private and presence channels authorised by your policies. - [Cache](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/cache.md): Keep the result of slow work for a while so the next request is fast, with stores you can swap, tags, locks, stale-while-revalidate and per-request memoisation, always separated per team. - [Concurrency](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/concurrency.md): Do several things at the same time: wait for many database or HTTP calls at once with plain promises, move CPU-heavy work to other threads with Concurrency.run(), and finish work after the response with defer(). - [Context](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/context.md): The request context that follows every request and command through each `await` (the current app, the request id, the user and team), how it flows into log lines and, from 0.3, into queued jobs, how to add your own values and hidden values, and what to do in scripts and tests. - [Events](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/events.md): Announce that something happened (a post was published) and let other parts of your app react to it, without the two knowing about each other, in the same request, after the commit, or in the background. - [File Storage](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/storage.md): Save, read, list and delete files on named disks, accept uploads safely, keep each team's files apart, share private files with expiring links, and know what happens when a file is missing, too big or the wrong type. - [HTTP Client](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/http-client.md): Call other servers from your app safely with `safeFetch`, which blocks requests to your private network (SSRF), pins DNS, re-checks redirects, and enforces time and size limits. Every option, every error, and the `Http` client with retries and fakes coming in 0.2. - [Localization](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/localization.md): Translate your app's messages into other languages: message catalogs, placeholders and plurals, picking each request's language, overriding built-in and package messages, finding missing translations, and what users see when a key is missing. - [Mail](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/mail.md): Send email from your app: where mail goes in development, choosing a production mailer, writing mails as classes with React templates, queueing them, sending only after the database commits, failover between providers, and what happens when a mail server is down. - [Maintenance Mode](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/maintenance-mode.md): Take your app offline for a moment with `node strut down`, show visitors a friendly "back soon" answer, keep using it yourself with a secret link, and bring it back with `node strut up`. Every option, what visitors see, a safe deploy routine, and the mistakes to avoid. - [Notifications](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/notifications.md): Tell people when something happens, over mail and the in-app bell at once: write one notification class, choose channels per user, queue it, notify someone without an account, mark notifications read, and handle a channel that fails. - [Optimization](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/optimization.md): Make your app start faster in production with `node strut optimize` and the cache commands (config, routes, events, the application cache, the UI build, generated files, queues, the scheduler, logs and storage). What each one builds or clears, where the caches live, why they're encrypted, when to run them, and what to do when something looks stale. - [Processes](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/processes.md): Run other programs (git, a database dump, an image tool) from your app safely, with no shell in between, time limits, several at once or piped together, and a fake for tests. - [Prompts](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/prompts.md): Ask questions in your own `node strut` commands (text, select, search, confirm), show a spinner, a progress bar and tables, behave sensibly in CI and with no terminal, and test it all with a fake. A preview of the API planned for 0.2. - [Queues](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/queues.md): Move slow work (sending mail, generating reports, calling other services) out of the request into background jobs, with retries, failed-job handling, chains, batches, unique jobs and workers that survive deploys. - [Rate Limiting](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/rate-limiting.md): Limit how often a client may call your routes, per signed-in user or per IP address. The `throttle` middleware, named limiters (api, login, password-reset, aggregate), your own keys, the headers clients see, every way to apply a limit, and how to test it. - [Task Scheduling](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/scheduling.md): Run commands, jobs and small functions on a timetable (every minute, nightly, on weekdays), declared in your code, with one cron entry, no overlapping runs, one server only, and hooks for success and failure. ## Security - [Security Features](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/security.md): Every protection Strutvane turns on by default, how to adjust each one in bootstrap/app.ts, the Strict security profile, the security commands (key:rotate, env:encrypt, session:flush, security:check), and what is already proven versus still being built. - [Authentication](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/authentication.md): Sign people in with a password, an emailed link or a passkey; add two-factor, sessions, API tokens, teams and impersonation; and switch each feature on or off. - [Authorization](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/authorization.md): Decide who may do what with policies. Everything is denied unless a policy allows it, invisible records answer 404 instead of 403, admins pass through before(), and developers get an explanation of every denial in local mode. - [Email Verification](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/email-verification.md): Make sure people own the email address they signed up with: switch verification on, understand the signed link, resend it, require a verified address on routes, and handle expired or edited links. - [Password Reset](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/passwords.md): Let people reset a forgotten password safely, change it from their settings, confirm it before sensitive actions, and choose the password rules and breach checks your app enforces. - [Two-Factor Authentication](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/two-factor.md): Adding a second sign-in step with an authenticator app, recovery codes or a passkey. - [API Tokens](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/api-tokens.md): Give scripts, mobile apps and other servers their own personal access tokens with abilities and an expiry, check abilities in your routes, and handle expired, revoked and mistyped tokens. - [Multi-tenancy](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/tenancy.md): Run one app for many customer companies (teams) and keep each team's data apart: turning teams on, how a request picks its team, the two layers of protection, shared tables, jobs, tests and the differences between MySQL, PostgreSQL and SQLite. - [Audit](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/audit.md): Keep a permanent record of who did what, when and to which record: the security events Strutvane writes for you, recording your own actions with recordAudit(), field-level changes with secrets redacted, and reading the log back. - [Encryption](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/encryption.md): Encrypt values you need to read back later (API secrets, notes, tokens for other services) with encrypt() and decrypt(), bind each value to a purpose, and rotate APP_KEY without breaking anything. - [Hashing](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/hashing.md): Store passwords safely with scrypt, check them, upgrade old hashes on the next sign-in, import bcrypt hashes from another app, and tune the cost for your servers. ## Database - [Database: Getting Started](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/database.md): Connect your app to MySQL, MariaDB, PostgreSQL or SQLite, on your own server (XAMPP, WAMP, MAMP, Laragon, Postgres.app, a local install, the cloud) or in Docker, run safe raw SQL, watch every query, and know which database commands exist. - [Query Builder](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/queries.md): Every method of Strutvane's typed query builder in one place, the SQL each one produces on MySQL, PostgreSQL and SQLite, safe raw SQL, debugging, and what's coming (joins, aggregates, chunking). - [Pagination](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/pagination.md): Split long lists into pages: numbered and cursor pages in your queries, the generated API's ?page and ?perPage, the meta block clients read, the admin screens, and how to make your own endpoints page the same way. - [Migrations](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/migrations.md): Create migration files with one command, describe your tables with the Schema builder, run, check and undo migrations, and see exactly what Strutvane generates from them (types, API, screens). - [Seeding](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/seeding.md): Fill your database with starting data (roles, the first admin, lists of countries) and with realistic fake data while you build. Create seeders, order them, run one on its own, and know exactly when Strutvane runs them for you. - [Redis](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/redis.md): Use Redis or Valkey for your app's cache, queues, locks, sessions and rate limits: when you need it, installing @strutvane/redis, connecting with REDIS_URL, running it with Docker or on your own server, and what happens when it goes down. ## ORM - [ORM: Getting Started](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm.md): Read, create, update and delete database rows with model classes whose columns come straight from your migrations, and learn the conventions, settings and safety switches behind them. - [Querying](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-querying.md): Find exactly the rows you need with typed conditions, grouping, ordering, limits, request-driven search and filters, and safe raw SQL. - [Relationships](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-relationships.md): Connect models (a post's author, a user's posts, a post's tags) and load them in a few queries instead of hundreds. - [Scopes](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-scopes.md): Give common conditions a name (Post.query().published()) and add conditions that apply to every query of a model automatically. - [Casts & Accessors](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-casts.md): How database values become proper TypeScript values (booleans, dates, exact decimals, typed JSON), and how to add your own conversions and computed properties. - [Events & Observers](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-events.md): Run your own code when a model is created, updated, deleted or restored: model hooks, observer classes, the exact order events fire in, events inside transactions, and how to skip them. - [Mass Assignment](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-mass-assignment.md): Why create() and fill() only accept the columns you list in fillable, and how to set everything else safely. - [Pagination](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-pagination.md): Split long lists into pages: numbered pages with a total, or fast cursor pages for infinite scrolling and APIs. - [Soft Deletes](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-soft-deletes.md): Hide deleted rows instead of erasing them, so they can be restored, and erase them for good when you really mean it. - [Slugs](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-slugs.md): Readable, unique URL names like hello-world, generated from a title when a row is created, safe with accents, races and teams. - [Transactions](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-transactions.md): Group several database changes so they all succeed or all fail together, with nested transactions as savepoints. - [Tenancy](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-tenancy.md): Keep each customer company's data apart: every query is limited to the active tenant, checked again before the SQL runs, and refused when no tenant is set. - [Collections](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-collections.md): Work with lists of models: they're plain, typed JavaScript arrays, so map, filter, group and chunk them with the array methods you already know. - [Factories](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-factories.md): Make realistic fake records for tests and seeders: what the generated factory file gives you today, and the full factory API (counts, states, sequences, relations, recycle) arriving in 0.2. - [API Resources](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-resources.md): Decide exactly what a model looks like in your JSON responses: what toJSON() and hidden give you today, how to write a typed transformer now, and the API resources arriving in 0.2. - [Serialization](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/orm-serialization.md): Turn models into JSON for your API: what toJSON() returns, hiding columns, dates and decimals, loaded relations and counts, the typed JsonOf and PostJson shapes, and what's coming (visible, appends). ## Auto CRUD & UI - [Resources](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/crud.md): Every table with a model gets a secured CRUD API and admin screens after `node strut migrate`. What you get, the endpoints and their answers, the screens and conveniences, who may see what, which tables never get one, and how to opt out or take over. - [The Sidebar](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/crud-sidebar.md): How generated resources and package pages appear in the admin sidebar: who sees each entry, how entries are grouped and ordered, and how to change a label, icon, group, order or badge, hide an entry, or add your own page. - [Customising Screens](https://vishwajit-vm.github.io/strutvane-docs/docs/0.2.x/crud-customising.md): Change the generated list, form, filters, labels, sort and sidebar entry of a resource in its own `resources/ui/