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
Basic docs (#25)
Brad Barbin7435dfa6c581
diff --git a/.nvmrc b/.nvmrcnew file mode 100644index 0000000000..0828ab7947--- /dev/null+++ b/.nvmrc@@ -0,0 +1 @@+v18\ No newline at end of filediff --git a/README.md b/README.mdindex 5184a2d651..e8fb89e01e 100644--- a/README.md+++ b/README.md@@ -75,6 +75,7 @@ After running the steps below you should be able to access the following apps/coFirst download and initialize the repository dependencies.```bash+$ nvm use # use node v18$ yarn # install dependencies$ yarn init # pull and start the containers```diff --git a/packages/carbon-database/supabase/.branches/_current_branch b/packages/carbon-database/supabase/.branches/_current_branchdeleted file mode 100644index 88d050b190..0000000000--- a/packages/carbon-database/supabase/.branches/_current_branch+++ /dev/null@@ -1 +0,0 @@-main\ No newline at end of filediff --git a/www/components/pages/Home.tsx b/www/components/pages/Home.tsxindex 13e100c583..8d285fff22 100644--- a/www/components/pages/Home.tsx+++ b/www/components/pages/Home.tsx@@ -17,7 +17,7 @@ export default function Home() {<div className="flex flex-col justify-between text-center"><div><h1 className="max-w-5xl mx-auto nx-text-6xl font-extrabold tracking-tighter leading-[1.1] text-6xl sm:text-7xl lg:nx-text-8xl xl:nx-text-8xl">- ERP + ERP <span className="pr-1 inline-block text-transparent bg-clip-text bg-gradient-to-r from-green-500 to-blue-500 ">for the builders</span>@@ -27,6 +27,16 @@ export default function Home() {manufacturers.</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">+ <div className="rounded-md fix-width-auto xl:w-auto">+ <a+ className="flex items-center justify-center w-full px-8 py-3 text-base font-medium text-white no-underline bg-black border border-transparent rounded-md dark:bg-white dark:text-black betterhover:dark:hover:bg-gray-300 betterhover:hover:bg-gray-700 md:py-3 md:text-lg md:px-10 md:leading-6"+ href="/docs/getting-started"+ >+ Get Started →+ </a>+ </div>+ </div></div></div>diff --git a/www/pages/_app.tsx b/www/pages/_app.tsxindex 79eea87189..e844ae9c5d 100644--- a/www/pages/_app.tsx+++ b/www/pages/_app.tsx@@ -3,6 +3,6 @@ import type { AppProps } from "next/app";import "../styles.css";import "nextra-theme-docs/style.css";-export default function Nextra({ Component, pageProps }: AppProps) {+export default function Docs({ Component, pageProps }: AppProps) {return <Component {...pageProps} />;}diff --git a/www/pages/docs/_meta.json b/www/pages/docs/_meta.jsonindex 08c84f5418..a0e3133cb5 100644--- a/www/pages/docs/_meta.json+++ b/www/pages/docs/_meta.json@@ -1,6 +1,6 @@{"index": "Introduction",- "stack": "Tech Stack",+ "tech-stack": "Tech Stack","getting-started": "Getting Started","principles": "Principles","core-concepts": "Core Concepts"diff --git a/www/pages/docs/core-concepts/_meta.json b/www/pages/docs/core-concepts/_meta.jsonindex 1584d33db3..ceb5ef0fac 100644--- a/www/pages/docs/core-concepts/_meta.json+++ b/www/pages/docs/core-concepts/_meta.json@@ -1,8 +1,5 @@{"permissions": "Permissions","fetching": "Data Fetching",- "writing": "Data Writes",- "realtime": "Realtime",- "serverless": "Serverless",- "integration": "APIs"+ "writing": "Data Writes"}diff --git a/www/pages/docs/core-concepts/fetching.mdx b/www/pages/docs/core-concepts/fetching.mdxnew file mode 100644index 0000000000..68dbf15d6d--- /dev/null+++ b/www/pages/docs/core-concepts/fetching.mdx@@ -0,0 +1,119 @@+---+title: Data Fetching in Carbon ERP+description: Conventions for fetching data in Carbon ERP+---++import { Callout } from "nextra-theme-docs";++# Fetching++The convention is to fetch data on the server and pass it to the UI with the `useLoaderData` hook. Here's how that works:++1. Data is fetched on the server in a `loader` function+2. The `loader` function gets a `client` by calling `requirePermissions`+3. The `client` is passed to the server-side service, and returns both `{ data, error }`+4. The `loader` function redirects in the case of an error and returns the data in the case of no error+5. The component uses the `useLoaderData` hook to expose the data to the UI++<Callout>+ Fetching should not be done with a `useEffect` hook. This is because the+ `useEffect` hook is not called on the server, so the data will not be+ available on the first render. Instead, use the `useLoaderData` hook.+</Callout>++Here's an example of simple route that fetches data from a service and displays it in a table:++```tsx+// app/routes/x+/resources+/partners.tsx++// loader is run on the server+export async function loader({ request }: LoaderArgs) {+ const { client } = await requirePermissions(request, {+ view: "resources",+ role: "employee",+ });++ const url = new URL(request.url);+ const searchParams = new URLSearchParams(url.search);+ const name = searchParams.get("name");+ const { limit, offset, sorts } = getGenericQueryFilters(searchParams);++ const partners = await getPartners(client, {+ name,+ limit,+ offset,+ sorts,+ });++ if (partners.error) {+ return redirect(+ "/x/resources",+ await flash(request, error(partners.error, "Failed to load partners"))+ );+ }++ return json({+ partners: partners.data ?? [],+ count: partners.count ?? 0,+ });+}++// data is passed to the UI with the useLoaderData hook+export default function Route() {+ const { partners, count } = useLoaderData<typeof loader>();++ return (+ <VStack w="full" h="full" spacing={0}>+ <PartnersTableFilters />+ <PartnersTable data={partners} count={count} />+ <Outlet />+ </VStack>+ );+}+```++Here's an example of two services that fetch data from the database. The `.server.ts` file extension ensures that the code is only executed on the server:++```tsx+// app/modules/resources/resources.server.ts++export async function getPartner(+ client: SupabaseClient<Database>,+ partnerId: string+) {+ // select a single row from the partner table+ return client+ .from("partner")+ .select(`id, hoursPerWeek, supplier(name)`)+ .eq("id", partnerId)+ .single();+}++export async function getPartners(+ client: SupabaseClient<Database>,+ args?: GenericQueryFilters & { name: string | null }+) {+ // select the partner id, supplier name, and hours per week+ let query = client+ .from("partner")+ .select(`id, supplier(name), hoursPerWeek`, { count: "exact" })+ .eq("active", true);++ if (args?.name) {+ // if a name argument is provided, filter by name+ query = query.ilike("name", `%${args.name}%`);+ }++ if (args) {+ // sort by supplier name by default+ query = setGenericQueryFilters(query, args, "supplier(name)");+ }++ return query;+}+```++<Callout>+ For more information on query building, see the [Supabase+ documentation](https://supabase.io/docs/reference/javascript/select)+</Callout>diff --git a/www/pages/docs/core-concepts/permissions.mdx b/www/pages/docs/core-concepts/permissions.mdxnew file mode 100644index 0000000000..159bc8e1ad--- /dev/null+++ b/www/pages/docs/core-concepts/permissions.mdx@@ -0,0 +1,168 @@+---+title: Permissions in Carbon ERP+description: Conventions for permissions in Carbon ERP+---++# Permissions++There are two types of permissions in the system:++1. **Module permissions** - These are permissions that are specific to a module. For example, a user may have permission to view the sales module, but not to create, update or delete sales.+2. **Role permissions** - These are permissions that are specific to a role. For example, customers may be able to view the sales module, but a customer role limits the data to only their own sales, where an employee with the same permission can view all sales.++A user's permissions are stored in the `auth.users` table in the `raw_app_meta_data` column.++The JSON permissions data in that column something like this:++```json+{+ "role": "employee",+ ...+ "sales_view": true,+ "sales_create": true,+ "sales_update": true,+ "sales_delete": false,+ ...+ "purchasing_view": false,+ "purchasing_create": false,+ "purchasing_update": false,+ "purchasing_delete": false,+ ...+}+```++Each user has a **role**, which may be one of the following:++- `employee`+- `customer`+- `supplier`++Additionally, each user has a set of permissions for each module. Generally, the permissions are:++- `<module>_view`+- `<module>_create`+- `<module>_update`+- `<module>_delete`++Permissions are managed within the user module. **An employees' permissions are set according to the default permissions for their employee type when the user is created**. Each employee may then be fined tuned for individual permissions in the users module. There is also an option to bulk update permissions for employees.++Currently, all customers and suppliers have hard-coded permissions, which are set when the customer account or supplier account is created.++## Permissions in the Code++There are three places where permissions can be used in the code. In order of precedence, they are:++1. **Database row-level security (RLS)** - an in-database policy, written in SQL, that limits the data that a user can see or modify.+2. **Server-side permission checks** - a helper function that checks the user's permissions before making a call to the database.+3. **Client-side permission checks** - a helper function that checks the user's permissions before making a call to the server.++It is most important to use RLS. But server-side and client-side mechanisms can be used as additional security measures. RLS is expensive, so we use server-side and client-side checks to avoid making unnecessary calls to the database.++### Database Row-Level Security++Here is an example of how to use RLS policies to limit a user's rights to modify a table using the `get_my_claim` function. This is SQL that's run against the database to create a security policy for the `customer` table. If you're not familiar with the `::bolean` and `::jsonb` syntax, that's just casting the value to a boolean or jsonb type. The `get_my_claim` function is a custom function that returns the value of a claim from the user's permissions record. The `auth.uid()` function returns the user's ID.++```sql+-- SQL++ALTER TABLE "customer" ENABLE ROW LEVEL SECURITY;++CREATE POLICY "Employees with sales_view can view customer" ON "customer"+ FOR SELECT+ USING (+ coalesce(get_my_claim('sales_view')::boolean, false) = true+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb+ );++CREATE POLICY "Customers with sales_view can their own organization" ON "customer"+ FOR SELECT+ USING (+ coalesce(get_my_claim('sales_view')::boolean, false) = true+ AND (get_my_claim('role'::text)) = '"customer"'::jsonb+ AND id IN (+ SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()+ )+ );++CREATE POLICY "Employees with sales_create can create customers" ON "customer"+ FOR INSERT+ WITH CHECK (+ coalesce(get_my_claim('sales_create')::boolean, false)+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb+ );++CREATE POLICY "Employees with sales_update can update customers" ON "customer"+ FOR UPDATE+ USING (+ coalesce(get_my_claim('sales_update')::boolean, false)+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb+ );++CREATE POLICY "Customers with sales_update can their own organization" ON "customer"+ FOR UPDATE+ USING (+ coalesce(get_my_claim('sales_update')::boolean, false) = true+ AND (get_my_claim('role'::text)) = '"customer"'::jsonb+ AND id IN (+ SELECT "customerId" FROM "customerAccount" WHERE id::uuid = auth.uid()+ )+ );++CREATE POLICY "Employees with sales_delete can delete customers" ON "customer"+ FOR DELETE+ USING (+ coalesce(get_my_claim('sales_delete')::boolean, false) = true+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb+ );++```++### Server-Side Permission Checks++We provide a helper function called `requirePermissions` that can be used to check the user's permissions before making a call to the database. This method is almost always called in an action (data write) or a loader (data fetch).++Here is an example of how to use it in a loader:++```tsx+export async function loader({ request }: LoaderArgs) {+ const { client } = requirePermissions(request, {+ view: "sales",+ role: "employee",+ });++ // call to the database+}+```++In this example, the user must have the `sales_view` permission and the `employee` role in order to access the loader. If the user does not have the required permissions, an `Access denied` error will be thrown, and the user will be redirected to the root page.++We can also required multiple permissions. In the next example, the user must have the `sales_update` permission and the `users_update` permission in order to invoke the action:++```tsx+export async function action({ request }: ActionArgs) {+ const { client } = requirePermissions(request, {+ update: ["sales", "users"],+ });++ // call to the database+}+```++### Client-Side Permission Checks++Finally, we can use client-side permission checks to limit what the user can do in the UI. This is done using the `usePermissions` hook. It provides two methods:++1. `can` - a function that takes a module (sales) and an action (view, create, update, delete) and returns a boolean indicating whether the user has the required permission.+2. `is` - a function that takes a role (employee, customer, supplier) and returns a boolean indicating whether the user has the required role.++Here's an example of how we might use client-side permission checks to hide the NewSalesForm component if the user does not have the `sales_create` permission:++```tsx+import { usePermissions } from "~/hooks";++export default function SalesList() {+ const permissions = usePermissions();++ return <>{permissions.can("create", "sales") && <NewSalesForm />}</>;+}+```diff --git a/www/pages/docs/core-concepts/writing.mdx b/www/pages/docs/core-concepts/writing.mdxnew file mode 100644index 0000000000..5f23c42287--- /dev/null+++ b/www/pages/docs/core-concepts/writing.mdx@@ -0,0 +1,134 @@+---+title: Data Writes in Carbon ERP+description: Conventions for mutating data in Carbon ERP+---++import { Callout } from "nextra-theme-docs";++# Data Writes++Data writes should include:++1. An HTML form+2. Client-side validation in the component+3. Server-side validation in an action+4. A call to the service layer to perform the write++## Validation++Client-side validation and server-side validation can be done with the same validator. The convention is to store all validators for a module in `app/<module>/services/<module>.form.ts`. We use `zod` and `zod-form-data` for form validation. Here's an example of a simple validator:++```ts+import { withZod } from "@remix-validated-form/with-zod";+import { z } from "zod";+import { zfd } from "zod-form-data";++export const personValidator = withZod(+ z.object({+ // optional, parsed as string or undefined+ id: zfd.text(z.string().optional()),+ // required, parsed as string+ name: z.string().min(1, { message: "Name is required" }),+ // optional, parsed as number or undefined+ age: zfd.numeric(z.number().optional()),+ // required, parsed as boolean+ male: zfd.checkbox(),+ })+);+```++In this example, we have a validator for a person form. For most fields, `z.string()` will suffice, but sometimes, we want to parse the validated form values as numbers or booleans. In those cases, we use `zfd.numeric()` and `zfd.checkbox()`. There are fancier things you can do, but this example should cover 90% of use cases.++<Callout>+ For more information on the validators, see the [remix-validated-form+ documentation](https://www.remix-validated-form.io/)+</Callout>++## Client-Side Validation++On the client-side, there are two major components to be aware of:++1. Our form validation component from the [remix-validated-form](https://www.remix-validated-form.io/) package called `ValidatedForm` which accepts a `validator` prop.+2. Our form input components from `~/components/Form` which are designed to be used inside of `ValidatedForm`++Here's an example of how they work together on the client-side:++```tsx+import { ValidatedForm } from "remix-validated-form";+import { Boolean, Hidden, Input, Numeric} from "~/components/Form";+import { personValidator } from "~/modules/people";+++const Form = ({initialValues}: FormProps) => {+ return (+ <ValidatedForm+ method="post"+ action="/path/to/the/action/route"+ validator={personValidator}+ defaultValues={initialValues}+ >+ <Hidden name="id" />+ <Input name="name" label="Name">+ <Numeric name="age" min={0} max={100} />+ <Boolean name="male" label="Male" />+ </ValidatedForm>+ )+}+```++The form is validated on the client-side before the form is submitted. If the form is invalid, the user can't submit the form until they fix the errors. If the form is valid, the user can submit the form and the server-side validation will run with the same validator.++## Server-Side Validation++On the server-side, we use the same validator in the `action` function to validate the form data. If the form data is invalid, we return the form with the errors. If the form data is valid, we call the service layer to perform the write.++```tsx+import { validationError } from "remix-validated-form";+import { createPerson, personValidator } from "~/modules/people";++export async function action({ request }: ActionArgs) {+ const { client } = await requirePermissions(request);++ const validation = await personValidator.validate(await request.formData());++ if (validation.error) {+ return validationError(validation.error);+ }++ const { name, male, age } = validation.data;++ await createPerson(client, {+ name,+ male,+ age+ });++ return redirect(+ "/path/to/the/next/page",+ await flash(request, success("Person created."))+ );+```++## Service Layer++Finally, let's have a look at our service layer. The service layer is where we perform the actual write to the database using the `client` returned from `requirePermissions`. The convention is to store all service layer functions in `app/<module>/services/<module>.server.ts`. Including `.server` in the filename is important because it tells Remix to only include the file in the server bundle.++Here's an example of a simple service layer function:++```ts+export async function createPerson(+ client: SupabaseClient<Database>,+ person: {+ name: string;+ male: boolean;+ age?: number;+ }+) {+ return client.from("people").insert(person);+}+```++<Callout>+ For more information on the service layer, see the [Supabase+ documentation](https://supabase.io/docs/reference/javascript/insert)+</Callout>diff --git a/www/pages/docs/getting-started.mdx b/www/pages/docs/getting-started.mdxindex 42c294a0d7..8298b94d5a 100644--- a/www/pages/docs/getting-started.mdx+++ b/www/pages/docs/getting-started.mdx@@ -5,7 +5,7 @@ description: Carbon ERP is a high-performance, open-source ERP for manufacturing# Getting Started-Before getting started with development, it's good to have a basic understanding of our [tech stack](/stack).+Before getting started with development, it's good to have a basic understanding of our [tech stack](/docs/tech-stack).You'll also need to have [Docker installed](https://docs.docker.com/desktop/install/mac-install/) and [yarn installed](https://yarnpkg.com/lang/en/docs/install/#debian-stable)on your system since this monorepo uses the yarn package manager.@@ -37,6 +37,7 @@ $ cp ./.env.example ./.envAfter you've set the enviroment variables to the output of `yarn init` you can run```bash+$ nvm use # use node v18$ yarn db:build # run db migrations and seed script$ yarn build # build the packages```diff --git a/www/pages/docs/principles.mdx b/www/pages/docs/principles.mdxnew file mode 100644index 0000000000..9f44f696cb--- /dev/null+++ b/www/pages/docs/principles.mdx@@ -0,0 +1,52 @@+---+title: Carbon ERP Principles+description: Simplicity, extensibility, openness, and productivity are the four principles that guide the development of Carbon ERP.+---++# Principles++Decision-making is guided by four principles:++1. Simplicity+2. Extensibility+3. Openness+4. Productivity++## Simplicity++We understand that manufacturers don't often have the luxury of large teams of developers. Often a single software developer will be responsible for many custom applications. Our goal is to provide **a simple platform with a single database** that manufacturers can use as **the heart of their digital operations**.++To provide simplicity we use these approaches:++- Best open-source software+- Minimal languages (TypeScript and SQL)+- Minimal dependencies+- Single-purpose examples and templates+- Strong documentation+- Total transparency++## Extensibility++**Every manufacturer has unique needs that are not covered by the standard platform**. We want to make it easy to extend the platform to meet their needs.++To provide extensibility we have the following goals:++- Easy to add custom applications+- Easy to add API endpoints+- Easy to add custom database tables+- Easy to add modules and interfaces to the primary application++## Openness++The ERP system is the heart of a manufactuer's digital operation. We want to make sure that they can easily integrate with other systems and customize it in any way that they need. **The only real way to do this that to make the source code available**.++An open source ERP system has a number of benefits, including:++- Lower costs+- Greater flexibility+- More customization operations+- Better security++## Productivity++When making decisions, we aim to **optimize for long-term developer productivity**. We take it as a given that everyone wants more features. But in order to quickly provide new features over time, we need to make sure that the platform is easy to use and maintain.diff --git a/www/pages/docs/principles/_meta.json b/www/pages/docs/principles/_meta.jsondeleted file mode 100644index 26efabd18d..0000000000--- a/www/pages/docs/principles/_meta.json+++ /dev/null@@ -1,6 +0,0 @@-{- "simplicity": "Simple",- "extensiblity": "Extensible",- "open-source": "Open Source",- "productivity": "Productive"-}diff --git a/www/pages/docs/tech-stack.mdx b/www/pages/docs/tech-stack.mdxnew file mode 100644index 0000000000..43b69271f7--- /dev/null+++ b/www/pages/docs/tech-stack.mdx@@ -0,0 +1,140 @@+---+title: Carbon ERP Tech Stack+description: TypeScript, React, Chakra UI, Remix, Supabase+---++# Tech Stack++Our tech stack aims to be as simple as possible, while still being powerful enough to build any web application. We use the following technologies:++- [TypeScript](https://www.typescriptlang.org) is the programming language+- [React](https://reactjs.org) for the frontend+- [Chakra UI](https://chakra-ui.com) for the UI components+- [Remix](https://remix.run) for the routing and compiling+- [Supabase](https://supabase.io) for the database and authentication++We also use [Redis](https://redis.io) for caching and [Vercel](https://vercel.com) for hosting, though in most cases you probably won't need those.++In this page, we'll give you a basic overview of how the tech stack works together. If you want to learn more about any of the technologies, we recommend checking out their documentation.++## TypeScript++[TypeScript](https://www.typescriptlang.org) is a programming language that builds on top of JavaScript. It adds a bunch of features that make it easier to write code, and it also makes it easier to catch bugs before you ship your code. It was created by the inventor of C# and maintained by Microsoft.++We chose TypeScript because it allows us to use a single, strongly-typed language across the entire application.++## React++[React](https://reactjs.org) is a JavaScript library for building user interfaces. It's the most popular frontend framework in the world, and it's used by many of the biggest companies in the world, including Facebook, Netflix, and Airbnb.++React is a component-based framework, which means that you can build your UI out of small, reusable components. This makes it easy to build complex UIs, and it also makes it easy to reuse code across different parts of your application.++React is also declarative, which means that you describe what you want your UI to look like, and React will take care of updating the UI whenever the data changes. This makes it easy to build complex UIs, and it also makes it easy to reuse code across different parts of your application.++We have a package called [@carbon/react](https://github.com/barbinbrad/carbon/tree/main/packages/carbon-react/src) that has a bunch of React components that you can use to build your UI. You can also use any other React component library that you want.++## Chakra UI++[Chakra UI](https://chakra-ui.com) is a lightweight and flexible component library that gives us accessibility, full-control, and simplicty. It implements the WAI-ARIA spec behaviors with some basic primitive components (like Button and Modal) while providing an easy-to-modify API for customizing the design.++```jsx+import { Button } from "@chakra-ui/react";++function App() {+ return (+ <Button size="lg" variant="outline">+ Click me+ </Button>+ );+}+```++There are a lot of other component libraries out there, but we chose Chakra UI because it gives us a lot of flexibility while still being easy to use. If you're building user interfaces, we recommend you check out their documentation.++## Remix++[Remix](https://remix.run) is a framework for building full-stack web applications. It's built on top of React, and it allows us to co-locate server-side code and client-side code in the same files. When combined with TypeScript and Supabase, this gives us type-safety from the database to the UI.++Remix makes for a beautiful developer experience. It's use of [loaders, actions and components](https://remix.run/blog/remix-data-flow) **minimizes the amount of code that needs written while maximzing performance**. To learn more about Remix, check out their documentation, and take a look at some files from our [routes](https://github.com/barbinbrad/carbon/tree/main/apps/carbon/app/routes) directory.++Here's a slightly-simplified example of how a Remix route works:++```tsx+// File (route): /products/$productId/edit.tsx++export async function loader({ params }) {+ const product = await database.getProduct(params.productId);+ return json(product);+}++export default function Route() {+ const product = useLoaderData();+ return (+ <h2>Edit Product {product.id}</h2>+ <Form method="post">+ <input name="name" defaultValue={product.name} />+ <input name="price" defaultValue={product.price} />+ <button type="submit">Save</button>+ </Form>+ )+}++export async function action({params, request}) {+ const form = await request.formData();+ const name = form.get("name");+ const price = form.get("price");+ const product = await database.updateProduct({ id: params.productId, name, price });+ return redirect(`/products/${product.id}`);+}+```++## Supabase++[Supabase](https://supabase.io) is a database, authentication, and storage service that's built on top of Postgres. It allows us to provide a simple, unified authentication layer across many applications (even one's that don't exist yet).++Supabase provides a TypeScript client called [Supabase JS](https://supabase.com/docs/reference/javascript/typescript-support) that makes it incredibly easy to query/modify the database. It also makes it easy to use row-level security to restrict access to certain parts of the database on a per-user basis.++Here's a look at how you can use Supabase JS to query the database from a Remix loader where `client` is the supabase client specific to the user making the request:++```tsx+export async function loader({request}) {+ const { client } = requirePermissions(request, view: 'purchasing');+ const { data, error } = await client+ .from('purchaseOrder')+ .select(`+ id, name,+ customer(id, name),+ purchaseOrderItems(id, name, quantity, unitPrice, total)+ `)+ .order('createdAt', { ascending: false })+ .limit(10);++ if (error) {+ return redirect('/');+ }++ return json(data);+}+```++This is equivalent to the following SQL query.++```sql+SELECT+ id,+ name,+ customer.id,+ customer,name+ purchaseOrderItems.id,+ purchaseOrderItems.name,+ purchaseOrderItems.quantity,+ purchaseOrderItems.unitPrice,+ purchaseOrderItems.total+FROM "purchaseOrder"+INNER JOIN "customer" ON "customer"."id" = "purchaseOrder"."customerId"+LEFT JOIN "purchaseOrderItem" ON "purchaseOrderItem"."purchaseOrderId" = "purchaseOrder"."id"+ORDER BY "createdAt" DESC+LIMIT 10+```++But unlike a raw SQL query, the data that we get back is strongly-typed and nicely nested. It also has nice error reporting baked in.diff --git a/www/theme.config.js b/www/theme.config.jsindex d6c056c77d..953fc0b5d4 100644--- a/www/theme.config.js+++ b/www/theme.config.js@@ -49,8 +49,6 @@ export default {head: (<><meta name="viewport" content="width=device-width, initial-scale=1.0" />- <meta name="description" content="Nextra: the next docs builder" />- <meta name="og:title" content="Nextra: the next docs builder" /></>),};