MCPcopy Index your code
hub / github.com/crbnos/carbon

github.com/crbnos/carbon @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
14,088 symbols 59,367 edges 3,778 files 277 documented · 2%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Carbon Logo

The open core for manufacturing






<a href="https://discord.gg/yGUJWhNqzy">Discord</a>
·
<a href="https://carbon.ms">Website</a>
·
<a href="https://docs.carbon.ms">Documentation</a>

Supabase Typescript React

ERP Screenshot

MES Screenshot

Does the world need another ERP?

We built Carbon after years of building end-to-end manufacturing systems with off-the-shelf solutions. We realized that:

  • Modern, API-first tooling didn't exist
  • Vendor lock-in bordered on extortion
  • There is no "perfect ERP" because each company is unique

We built Carbon to solve these problems ☝️

Architecture

Carbon is designed to make it easy for you to extend the platform by building your own apps through our API. We provide some examples to get you started in the examples folder.

Carbon Functionality

Carbon Architecture

Features:

  • [x] ERP
  • [x] MES
  • [x] QMS
  • [x] Custom Fields
  • [x] Nested BoM
  • [x] Traceability
  • [x] MRP
  • [x] Configurator
  • [x] MCP Client/Server
  • [x] API
  • [x] Webhooks
  • [x] Accounting
  • [ ] Capacity Planning
  • [ ] Simulation
  • [ ] Full Roadmap

Technical highlights:

  • [x] Unified auth and permissions across apps
  • [x] Full-stack type safety (Database → UI)
  • [x] Realtime database subscriptions
  • [x] Attribute-based access control (ABAC)
  • [x] Role-based access control (Customer, Supplier, Employee)
  • [x] Row-level security (RLS)
  • [x] Composable user groups
  • [x] Dependency graph for operations
  • [x] Third-party integrations

Techstack

Codebase

The monorepo follows the Turborepo convention of grouping packages into one of two folders.

  1. /apps for applications
  2. /packages for shared code

/apps

Package Name Description How to run
erp ERP Application pnpm dev (boots stack + ERP via crbn up picker)
mes MES pnpm dev (select MES in picker, or both)
academy Academy pnpm dev:academy
starter Starter pnpm dev:starter

pnpm dev runs the per-worktree dev CLI (crbn up). ERP and MES are first-class — the CLI boots the docker stack, applies migrations, regenerates types/swagger, and spawns the selected apps behind portless. Academy and starter are standalone Turborepo entries.

/packages

Package Name Description
@carbon/database Database schema, migrations and types
@carbon/documents Transactional PDFs and email templates
@carbon/ee Integration definitions and configurations
@carbon/config Shared configuration (vitest, tsconfig, tailwind) across apps and packages
@carbon/jobs Background jobs and workers
@carbon/logger Shared logger used across apps
@carbon/react Shared web-based UI components
@carbon/kv Redis cache client
@carbon/lib Third-party client libraries (slack, resend)
@carbon/stripe Stripe integration
@carbon/utils Shared utility functions used across apps and packages

Development

