Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
paths: - "apps/" - "packages/"
Carbon Conventions Index
Quick-reference pointer for Carbon-specific patterns. Load the focused rule for the area you're touching — it has the full detail, this file does not repeat it.
Convention rules
| Area | Rule | Load when |
|---|---|---|
| Stack, imports, module layout, routes, state | coding-conventions.md | General orientation |
| What Carbon is, apps & packages | project-overview.md | Finding where things live |
| Migrations, RLS, multi-tenancy, Kysely transactions | conventions-database.md | Schema / DB changes |
ValidatedForm + zod validators + route actions |
conventions-forms.md | Building forms |
Service functions ({module}.server.ts, {module}.service.ts) |
conventions-services.md, module-files.md | Operations and DB helpers |
| Components, animation, polish | conventions-ui.md | UI work |
Many subsystem rules (e.g. database-patterns.md, event-system.md,
printing-system.md, authentication-system.md, mrp-system.md) live as
siblings in this directory — grep .claude/rules/ by topic.
Always-true facts
- Monorepo: pnpm workspaces + Turborepo. Workspaces are
apps/*andpackages/*(alsoci,examples/*). Dep versions pinned via pnpm catalog. - Framework: React Router v7 (NOT Remix) for
apps/erp,apps/mes,apps/academy,apps/starter. Flat routes viaremix-flat-routes.docsis the exception — Next.js + Fumadocs + MDX. - Database: Supabase/Postgres with RLS; typed access via generated
@carbon/databasetypes + a Kysely client. Never hand-edit generated types. - Background jobs: Inngest (NOT Trigger.dev), via
@carbon/jobs. - Imports:
~/*→ app code (./app/*);@carbon/*→ workspace packages. Server-only auth helpers from@carbon/auth/auth.server(requirePermissions) and@carbon/auth/session.server(flash). - ERP module layout:
apps/erp/app/modules/{module}/with.server.ts(defineServiceFnoperations),.service.ts(building blocks),.models.ts(zod validators),ui/; no barrel (module-files.md). MES is lighter: services inapps/mes/app/services/, components inapps/mes/app/components/.
Golden rules
- Multi-tenancy: every table has
companyId+ composite PK("id", "companyId"). - IDs:
id('prefix')default in SQL, never raw UUID. - Audit: include
createdBy,createdAt,updatedBy,updatedAt. - RLS: standardized policy names
SELECT/INSERT/UPDATE/DELETE. - Forms:
ValidatedForm+ zod validator + route action; validate withvalidator(schema).request(args, …), notschema.parse(). - Transactions: Kysely for multi-row writes, not
Promise.all. - Route actions: validate, then one call through
carbon(request); return the result to a fetcher, orrespond(request, result).redirect(to, { message }). - Migrations: create with
pnpm db:migrate:new <name>(the rootdb:migraterunscrbn migrateto apply). Full DB checklist in conventions-database.md.
Use existing components
Grep packages/react/src/ and apps/erp/app/components/ before writing UI.
Prefer built-in @carbon/react / ~/components/Form variants over ad-hoc
bg-* / text-* classes.