# Brick > Brick is a TypeScript backend framework for Bun. Define services, actions, resources, and MCP tools with typed schemas. Follow the page links for focused context, or read [all documentation](https://www.brickkit.dev/llms-full.txt). ## Brick-TS Framework - [Why Brick Was Built](https://www.brickkit.dev/docs/why-brick.md): Why Brick exists, the architectural problems it solves, and the design principles behind the framework. - [Overview & Architecture](https://www.brickkit.dev/docs/index.md): Learn the mental model, core design principles, and architecture of Brick-TS. - [Quickstart](https://www.brickkit.dev/docs/quickstart.md): Build and run an in-memory SQLite CRUD service in less than 5 minutes. - [Tutorial: Building a REST API](https://www.brickkit.dev/docs/tutorial.md): Build a complete, production-ready REST API end to end with database models, CRUD, access control, and custom actions. - [For AI agents](https://www.brickkit.dev/docs/for-ai-agents.md): Give Cursor, Claude Code, and Copilot Brick documentation, project instructions, and MCP tools - [Services and Actions](https://www.brickkit.dev/docs/services-and-actions.md): Define modular backend services and typed actions with runtime schema validation. - [Execution Context & Services](https://www.brickkit.dev/docs/context.md): Resolve request context, inject databases and users, and isolate in-process service calls. - [Resources and CRUD](https://www.brickkit.dev/docs/resources.md): Expose database tables via CRUD resources with field-level access, filtering, and security policies. - [Access Control and Policies](https://www.brickkit.dev/docs/access-control.md): Secure actions and CRUD operations with role-based authorization and row scoping. - [Validation and Errors](https://www.brickkit.dev/docs/validation-and-errors.md): Validate inputs and outputs with TypeBox schemas and throw structured errors with HTTP statuses. - [Lifecycle Hooks](https://www.brickkit.dev/docs/hooks.md): Intercept CRUD operations before and after writes to validate, transform, and log data. - [Primary Keys and Identifiers](https://www.brickkit.dev/docs/primary-keys.md): Configure custom primary keys, UUIDs, and auto-minted column IDs. - [Relational Data Modeling & Joins](https://www.brickkit.dev/docs/relations.md): Model one-to-many, many-to-many, and singleton relationships with explicit Drizzle queries. - [Typed Client SDK](https://www.brickkit.dev/docs/typed-client.md): Call backend actions through a typed HTTP client with automatically generated browser contracts. - [TanStack Query](https://www.brickkit.dev/docs/tanstack-query.md): Use typed query options, mutation options, and cache keys with Brick's HTTP client. - [AI Tools and Model Context Protocol (MCP)](https://www.brickkit.dev/docs/tools-and-mcp.md): Expose backend actions to AI agents via Model Context Protocol (MCP) and JSON-RPC. - [OpenAPI 3.1 & Interactive Documentation](https://www.brickkit.dev/docs/openapi.md): Generate OpenAPI 3.1 specifications and serve interactive Scalar and Swagger docs automatically. - [Zero-Codegen Type Inference](https://www.brickkit.dev/docs/type-inference.md): Infer static TypeScript types directly from TypeBox schemas and Drizzle models without build steps. - [Database Management & Migrations](https://www.brickkit.dev/docs/database.md): Configure SQLite and PostgreSQL databases, development sync, and production migrations. ## brick CLI - [brick CLI Overview](https://www.brickkit.dev/docs/brick-cli.md): Command-line developer and build tooling for Brick-TS applications. - [Development & Production Server](https://www.brickkit.dev/docs/brick-cli/dev-and-start.md): Run development servers with live reload and start production instances. - [Build & Compilation](https://www.brickkit.dev/docs/brick-cli/build.md): Compile default-exported Brick applications into standalone Bun server bundles. - [Code & Spec Generators](https://www.brickkit.dev/docs/brick-cli/gen.md): Generate OpenAPI 3.1 specifications and typed client contracts from application code. - [Architecture Introspection](https://www.brickkit.dev/docs/brick-cli/info.md): Export and inspect the runtime architecture JSON schema of your application. ## Plugins - [Plugins Overview](https://www.brickkit.dev/docs/plugins.md): Extend services and resources with modular plugins, typed APIs, and scoped routes. - [Built-in Capabilities](https://www.brickkit.dev/docs/plugins/built-in.md): Explore built-in framework plugins for CRUD, request logging, and interactive documentation. - [Audit Trail Plugin Recipe](https://www.brickkit.dev/docs/plugins/audit.md): Record immutable audit trails for resource mutations using CRUD lifecycle hooks. - [Comments Plugin Pattern](https://www.brickkit.dev/docs/plugins/comments.md): Attach discussion threads to any parent resource using a canonical comments schema. - [Authoring Plugins](https://www.brickkit.dev/docs/plugins/build-plugin.md): Create custom service and resource plugins with scoped routes and typed APIs. - [Plugin Best Practices](https://www.brickkit.dev/docs/plugins/best-practices.md): Architectural guidelines for building maintainable, safe, and isolated plugins. ## Reference - [API Cheatsheet](https://www.brickkit.dev/docs/reference/cheatsheet.md): Quick reference of all public functions, classes, and types in Brick-TS. - [Error Catalog & Troubleshooting](https://www.brickkit.dev/docs/reference/errors.md): Catalog of error codes, HTTP statuses, response envelopes, and troubleshooting advice. - [Context API Reference](https://www.brickkit.dev/docs/reference/context-api.md): Detailed specification of BaseContext, ActionContext, and context lifecycle guarantees. - [Server & Environment Configuration](https://www.brickkit.dev/docs/reference/configuration.md): Complete configuration reference for brick() server options, environment variables, and secrets. ## API Reference - [API Reference](https://www.brickkit.dev/docs/api-reference.md): Every function, class, and type the Brick packages export, generated from the JSDoc in their source. - [@brickkit/core](https://www.brickkit.dev/docs/api-reference/core.md): Services, actions, tools, resources, databases, secrets, the HTTP runtime, and the typed contract of a Brick application. - [@brickkit/core/client](https://www.brickkit.dev/docs/api-reference/core-client.md): The typed HTTP client a frontend uses to call a Brick application, inferred from its contract. - [@brickkit/core/tanstack-query](https://www.brickkit.dev/docs/api-reference/core-tanstack-query.md): TanStack Query options and keys for the typed client's actions. - [@brickkit/core/pg](https://www.brickkit.dev/docs/api-reference/core-pg.md): Postgres databases for Brick services, with Drizzle's table builders. - [@brickkit/cli](https://www.brickkit.dev/docs/api-reference/cli.md): The brick command's building blocks: the dev and production servers, contract generation, and the OpenAPI pages. - [@brickkit/cli/compiler](https://www.brickkit.dev/docs/api-reference/cli-compiler.md): Compile and bind a Brick application's routes ahead of time. - [@brickkit/cli/vite](https://www.brickkit.dev/docs/api-reference/cli-vite.md): The Vite plugin that generates the typed client contract and serves the dashboard. - [@brickkit/cli/dev-reporter](https://www.brickkit.dev/docs/api-reference/cli-dev-reporter.md): Report a worker process's requests to a running dev dashboard. - [@brickkit/crud](https://www.brickkit.dev/docs/api-reference/crud.md): CRUD actions for a resource, with access rules, filters, and hooks. ## Additional documentation - [Related Tables](https://www.brickkit.dev/docs/child-tables.md): Modeling parent-child relationships and joins with Drizzle ORM. - [Type Inference Without Codegen](https://www.brickkit.dev/docs/codegen.md): Static types from schemas and tables with no build step. - [Schema Management](https://www.brickkit.dev/docs/migrations.md): Creating tables in development and managing production migrations. - [Resource Lifecycle](https://www.brickkit.dev/docs/resource-lifecycle.md): Lifecycle phases, preparation, and hooks for resources and services. - [Singleton Records](https://www.brickkit.dev/docs/singletons.md): Model singleton constraints and single-row tables in the database. - [AI Tools and Model Context Protocol](https://www.brickkit.dev/docs/tools.md): Exposing actions to AI agents via Model Context Protocol (MCP). - [Input and Output Validation](https://www.brickkit.dev/docs/validate-hook.md): Validating actions with TypeBox schemas and error helpers. - [Generators](https://www.brickkit.dev/docs/brick-cli/generate.md): Generate OpenAPI specifications and typed browser client contracts. - [Database Migrations](https://www.brickkit.dev/docs/brick-cli/migrate.md): Database configuration in development and caller-owned PostgreSQL migrations. - [Architecture Export](https://www.brickkit.dev/docs/brick-cli/schema-dump.md): Export and inspect the service mesh architecture with brick info.