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
docs(architecture): drop cross-tenant trap, use American spellings (#1390)
Brad Barbin87a19b325363
diff --git a/apps/erp/app/modules/agent/kb/docs/platform/architecture.md b/apps/erp/app/modules/agent/kb/docs/platform/architecture.mdindex 6d98436f48..304e5fa35c 100644--- a/apps/erp/app/modules/agent/kb/docs/platform/architecture.md+++ b/apps/erp/app/modules/agent/kb/docs/platform/architecture.md@@ -28,13 +28,13 @@ about twenty-five shared libraries, built together by pnpm workspaces andTurborepo [[25]](#g25). Two of those applications are the products people log into, theERP and the MES. Everything else exists to serve them.-The centre of gravity is a single Postgres [[17]](#g17) database. Almost every arrow in+The center of gravity is a single Postgres [[17]](#g17) database. Almost every arrow inthis doc eventually points at it. Unusually for a web app, a lot of logic that you mightexpect to live in application code lives _inside_ the database instead: permissions,computed totals, and the "something changed" notifications. That is the single mostimportant thing to understand about Carbon, and [Part 3](#part-3-layer-by-layer) explains why.-Colour is used sparingly in these diagrams, and it means the same thing in all of them:+Color is used sparingly in these diagrams, and it means the same thing in all of them:**blue** is our own apps, **pink** is stored state, **amber** is work that happens in thebackground. Everything else is left plain on purpose.@@ -359,7 +359,7 @@ FOR SELECT USING (So if a query for another company's purchase orders reaches Postgres, it returns zerorows. The tenant boundary is enforced by the database, not by us remembering a `.eq()`.-Service functions still filter by `companyId` anyway, as a second line of defence.+Service functions still filter by `companyId` anyway, as a second line of defense.**The escape hatch.** Notice `bypassRls: true` in the Purchase Order action. RLS costsreal query time on hot paths, so for trusted employee requests we hand back a service-role@@ -407,7 +407,7 @@ return db.transaction().execute(async (trx) => {```Three warnings. Kysely **throws** on failure rather than returning `{ error }`, so wrap it-in `try/catch`. It applies **no** RLS, so authorise before you call it. And the pool it+in `try/catch`. It applies **no** RLS, so authorize before you call it. And the pool itdraws from is small (edge functions ask for exactly one connection,`getConnectionPool(1)`): if code inside a transaction reaches for a second connection fromthe same pool, that second request queues behind a transaction that cannot finish until it@@ -622,7 +622,7 @@ refuses to start without it.| App | What it is | Dev port || ----------- | --------------------------------------------------------------------------- | -------- || `erp` | The main product, and the host for all background jobs. By far the largest. | 3000 |-| `mes` | Shop floor: job operations, work centres, scheduling. Touch-first. | 3001 |+| `mes` | Shop floor: job operations, work centers, scheduling. Touch-first. | 3001 || `academy` | Training app for new Carbon users. | 4111 || `starter` | A minimal example app showing auth + database + forms. | 4000 || `assembler` | The Rust CAD/3D service. | varies |@@ -754,7 +754,7 @@ environment variables on the container.### 7.5 Knowing what is happening-Observability is deliberately thin. Logs go through LogTape: colour on a laptop, one JSON+Observability is deliberately thin. Logs go through LogTape: color on a laptop, one JSONline per entry in production, with sensitive field names blanked out and a request idthreaded through everything so one page load can be followed end to end. There is no logshipping of its own, so logs are whatever the platform collects: CloudWatch on AWS,@@ -776,8 +776,6 @@ Start from what the user saw and walk inwards. This mirrors the order things hapis wrong or you are using a user-scoped client where you needed service role.- _A write half-succeeded._ Chained `supabase-js` calls are not a transaction. Look for amanual rollback that didn't cover the failure.-- _You see another company's data._ Something is using `bypassRls: true` or the- service-role client without re-checking the tenant. **Treat this as urgent.**- _A number on a list screen is wrong._ It is almost certainly computed in a view.---diff --git a/docs/content/docs/platform/architecture.mdx b/docs/content/docs/platform/architecture.mdxindex b54991b27f..d29c4a11c0 100644--- a/docs/content/docs/platform/architecture.mdx+++ b/docs/content/docs/platform/architecture.mdx@@ -31,7 +31,7 @@ about twenty-five shared libraries, built together by pnpm workspaces andTurborepo [[25]](#g25). Two of those applications are the products people log into, theERP and the MES. Everything else exists to serve them.-The centre of gravity is a single Postgres [[17]](#g17) database. Almost every arrow in+The center of gravity is a single Postgres [[17]](#g17) database. Almost every arrow inthis doc eventually points at it. Unusually for a web app, a lot of logic that you mightexpect to live in application code lives _inside_ the database instead: permissions,computed totals, and the "something changed" notifications. That is the single most@@ -39,7 +39,7 @@ important thing to understand about Carbon, and [Part 3](#part-3-layer-by-layer)<Diagram name="map" caption="Everything Carbon runs. The loop on the right is the surprise: Inngest is a timer and a queue, but the job itself executes back inside the ERP." />-Colour is used sparingly in these diagrams, and it means the same thing in all of them:+Color is used sparingly in these diagrams, and it means the same thing in all of them:**blue** is our own apps, **pink** is stored state, **amber** is work that happens in thebackground. Everything else is left plain on purpose.@@ -366,7 +366,7 @@ FOR SELECT USING (So if a query for another company's purchase orders reaches Postgres, it returns zerorows. The tenant boundary is enforced by the database, not by us remembering a `.eq()`.-Service functions still filter by `companyId` anyway, as a second line of defence.+Service functions still filter by `companyId` anyway, as a second line of defense.**The escape hatch.** Notice `bypassRls: true` in the Purchase Order action. RLS costsreal query time on hot paths, so for trusted employee requests we hand back a service-role@@ -416,7 +416,7 @@ return db.transaction().execute(async (trx) => {```Three warnings. Kysely **throws** on failure rather than returning `{ error }`, so wrap it-in `try/catch`. It applies **no** RLS, so authorise before you call it. And the pool it+in `try/catch`. It applies **no** RLS, so authorize before you call it. And the pool itdraws from is small (edge functions ask for exactly one connection,`getConnectionPool(1)`): if code inside a transaction reaches for a second connection fromthe same pool, that second request queues behind a transaction that cannot finish until it@@ -635,7 +635,7 @@ refuses to start without it.| App | What it is | Dev port || ----------- | --------------------------------------------------------------------------- | -------- || `erp` | The main product, and the host for all background jobs. By far the largest. | 3000 |-| `mes` | Shop floor: job operations, work centres, scheduling. Touch-first. | 3001 |+| `mes` | Shop floor: job operations, work centers, scheduling. Touch-first. | 3001 || `academy` | Training app for new Carbon users. | 4111 || `starter` | A minimal example app showing auth + database + forms. | 4000 || `assembler` | The Rust CAD/3D service. | varies |@@ -769,7 +769,7 @@ environment variables on the container.### 7.5 Knowing what is happening-Observability is deliberately thin. Logs go through LogTape: colour on a laptop, one JSON+Observability is deliberately thin. Logs go through LogTape: color on a laptop, one JSONline per entry in production, with sensitive field names blanked out and a request idthreaded through everything so one page load can be followed end to end. There is no logshipping of its own, so logs are whatever the platform collects: CloudWatch on AWS,@@ -793,8 +793,6 @@ Start from what the user saw and walk inwards. This mirrors the order things hapis wrong or you are using a user-scoped client where you needed service role.- _A write half-succeeded._ Chained `supabase-js` calls are not a transaction. Look for amanual rollback that didn't cover the failure.-- _You see another company's data._ Something is using `bypassRls: true` or the- service-role client without re-checking the tenant. **Treat this as urgent.**- _A number on a list screen is wrong._ It is almost certainly computed in a view.---