Skip to content

Latest commit

 

History

History
62 lines (39 loc) · 3.28 KB

File metadata and controls

62 lines (39 loc) · 3.28 KB
title Data Providers
description This document explains the data providers used in the development of Atomic CRM.

By default, the Atomic CRM uses Supabase for the backend API. Supabase is an open-source alternative to Firebase, built on top of Postgres. It provides a REST API and a real-time subscription system. The generous free tier allows you to run a small CRM for free.

Using Test Data

Developing features with an empty database can be challenging. To help with this, Atomic CRM includes a CSV file with test data that can be imported into the application.

To import the test data, follow these steps:

  1. Go to the contacts page.
  2. Click the "Import" button.
  3. Select the file located at test-data/contacts.csv.

Using A Fake API For Development

For development purposes, you can use an alternative data provider called FakeRest. It's a simple REST API running in the browser that resets the data on each page reload. It's useful for testing the frontend without having to set up a backend, e.g. to let end users test some updates before the backend is ready.

Running The App With FakeRest

Type the following command to start the application with the FakeRest data provider:

npm run dev:demo

This will start the application on http://localhost:5173/ using FakeRest as the data provider. You will be logged in as a demo user with admin rights. The CRM will be pre-filled with random test data. You can modify the data, but it will be reset when you reload the page.

If you add custom fields and want them to be included in the FakeRest data, you can modify the data generator logic located in the src/components/atomic-crm/providers/fakerest/dataGenerator directory.

:::tip The Atomic CRM demo also uses FakeRest. Check it out to see how it works! :::

Setting Up The FakeRest Data Provider

If you want to set up the FakeRest data provider manually, you need to change the dataProvider import in the src/App.tsx file:

// in App.tsx
import { CRM } from "@/components/atomic-crm/root/CRM";
+import { authProvider, dataProvider } from "@/components/atomic-crm/providers/fakerest";

const App = () => (
-    <CRM />
+    <CRM dataProvider={dataProvider} authProvider={authProvider} />
);

export default App;

Warning: As supabase is still the default data provider, its environment variables (VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY) are still required.

Filters Syntax

The list filters used in this project MUST follow the ra-data-postgrest convention, where the filter operator is concatenated to the field name with an @. For example, to filter contacts by first name, you would use the first_name@eq filter.

When using FakeRest, the filters are mapped at runtime to the FakeRest filter syntax by the the supabaseAdapter file. If a filter is not yet supported by the adapter, you have to modify this file to add support for it.