Setup

  1. Clone the repo into a public GitHub repository (or fork https://github.com/crbnos/carbon/fork). If want to make the repo private, you should acquire a commercial license to comply with the AGPL license.

sh git clone https://github.com/crbnos/carbon.git

  1. Go to the project folder

sh cd carbon

Make sure that you have Docker installed on your system since this monorepo uses the Docker for local development.

In addition you must configure the following external services:

Service Purpose URL
Posthog Product analytics platform https://us.posthog.com/signup
Stripe Payments service https://dashboard.stripe.com/login
Resend Email service https://resend.com

Posthog has a free tier which should be plenty to support local development. If you're self hosting and you don't want to use Posthog, it's pretty easy to remove the analytics.

Installation

First download and initialize the repository dependencies.

This repo uses pnpm as its package manager. Enable Corepack so the correct pnpm version (pinned via packageManager in package.json) is used automatically:

$ corepack enable    # one-time: activates pnpm shim from packageManager field

Then install dependencies:

$ nvm use            # use node v22
$ pnpm install       # install dependencies

The dev stack (Postgres, GoTrue, Kong, Storage, Inngest, Inbucket, Studio, Realtime) is booted later by crbn up — see Local dev CLI below. There is no separate "start the database" step.

Local dev CLI (crbn)

crbn is a small CLI at packages/dev/bin/crbn that wraps two things:

  • Git worktrees — every feature branch can live in its own checkout dir, so you can switch branches without stashing.
  • Per-worktree docker compose stack — each worktree gets its own Postgres / Supabase services on dynamic ports, isolated under carbon-<slug> compose project. Routing is handled by portless (a local HTTPS reverse proxy that serves *.dev hostnames on :443 with locally-trusted certs — installed automatically on first crbn up).

Windows users: the dev CLI (crbn, setup.sh) is POSIX-only and expects WSL or Git Bash. Native cmd.exe / PowerShell shells are not supported. From a WSL/Git Bash prompt, the standard flow (./setup.sh, pnpm dev, crbn checkout …) works the same as on macOS/Linux.

Run setup.sh once to put crbn on your $PATH and install the crbn shell function (so crbn checkout can change cwd):

$ ./setup.sh                   # writes a sentinel block to ~/.zshrc or ~/.bashrc
$ source ~/.zshrc              # or open a new shell
$ crbn                         # shows commands

Common flows:

$ crbn checkout sid/cool-thing       # cd into worktree (creates if missing,
                                     # auto-fetches from origin if needed)
$ crbn checkout -b feat/new-thing    # new branch off origin/main + worktree
$ crbn checkout sid/cool-thing --up  # …and boot the stack inside it
$ crbn checkout 760                  # fetch GitHub PR #760 into a `pr-760`
                                     # branch + worktree (fork PRs work too)
$ crbn copy                          # re-sync .env from main checkout
$ crbn up | down | reset | status    # per-worktree compose stack
$ crbn new | list | remove           # interactive worktree management

crbn up flags:

  • --no-migrate — skip supabase migration up (use when schema is already current and you just want to re-boot containers fast)
  • --no-regen — skip regenerating packages/database/src/types.ts + swagger-docs-schema.ts (auto-skipped when --no-migrate is set, since no schema change implies no type drift)

Files synced by crbn copy are listed under package.json#crbn.copy (defaults to [".env"]). To uninstall the rc block: ./setup.sh --uninstall.

Create an .env file and copy the contents of .env.example file into it

$ cp ./.env.example ./.env
  1. Social Sign In: Signing in requires you to setup one of two methods:

  2. Email requires a Resend API key (you'll set this up later on)

  3. Sign-in with Google requires a Google auth client with these variables. See the Supabase docs for instructions on how to set this up:
  4. Set Authorized JavaScript origins to https://api.carbon.dev
  5. Set Authorized redirect URIs to https://api.carbon.dev/auth/v1/callback
  6. About the two API URLs you'll see: each worktree has its own scoped Supabase URL (https://<worktree>.api.dev) for app traffic, and there is one stable alias https://api.carbon.dev registered on whichever worktree is currently up. The stable alias exists only so OAuth callbacks have a single registered redirect URI — one Google Console entry covers every worktree. Day-to-day, your app talks to its worktree-scoped URL; only the OAuth callback hits the stable alias.
  7. You should set environment variables like the following.
  8. SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID="******.apps.googleusercontent.com"
  9. SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_SECRET="GOCSPX-****************"

  10. Supabase: Backend services run inside the per-worktree docker stack — crbn up boots them and writes everything you need into .env.local automatically:

  11. SUPABASE_URL — portless alias (e.g. https://local-dev.api.dev)

  12. SUPABASE_ANON_KEY, SUPABASE_SERVICE_ROLE_KEY — keys minted per-worktree from a random SUPABASE_JWT_SECRET
  13. SUPABASE_DB_URL — direct Postgres URL on a dynamic port

.env.local is generated; do not commit it or hand-edit values that came from crbn up (they are re-derived on each boot). Put genuine secrets (OAuth client IDs, Stripe keys, Resend) in .env only.

Run crbn status at any time to see the live port assignment and the URLs portless is serving.

  1. Redis (Caching): No setup needed for local dev — crbn up boots a shared Redis container and writes REDIS_URL into .env.local automatically (each worktree gets its own logical Redis DB). For self-hosted production, set REDIS_URL to any Redis-compatible endpoint (Upstash, AWS ElastiCache, etc.) in your prod environment.

  2. Posthog (Analytics): In Posthog go to https://[region].posthog.com/project/[project-id]/settings/project-details to find your Project ID and Project API key:

  3. POSTHOG_API_HOST=[https://[region].posthog.com]

  4. POSTHOG_PROJECT_PUBLIC_KEY=[Project API Key starting 'phc*']

  5. Stripe (Payment service) - Create a stripe account, add a STRIPE_SECRET_KEY from the Stripe Settings > Developers interface

  6. STRIPE_SECRET_KEY="sk_test_*************"

  7. Resend (Email service) - Create a Resend account and configure:

  8. RESEND_API_KEY="re_**********"

  9. RESEND_DOMAIN="carbon.ms" (or your domain, no trailing slashes or protocols)
  10. RESEND_AUDIENCE_ID="*****" (Optional - required for contact management in packages/jobs)

Resend is used for transactional emails (user invitations, email verification, onboarding). All three variables are stored in packages/auth/src/config/env.ts.

Finally, boot the stack and the apps:

$ pnpm dev                # equivalent to `crbn up` — picker lets you choose ERP/MES

crbn up prints a summary box with the live URLs once the stack is healthy. Defaults look like:

Surface URL
ERP https://<worktree>.erp.dev
MES https://<worktree>.mes.dev
Supabase API https://<worktree>.api.dev

Extension points exported contracts — how you extend this code

NotificationService (Interface)
(no doc) [9 implementers]
packages/ee/src/notifications/types.ts
SchedulingStrategy (Interface)
(no doc) [5 implementers]
packages/database/supabase/functions/lib/scheduling/date-calculator.ts
ExtensionData (Interface)
* The minimal data every extension renderer needs. Each document's richer data * bag (QuoteData, JobTravelerData, …) is
packages/documents/src/pdf/blocks/extensionRegistry.tsx
EditorSnapshot (Interface)
The persisted shape — what `isDirty` compares and what `save` writes.
apps/erp/app/components/DocumentTemplateEditor/context.tsx
EphemeralCache (Interface)
(no doc) [1 implementers]
packages/kv/src/ratelimit/types.ts
Resource (Interface)
(no doc)
sst-env.d.ts
ICarbonStore (Interface)
(no doc)
packages/react/src/CarbonContext.tsx
Options (Interface)
(no doc)
packages/utils/src/humanize-duration.d.ts

Core symbols most depended-on inside this repo

map
called by 3580
apps/erp/public/pdf.worker.min.mjs
get
called by 2518
packages/ee/src/accounting/core/types.ts
flash
called by 2042
packages/auth/src/services/session.server.ts
push
called by 1979
apps/erp/public/pdf.worker.min.mjs
error
called by 1653
packages/auth/src/utils/result.ts
requirePermissions
called by 1474
packages/auth/src/services/auth.server.ts
error
called by 1303
apps/erp/public/pdf.worker.min.mjs
filter
called by 1216
apps/erp/public/pdf.worker.min.mjs

Shape

Function 9,686
Method 2,685
Class 1,235
Interface 458
Enum 24

Languages

TypeScript100%

Modules by API surface

apps/erp/public/pdf.worker.min.mjs3,791 symbols
apps/erp/app/modules/sales/sales.service.ts191 symbols
apps/erp/app/modules/items/items.service.ts160 symbols
apps/erp/app/modules/production/production.service.ts143 symbols
apps/erp/app/modules/inventory/inventory.service.ts122 symbols
apps/erp/app/modules/purchasing/purchasing.service.ts109 symbols
apps/erp/app/modules/resources/resources.service.ts96 symbols
apps/erp/app/modules/quality/quality.service.ts92 symbols
apps/erp/app/modules/accounting/accounting.service.ts87 symbols
apps/erp/app/modules/settings/settings.service.ts85 symbols
packages/ee/src/paperless-parts/lib/client.ts67 symbols
apps/erp/app/modules/invoicing/invoicing.service.ts61 symbols

Datastores touched

postgresDatabase · 1 repos

For agents

$ claude mcp add carbon \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact