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
refactor: code cleanup
Brad Barbine97ed9ba21a5
diff --git a/README.md b/README.mdindex de976ef7c3..6d39749691 100644--- a/README.md+++ b/README.md@@ -20,7 +20,7 @@ Product highlights/roadmap are:- [x] Search- [x] Customer and supplier access-- [ ] Double-entry accrual accounting+- [x] Double-entry accrual accounting- [ ] Stochastic scheduling/planning- [ ] Graph-based routing for manufacturing@@ -32,6 +32,19 @@ Product highlights/roadmap are:- [ ] Public Beta: Stable enough for most non-enterprise use-cases.- [ ] Public: Production-ready+## Techstack++- [Remix](https://remix.run) – framework+- [Typescript](https://www.typescriptlang.org/) – language+- [Tailwind](https://tailwindcss.com) – styling+- [Radix UI](https://radix-ui.com) - behavior+- [Supabase](https://supabase.com) - database+- [Supabase](https://supabase.com) – auth+- [Redis](https://redis.io) - cache+- [Trigger](https://trigger.dev) - jobs+- [Resend](https://resend.com) – email+- [Vercel](https://vercel.com) – hosting+## CodebaseThe monorepo follows the Turborepo covention of grouping packages into one of two folders.@@ -67,7 +80,6 @@ After running the steps below you should be able to access the following apps/co| Application | URL || --------------- | ------------------------------------------------------------------------------------------------------------------ || Carbon ERP | [http://localhost:3000](http://localhost:3000) |-| Shared Workers | [http://localhost:3000](http://localhost:3000) || Postgres | [postgresql://postgres:postgres@localhost:54322/postgres](postgresql://postgres:postgres@localhost:54322/postgres) || Supabase Studio | [http://localhost:54323/project/default](http://localhost:54323/project/default) || Inbucket | [http://localhost:54324/monitor](http://localhost:54324/monitor) |diff --git a/apps/carbon/app/jobs/get-exchange-rates.server.ts b/apps/carbon/app/jobs/get-exchange-rates.server.tsindex ed8976599d..e17eb8743b 100644--- a/apps/carbon/app/jobs/get-exchange-rates.server.ts+++ b/apps/carbon/app/jobs/get-exchange-rates.server.ts@@ -13,18 +13,23 @@ export const job = triggerClient.defineJob({seconds: 60 * 60 * 8, // thrice a day}),run: async (payload, io, ctx) => {+ // TODO: get client dynamically from DB+ if (!exchangeRatesClient) return;+await io.logger.info(`💵 Exchange Rates Job: ${payload.lastTimestamp}`);await io.logger.info(JSON.stringify(exchangeRatesClient.getMetaData()));try {const rates = await exchangeRatesClient.getExchangeRates();+ const timestamp = new Date().toISOString();await io.logger.info(JSON.stringify(rates));const { error } = await supabaseClient.from("currencyExchangeRate")- .insert(+ .upsert(Object.entries(rates).map(([currency, exchangeRate]) => ({currency,exchangeRate,+ timestamp,})));if (error) {diff --git a/apps/carbon/app/lib/exchange-rates.server.ts b/apps/carbon/app/lib/exchange-rates.server.tsindex f90752ed3c..a73ec36eaa 100644--- a/apps/carbon/app/lib/exchange-rates.server.ts+++ b/apps/carbon/app/lib/exchange-rates.server.ts@@ -79,8 +79,11 @@ export class ExchangeRatesClient {const apiKey = process.env.EXCHANGE_RATES_API_KEY;const apiUrl = process.env.EXCHANGE_RATES_API_URL;-export const exchangeRatesClient = new ExchangeRatesClient({- apiKey,- apiUrl,- baseCurrency: "USD",-});+export const exchangeRatesClient =+ apiKey && apiUrl+ ? new ExchangeRatesClient({+ apiKey,+ apiUrl,+ baseCurrency: "USD",+ })+ : undefined;diff --git a/apps/carbon/app/root.tsx b/apps/carbon/app/root.tsxindex aba9224364..5e189cc2f8 100644--- a/apps/carbon/app/root.tsx+++ b/apps/carbon/app/root.tsx@@ -107,7 +107,7 @@ export function ErrorBoundary() {<Document title="Error!"><div className="dark"><div className="flex flex-col w-full h-screen bg-zinc-900 items-center justify-center space-y-4">- <Heading size="display">Something went wrong</Heading>+ <Heading size="display">Cuss! Something went wrong</Heading><p className="text-foreground">{message}</p></div></div>diff --git a/packages/database/SCHEMA.md b/packages/database/SCHEMA.mdindex f8af0668d4..b340fd0134 100644--- a/packages/database/SCHEMA.md+++ b/packages/database/SCHEMA.md@@ -1,6 +1,4 @@-# Carbon Database Schema--This file is generated by `scripts/generate-schema-md.ts` using the migrations in `packages/database/supabase/migrations`.+# Carbon Database Schema by `scripts/generate-schema-md.ts` using the migrations in `packages/database/supabase/migrations`.@@ -7404,14 +7402,12 @@ CREATE OR REPLACE VIEW "employeeSummary" WITH(SECURITY_INVOKER=true) AS```sqlCREATE TABLE "currencyExchangeRate" (- "id" SERIAL PRIMARY KEY,"currency" TEXT NOT NULL,"exchangeRate" NUMERIC NOT NULL,- "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()-);+ "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),-CREATE INDEX "currencyExchangeRate_currency_index" ON "currencyExchangeRate" ("currency");-CREATE INDEX "currencyExchangeRate_createdAt_index" ON "currencyExchangeRate" ("createdAt");+ CONSTRAINT "currencyExchangeRate_pkey" PRIMARY KEY ("currency")+);ALTER TABLE "currencyExchangeRate" ENABLE ROW LEVEL SECURITY;diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex 93d96ec475..9e1dd60ef4 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -1667,22 +1667,19 @@ export interface Database {};currencyExchangeRate: {Row: {- createdAt: string;currency: string;exchangeRate: number;- id: number;+ timestamp: string;};Insert: {- createdAt?: string;currency: string;exchangeRate: number;- id?: number;+ timestamp?: string;};Update: {- createdAt?: string;currency?: string;exchangeRate?: number;- id?: number;+ timestamp?: string;};Relationships: [];};diff --git a/packages/database/supabase/migrations/20230126050441_abac.sql b/packages/database/supabase/migrations/20230126050441_abac.sqlindex 8cc6be6264..cf378f360b 100644--- a/packages/database/supabase/migrations/20230126050441_abac.sql+++ b/packages/database/supabase/migrations/20230126050441_abac.sql@@ -50,7 +50,7 @@ CREATE POLICY "Customers with sales_view can view contacts from their organizati));-CREATE POLICY "Many employees can create contact" ON "contact"+CREATE POLICY "Many employees can create contacts" ON "contact"FOR INSERTWITH CHECK ((diff --git a/packages/database/supabase/migrations/20240118035549_currency-exchange-rates.sql b/packages/database/supabase/migrations/20240118035549_currency-exchange-rates.sqlindex 15492d9bfa..7495eafd40 100644--- a/packages/database/supabase/migrations/20240118035549_currency-exchange-rates.sql+++ b/packages/database/supabase/migrations/20240118035549_currency-exchange-rates.sql@@ -1,12 +1,10 @@CREATE TABLE "currencyExchangeRate" (- "id" SERIAL PRIMARY KEY,"currency" TEXT NOT NULL,"exchangeRate" NUMERIC NOT NULL,- "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()-);+ "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),-CREATE INDEX "currencyExchangeRate_currency_index" ON "currencyExchangeRate" ("currency");-CREATE INDEX "currencyExchangeRate_createdAt_index" ON "currencyExchangeRate" ("createdAt");+ CONSTRAINT "currencyExchangeRate_pkey" PRIMARY KEY ("currency")+);ALTER TABLE "currencyExchangeRate" ENABLE ROW LEVEL SECURITY;diff --git a/packages/react/src/Heading.tsx b/packages/react/src/Heading.tsxindex 29224b3250..090770e7c7 100644--- a/packages/react/src/Heading.tsx+++ b/packages/react/src/Heading.tsx@@ -10,7 +10,7 @@ const headingVariants = cva({variants: {size: {- display: "md:text-5xl text-4xl",+ display: "md:text-4xl text-3xl",h1: "md:text-3xl text-2xl",h2: "md:text-2xl text-xl",h3: "md:text-xl text-base",diff --git a/www/components/pages/Home.tsx b/www/components/pages/Home.tsxindex 1e1a606daa..6aaee0f2f5 100644--- a/www/components/pages/Home.tsx+++ b/www/components/pages/Home.tsx@@ -42,67 +42,31 @@ function Hero() {return (<div className="flex flex-col justify-between text-center"><div>- <motion.h1- initial={{- filter: "blur(3px)",- opacity: 0,- scale: 1.2,- }}- animate={{- filter: "blur(0px)",- opacity: 1,- scale: 1,- }}- transition={{- duration: 2.5,- ease: "easeInOut",- }}- className="max-w-5xl mx-auto text-7xl font-extrabold tracking-tighter leading-tighter sm:text-7xl lg:text-8xl xl:text-8xl"- >+ <h1 className="max-w-5xl mx-auto text-7xl font-extrabold tracking-tighter leading-tighter sm:text-7xl lg:text-8xl xl:text-8xl"><span className="dark:bg-clip-text dark:text-transparent dark:bg-gradient-to-b dark:from-white dark:to-zinc-400">ERP for</span>{" "}<span className="bg-gradient-to-r bg-clip-text text-transparent dark:bg-gradient-to-b dark:from-[#3ECF8E] dark:via-[#3ECF8E] dark:to-[#3ecfb2] from-black via-orange-600 to-amber-500 ">the builders</span>- </motion.h1>- <motion.p- {...fadeIn}- transition={{- duration: 0.5,- delay: 2.6,- ease: "easeInOut",- }}- className="mt-6 nx-text-xl font-medium leading-tight text-black/60 dark:text-white/60 sm:nx-text-2xl md:nx-text-3xl lg:nx-text-4xl"- >+ </h1>+ <p className="mt-6 nx-text-xl font-medium leading-tight text-black/60 dark:text-white/60 sm:nx-text-2xl md:nx-text-3xl lg:nx-text-4xl">Carbon is an open-source starting point for resource planning- </motion.p>+ </p></div><div className="flex fix-flex-col h-32 mt-4 md:mt-0 mb-6 md:mb-0 items-center justify-center gap-3 md:flex-row xl:flex-row">- <motion.a- {...fadeIn}- transition={{- duration: 0.5,- delay: 3.0,- ease: "easeInOut",- }}+ <aclassName="flex items-center justify-center w-full px-8 py-3 text-base font-medium text-black no-underline bg-zinc-200 border border-zinc-300 dark:border-zinc-700 rounded-md dark:bg-zinc-800 dark:text-white betterhover:dark:hover:bg-zinc-800 betterhover:hover:bg-zinc-300 md:text-lg md:px-12 md:leading-6 fix-width-auto xl:w-auto"href="/learn/introduction">Learn- </motion.a>- <motion.a- {...fadeIn}- transition={{- duration: 0.5,- delay: 3.2,- ease: "easeInOut",- }}+ </a>+ <aclassName="flex items-center justify-center w-full px-8 py-3 text-base font-medium text-white no-underline bg-zinc-800 border border-zinc-700 dark:border-zinc-200 rounded-md dark:bg-zinc-100 dark:text-black betterhover:dark:hover:bg-zinc-300 betterhover:hover:bg-zinc-700 md:text-lg md:px-12 md:leading-6 fix-width-auto xl:w-auto"href="/develop/getting-started">Develop- </motion.a>+ </a></div></div>);diff --git a/www/pages/develop/getting-started.mdx b/www/pages/develop/getting-started.mdxindex 7dabf87826..1130df9ba7 100644--- a/www/pages/develop/getting-started.mdx+++ b/www/pages/develop/getting-started.mdx@@ -48,13 +48,19 @@ Finally, start the apps and packages:npm run dev # npm run dev in all apps & packages```-To kill the database containers in a non-recoverable way, you can run:+To stop the database containers in a recoverable way, you can run:```bash-npm run db:kill # stop and delete all database containers+npm run db:stop # stop and delete all database containers```-To restart and reseed the database, you can run:+To restart the database containers, you can run:++```bash+npm run db:restart # restart all database containers+```++To rebuild and reseed the database, you can run:```bashnpm run db:build # runs db:kill, db:start, and setup