A full-featured CRM built with React, shadcn/ui, and Supabase.
Update documentation
François Zaninotto46ef649c9570
diff --git a/README.md b/README.mdindex 9cf1bfce..3d9d8c64 100644--- a/README.md+++ b/README.md@@ -1,12 +1,12 @@# Atomic CRM-A full-feature CRM built with React and Supabase.+A full-feature CRM built with React and Supabase.https://user-images.githubusercontent.com/99944/116970434-4a926480-acb8-11eb-8ce2-0602c680e45e.mp4You can test it online at https://marmelab.com/react-admin-crm.-## Install Project+## InstallationTo run this project locally, you will need the following tools installed on your computer:@@ -29,18 +29,6 @@ make installThis will install the dependencies for the frontend and the backend, including a local Supabase instance.--## Developing with Atomic CRM--### Local Development Setup--1. [Supabase Configuration](./doc/developer/dev-01-supabase-configuration.md)-2. [Customizing the CRM](./doc/developer/dev-02-customizing.md)-3. [Creating Migrations](./doc/developer/dev-03-supabase-migrations.md) *(optional)*-4. [Contact Import Customization](./doc/developer/dev-04-contact-import.md) *(optional)*-5. [Using Fake Rest Data Provider for Development](./doc/developer/dev-O5-data-providers.md) *(optional)*-6. [Learn More About Architecture Decisions](./doc/developer/dev-06-architecture-choices.md) *(optional)*-Once you app is configured, start the app locally with the following command:```sh@@ -49,7 +37,7 @@ make startThis will start the Vite dev server for the frontend, the local Supabase instance for the API, and a Postgres database (thanks to Docker).-You can then access the app via [http://localhost:5173/](http://localhost:5173/).+You can then access the app via [http://localhost:5173/](http://localhost:5173/). You will be prompted to create the first user.If you need debug the backend, you can access the following services:@@ -58,13 +46,28 @@ If you need debug the backend, you can access the following services:- Attachments storage: [http://localhost:54323/project/default/storage/buckets/attachments](http://localhost:54323/project/default/storage/buckets/attachments)- Inbucket email testing service: [http://localhost:54324/](http://localhost:54324/)-### Deploying to Production+## User Documentation++1. [User Management](./doc/user/user-management.md)+2. [Importing And Exporting Data](./doc/user/import-contacts.md)+3. [Inbound Email](./doc/user/inbound-email.md)-1. [Manual Production Deploy](./doc/developer/prod-01-manual-deploy.md)-2. [GitHub Actions Configuration](./doc/developer/prod-02-github-actions.md) *(optional)*-3. [Email Inbound Configuration](./doc/developer/prod-03-email-inbound.md) *(optional)*+## Deploying to Production-### Testing+1. [Configuring Supabase](./doc/developer/supabase-configuration.md)+2. [Configuring Inbound Email](./doc/developer/inbound-email-configuration.md) *(optional)*+3. [Deployment](./doc/developer/deploy.md)++## Customizing Atomic CRM++To customize Atomic CRM, you will need TypeScript and React programming skills as there is no graphical user interface for customization. Here are some resources to assist you in getting started.++1. [Customizing the CRM](./doc/developer/customizing.md)+2. [Creating Migrations](./doc/developer/migrations.md) *(optional)*+3. [Using Fake Rest Data Provider for Development](./doc/developer/data-providers.md) *(optional)*+4. [Architecture Decisions](./doc/developer/architecture-choices.md) *(optional)*++## Testing ChangesThis project contains unit tests. Run them with the following command:@@ -72,7 +75,4 @@ This project contains unit tests. Run them with the following command:make test```-## User documentation--1. [Create First User](./doc/user/01-create-first-user.md)-2. [Import Contacts](./doc/user/02-import-contacts.md)\ No newline at end of file+You can add your own unit tests powered by Jest anywhere in the `src` directory. The test files should be named `*.test.tsx` or `*.test.ts`.diff --git a/doc/developer/architecture-choices.md b/doc/developer/architecture-choices.mdnew file mode 100644index 00000000..35ebf7c6--- /dev/null+++ b/doc/developer/architecture-choices.md@@ -0,0 +1,32 @@+# Architecture Choices++This document explains some of the architecture decisions made in the development of Atomic CRM.++## Views++Some pages in Atomic CRM require data from multiple tables. To simplify the frontend code and reduce the HTTP overhead, Atomic CRM uses database views to abstract the complexity of the queries.++For instance, the contact list page displays the number of tasks for each contact. This information is provided by the `contacts_summary` view, defined in the `supabase/migrations/init_db.sql` file.++When using [the FakeRest data provider](./data-providers.md#setting-up-the-fakerest-data-provider), these views are emulated in the frontend.++## Triggers++User credentials are stored in Supabase's `auth.users` table. Supabase does not allow to add columns tp this table. That's why additional user details are stored in a `sales` table created by Atomic CRM. A database trigger is used to automatically sync the `sales` record when a user is created or updated (e.g. for the `first_name` and `last_name` fields).++The trigger can be found in the `supabase/migrations/init_triggerssql` file.++## Edge Functions++Due to the limitations of Supabase, the API does not have a public endpoint to manage users.++To solve this problem, Atomic CRM uses a `users` edge function in charge of:++- Verifying the current user's permissions+- Creating and updating users++Atomic CRM does not support user deletion to avoid data losses. Yet, it is possible to disable a user's account (relying on Supabase's ban feature).++Atomic also uses Edge functions to handle the webhook and process the received emails. Check the [Inbound Email](./inbound-email.md) documentation for more information.++The edge functions can be found in the `supabase/functions/` directory.diff --git a/doc/developer/customizing.md b/doc/developer/customizing.mdnew file mode 100644index 00000000..1a8d1ace--- /dev/null+++ b/doc/developer/customizing.md@@ -0,0 +1,105 @@+# Customizing Atomic CRM++Developers can customize the Atomic CRM application to suit their business needs. Some of the customizations can be achieved via configuration on the `<CRM>` component, while others require changes to the source code.++## The `<CRM>` component++The entry point of the frontend application is the `src/App.tsx` file. By default, this file simply renders the `<CRM>` component, which is the root component of Atomic CRM.++```tsx+import { CRM } from './root/CRM';++const App = () => <CRM />;++export default App;+```++`<CRM>` accepts various props to customize the application domain and look and feel, so the `App.tsx` file is the best place to configure your CRM.++For instance, the following code snippet shows how to customize the CRM application title, logo, themes, and domain-specific data.++```tsx+import { CRM } from './root/CRM';+import { radiantLightTheme, radiantDarkTheme } from 'react-admin';++const App = () => (+ <CRM+ title="ACME CRM"+ logo="./img/logo.png" // The logo path is relative to the public directory+ lightTheme={radiantLightTheme}+ darkTheme={radiantDarkTheme}+ contactGender={[+ { value: 'male', label: 'He' },+ { value: 'female', label: 'She' },+ ]}+ companySectors={['Technology', 'Finance']}+ dealCategories={['Copywriting', 'Design']}+ dealPipelineStatuses={['won']}+ dealStages={[+ { value: 'opportunity', label: 'Opportunity' },+ { value: 'proposal-sent', label: 'Proposal Sent' },+ { value: 'won', label: 'Won' },+ { value: 'lost', label: 'Lost' },+ ]}+ noteStatuses={[+ { value: 'cold', label: 'Cold', color: '#7dbde8' },+ { value: 'warm', label: 'Warm', color: '#e8cb7d' },+ { value: 'hot', label: 'Hot', color: '#e88b7d' },+ ]}+ taskTypes={['Call', 'Email', 'Meeting']}+ />+);++export default App;+```++`<CRM>` accepts the following props:++| Props | Description | Type |+|-----------------------|-----------------------------------------------------------------------|-----------------|+| contactGender | The gender options for contacts used in the application. | ContactGender[] |+| companySectors | The list of company sectors used in the application. | string[] |+| darkTheme | The theme to use when the application is in dark mode. | RaThemeOptions |+| dealCategories | The categories of deals used in the application. | string[] |+| dealPipelineStatuses | The statuses of deals in the pipeline used in the application | string[] |+| dealStages | The stages of deals used in the application. | DealStage[] |+| lightTheme | The theme to use when the application is in light mode. | RaThemeOptions |+| logo | The logo used in the CRM application. | string |+| noteStatuses | The statuses of notes used in the application. | NoteStatus[] |+| taskTypes | The types of tasks used in the application. | string[] |+| title | The title of the CRM application. | string |++## Customizing The Theme++Atomic CRM uses the Material-UI library for theming. You can customize the light and dark themes by setting the `lightTheme` and `darkTheme` props on the `<CRM>` component.++Check out react-admin's [theming documentation](https://marmelab.com/react-admin/Theming.html) for more information on how to customize the themes.++## Customizing The Layout++The components that make up the layout of the application (menu, container, etc) are located in the `src/layout` directory. You can customize the layout by modifying these components.++## Customizing the Homepage++The home page of the application is rendered by the `Dashboard.tsx` component. Updating this file to customize the dashboard.++Here is a simple example of a customized dashboard:++```jsx+// ./src/dashboard/Dashboard.tsx+import React from 'react';+import { Card, CardContent, Typography } from '@mui/material';++export const Dashboard = () => (+ <Card>+ <CardContent>+ <Typography variant="h5" component="div">+ Welcome to the Custom Dashboard!+ </Typography>+ <Typography variant="body2" color="text.secondary">+ This is a customized homepage for your application. You can add any components or content here to suit your needs.+ </Typography>+ </CardContent>+ </Card>+);+```\ No newline at end of filediff --git a/doc/developer/data-providers.md b/doc/developer/data-providers.mdnew file mode 100644index 00000000..45915c83--- /dev/null+++ b/doc/developer/data-providers.md@@ -0,0 +1,34 @@+# Data Providers++By default, the CRM demo uses [Supabase](https://supabase.com) 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 A Fake API For Development++For development purposes, you can use an alternative data provider called [FakeRest](https://github.com/marmelab/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.++FakeRest is used in the [React Admin CRM demo](https://marmelab.com/react-admin-crm/), where you can test it live.++### Setting Up The FakeRest Data Provider++To set up the FakeRest data provider, you need to change the `dataProvider` import in the `src/App.tsx` file:++```diff+// in src/App.tsx+import { CRM } from './root/CRM';++ import { dataProvider, authProvider } from './providers/fakerest';++const App = () => (+ <CRM++ dataProvider={dataProvider}++ authProvider={authProvider}+ />+);++export default App;+```++### Filters Syntax++The list filters used in this project MUST follow the [`ra-data-postgrest`](https://github.com/raphiniert-com/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`](../../src/providers/fakerest/internal/supabaseAdapter.ts) file. If a filter is not yet supported by the adapter, you have to modify this file to add support for it.diff --git a/doc/developer/deploy.md b/doc/developer/deploy.mdnew file mode 100644index 00000000..a99595e0--- /dev/null+++ b/doc/developer/deploy.md@@ -0,0 +1,73 @@+# Deploying to Production Manually++## Deploying The Backend++The entire backend of Atomic CRM is hosted on Supabase. The backend is composed of a Postgres database, a REST API, and edge functions. Check out the [Supabase Configuration](./supabase-configuration.md) section for details.++After configuring your Supabase instance, you can deploy the backend changes with the following command:++```sh+make supabase-deploy+```++## Testing Production Mode++If you want to test you local frontend code using the remote Supabase instance and the production settings, you can run the following command:++```sh+make prod-start+```++Note: It will apply migrations and deploy edge functions.++You can then access the app via [`http://localhost:3000/`](http://localhost:3000/).++## Deploying The Frontend++The frontend of the CRM is a Single-Page App that can be deployed to any CDN, or to GitHub Pages.++First, build the fontend bundle with:++```sh+make build+```++This will create a `dist` directory with the built application made of static HTML, CSS, and JS files. Upload this directory to the CDN of your choice.++If you want to deploy it to GitHub pages, you can use the following command:++```sh+npm run ghpages:deploy+```++The CRM will be available at `https://<username>.github.io/atomic-crm/`.++## Deploying Updates++If you've modified the code, run the following command to deploy a new version of your CRM:++```sh+make prod-deploy+```++It will apply migrations, deploy edge functions and push the built applications to the `gh-pages` branch.++## Automating Deployments With GitHub Actions++Atomic CRM contains GitHub actions for continuous integration and delivery. To enable these actions, you will+have to create the following secrets on GitHub:++```bash+SUPABASE_ACCESS_TOKEN: Your personal access token, can be found at https://supabase.com/dashboard/account/tokens+SUPABASE_DB_PASSWORD: Your supabase database password+SUPABASE_PROJECT_ID: Your supabase project id+SUPABASE_URL: Your supabase project URL+SUPABASE_ANON_KEY: Your supabase project anonymous key+POSTMARK_WEBHOOK_USER: User configured in Postmark to secure the webhook+POSTMARK_WEBHOOK_PASSWORD: Password configured in Postmark to secure the webhook+POSTMARK_WEBHOOK_AUTHORIZED_IPS: List of IPs (comma separated) authorized to send requests to the Postmark webhook+```++> **Note:** The `POSTMARK_*` variables are required for Atomic CRM's inbound email features. Have a look at the the [inbound email configuration](./inbound-email-configuration.md) to learn more about their usage and setup.++The GitHub action will run the `prod-deploy` command on every push to the `main` branch, deplyiong the frontend to GitHub pages and updating the Supabase instance.diff --git a/doc/developer/dev-01-supabase-configuration.md b/doc/developer/dev-01-supabase-configuration.mddeleted file mode 100644index 3ebfe648..00000000--- a/doc/developer/dev-01-supabase-configuration.md+++ /dev/null@@ -1,86 +0,0 @@-# Supabase Configuration--### Creating a Remote Supabase Instance--You can create a remote Supabase using the following script:--```sh-make supabase-remote-init-```--The script will ask you for the Supabase instance name, create the database, apply the migrations and deploy the edge functions. Finally, it will create a `.env.production.local` file with your remote Supabase configuration.--### Alternative: Using An Existing Supabase Instance--If you already created a Supabase instance for Atomic CRM, you can link the instance manually as follows.--First, log into your Supabase account:--```sh-npx supabase login-```--Now, link this project to the local Supabase instance. You'll be asked to enter the database password.--```sh-npx supabase link --project-ref ********************-```--Then, apply the migrations on it:--```sh-npx supabase db push-npx supabase functions deploy-```--Finally, add a `.env.production.local` file in the root directory with your remote Supabase credentials:--```sh-VITE_SUPABASE_URL=<instance_url>-VITE_SUPABASE_ANON_KEY=<instance_anon_token>-```--## Testing Production Mode--Before deploying the frontend code to production, you should test the local frontend code when connected to the remote Supabase instance.--To do so, call the following command:--```sh-make prod-start-```--Using a remote Supabase instance can be interesting if you deploy from your computer, or if you want to test your app with production data in production mode.--## Login Callback--### Local Supabase Instance--Go to your [local supabase config](../../supabase/config.toml) file:-1. In `[auth]` section set `site_url` to your application URL-2. In `[auth]`, add the following URL in the `additional_redirect_urls = [<APPLICATION_URL>/auth-callback.html"]`--### Remote Supabase Instance--To configure the authentication URL, you can go to your project dashboard at [supabase.com](https://supabase.com/). Then go to **Authentication** > **URL Configuration**. You can set up you callback URL in the **Site URL** field.--## Customizing Mail Template--### Local Instance Templates--You can customize the mail templates via the [supabase config](../../supabase/config.toml) file. An example of a custom template has been done for the [recovery](../../supabase/templates/recovery.html) email.--Note: updating the templates requires to restart your supabase instance.--If you want more information on how to customize email templates, go to the [related supabase documentation](https://supabase.com/docs/guides/cli/customizing-email-templates).--### Linked Instance Templates--If you want to customize the production templates, you can go to your project dashboard at [supabase.com](https://supabase.com/). Then go to **Authentication** > **Email Templates**. You can the choose which template to change using the email template stabs.--## Fequently Asked Questions--- I have a **Security Definer View** error in **Security Advisor**--You can ignore this error. This warning informs you that the `init_state` state view is public and can be called by everybody.-This view is required to test if your CRM has been setup correctly. This view has been configured to avoid data leak.\ No newline at end of filediff --git a/doc/developer/dev-02-customizing.md b/doc/developer/dev-02-customizing.mddeleted file mode 100644index 3a09aab8..00000000--- a/doc/developer/dev-02-customizing.md+++ /dev/null@@ -1,121 +0,0 @@-# Customizing Atomic CRM--## CRM component--You can customize the title, logo, theme, and domain of the CRM app by passing custom props to the `<CRM>` component:--```tsx-// App.tsx-import React from 'react';-import CRM from './CRM';--const App = () => (- <CRM- title="Custom CRM Title"- logo="custom-logo.png"- />-);--export default App;-```--## Domain & Process--In addition to the design, you can easily customize various aspects relevant to your business domain. The behavior is the same as described above. You can modify the following:--| Props | Description | Type |-|-----------------------|-----------------------------------------------------------------------|-----------------|-| contactGender | The gender options for contacts used in the application. | ContactGender[] |-| companySectors | The list of company sectors used in the application. | string[] |-| darkTheme | The theme to use when the application is in dark mode. | RaThemeOptions |-| dealCategories | The categories of deals used in the application. | string[] |-| dealPipelineStatuses | The statuses of deals in the pipeline used in the application | string[] |-| dealStages | The stages of deals used in the application. | DealStage[] |-| lightTheme | The theme to use when the application is in light mode. | RaThemeOptions |-| logo | The logo used in the CRM application. | string |-| noteStatuses | The statuses of notes used in the application. | NoteStatus[] |-| taskTypes | The types of tasks used in the application. | string[] |-| title | The title of the CRM application. | string |--```tsx-import { CRM } from './root/CRM';-import { ThemeOptions } from '@mui/material/styles';--const lightTheme: ThemeOptions = {- palette: {- mode: 'light',- },-};--const darkTheme: ThemeOptions = {- palette: {- mode: 'dark',- },-};--const App = () => {- return (- <CRM- contactGender={[- { value: 'male', label: 'He' },- { value: 'female', label: 'She' },- ]}- companySectors={['Technology', 'Finance']}- darkTheme={darkTheme}- dealCategories={['Copywriting', 'Design']}- dealPipelineStatuses={['won']}- dealStages={[- { value: 'opportunity', label: 'Opportunity' },- { value: 'proposal-sent', label: 'Proposal Sent' },- { value: 'won', label: 'Won' },- { value: 'lost', label: 'Lost' },- ]}- lightTheme={lightTheme}- logo="https://example.com/logo.png"- noteStatuses={[- { value: 'cold', label: 'Cold', color: '#7dbde8' },- { value: 'warm', label: 'Warm', color: '#e8cb7d' },- { value: 'hot', label: 'Hot', color: '#e88b7d' },- ]}- taskTypes={['Call', 'Email', 'Meeting']}- title="CRM Dashboard"- />- );-};--export default App;-```--## Adding Sales--To add a new sale to the CRM, you need to use an administrator account. By default, the first account created has this role. If you are starting fresh, a sign-up page will prompt you to create this admin account.--When logged in as an admin, an 'Account Manager' tab will be available. From this page, you can create sales and transfer the administrator role.-----## Customizing the Homepage--The first page of the application is managed by the `Dashboard.tsx` component. You can customize it by updating this file.--```jsx-// ./src/dashboard/Dashboard.tsx-import React from 'react';-import { Card, CardContent, Typography } from '@mui/material';--export const Dashboard = () => {- return (- <Card>- <CardContent>- <Typography variant="h5" component="div">- Welcome to the Custom Dashboard!- </Typography>- <Typography variant="body2" color="text.secondary">- This is a customized homepage for your application. You can add any components or content here to suit your needs.- </Typography>- </CardContent>- </Card>- );-};-```\ No newline at end of filediff --git a/doc/developer/dev-03-supabase-migrations.md b/doc/developer/dev-03-supabase-migrations.mddeleted file mode 100644index d1fe43c4..00000000--- a/doc/developer/dev-03-supabase-migrations.md+++ /dev/null@@ -1,18 +0,0 @@-# Supabase Migrations--You can create a new migration using the following command:-```sh-npx supabase migration new <migration_name>-```--You can apply the migrations using the following command:-```sh-npx supabase migration up-```--But you can also apply changes in the database directly using the supabase Dashboard.-Create a new migration using the following command:-```sh-npx supabase db diff | npx supabase migration new <migration_name>-```-diff --git a/doc/developer/dev-04-contact-import.md b/doc/developer/dev-04-contact-import.mddeleted file mode 100644index 8d89bce1..00000000--- a/doc/developer/dev-04-contact-import.md+++ /dev/null@@ -1,6 +0,0 @@-# Contact Import--From the crm, a user can import a list of contacts via a csv file. This csv file must match the data you use to store your contacts.-By default, we provide a sample file located at `src/contacts/contacts_export.csv`.--If you change your data structure for a contact, don't forget to modify this sample. You'll also need to modify the import function found in `src/contacts/useContactImport.tsx`diff --git a/doc/developer/dev-05-data-providers.md b/doc/developer/dev-05-data-providers.mddeleted file mode 100644index 9ced36c2..00000000--- a/doc/developer/dev-05-data-providers.md+++ /dev/null@@ -1,20 +0,0 @@-# Data Providers--This project supports two data providers:-- A [supabase data provider](../../src/providers/supabase/) (default)-- A [fakerest data provider](../../src/providers/fakerest/)--## Supabase Data Provider--This is the default data provider for the CRM demo. For local development, it binds to a local supabase instance.--## FakeRest Data provider--This data provider is used in the [React Admin CRM demo](https://marmelab.com/react-admin-crm/) and can also be used to test-local development with generated data.--## Filters--The list filters used in this project MUST follow the [`ra-data-postgrest`](https://github.com/raphiniert-com/ra-data-postgrest) convention. The filters are then mapped at runtime to the fakerest filters.--If a filter is not supported by the transformer, you can add new filter adapters in the [`supabaseAdapter` ](../../src/providers/fakerest/internal/supabaseAdapter.ts) file.diff --git a/doc/developer/dev-06-architecture-choices.md b/doc/developer/dev-06-architecture-choices.mddeleted file mode 100644index 7dc6cb37..00000000--- a/doc/developer/dev-06-architecture-choices.md+++ /dev/null@@ -1,17 +0,0 @@-# Architecture Choices--This document explains some of the architecture choices we made.--## Sales table--Sales are related to user accounts and add extra information to supabase's `auth.users` table.--They are automatically created or updated with supabase's `user` metadata (`first_name` and `last_name` are required when creating a new user) via a trigger.--## User Management--Due to the limitations of supabase, we do not have a public endpoint to manage users. To solve this problem, we created a `users` edge function that is in charge of:-- Verifying current user's permissions-- Creation and update of users--Note: We do not support user deletion to avoid data losses. Yet, it is possible to disable a user's account (relying on supabase ban feature).diff --git a/doc/developer/prod-03-email-inbound.md b/doc/developer/inbound-email-configuration.mdsimilarity index 62%rename from doc/developer/prod-03-email-inbound.mdrename to doc/developer/inbound-email-configuration.mdindex 15dd5f84..63353c72 100644--- a/doc/developer/prod-03-email-inbound.md+++ b/doc/developer/inbound-email-configuration.md@@ -1,10 +1,12 @@-# Email Features+# Inbound Email Configuration-## Setup+Atomic CRM can receive inbound emails and automatically create or update contacts based on the email content. This feature is useful to keep your CRM up-to-date with the latest interactions with your contacts.-### Postmark+Atomic CRM uses [Postmark](https://postmarkapp.com/) to receive and process inbound emails.-Atomic CRM uses [Postmark](https://postmarkapp.com/) to receive inbound emails. You can use an existing Postmark account or [create a new one](https://account.postmarkapp.com/sign_up). The free tier allows you to send or receive up to 100 emails per month.+## Postmark Setup++You can use an existing Postmark account or [create a new one](https://account.postmarkapp.com/sign_up). The free tier allows you to send or receive up to 100 emails per month.To enable inbound email features, you need to create a webhook in Postmark.@@ -22,11 +24,11 @@ To enable inbound email features, you need to create a webhook in Postmark.> **Note**: The server’s inbound email address can be customized by registering a domain to your Postmark account.-### Supabase+## Supabase SetupAtomic CRM uses a Supabase Edge Function to handle the webhook and process the received emails. You need to configure your Supabase project to handle the incoming requests.-In a terminal, after you have [linked your Supabase project](./dev-01-supabase-configuration.md#using-an-existing-remote-supabase-instance), run the following commands:+In a terminal, after [linking your Supabase project](./dev-01-supabase-configuration.md#using-an-existing-remote-supabase-instance), run the following commands:```shnpx supabase secrets set POSTMARK_WEBHOOK_USER=<user>@@ -46,35 +48,12 @@ POSTMARK_WEBHOOK_PASSWORD=<password>POSTMARK_WEBHOOK_AUTHORIZED_IPS=<comma-separated list of IPs>```-## Usage--Once you have set up Postmark and Supabase, you can start sending emails to your server's inbound email address, e.g. by adding it to the **Cc:** field. Atomic CRM will process the emails and add notes to the corresponding contacts.--Atomic CRM uses the sender's email address to identify the sales member, and the recipient's email address to identify the contact. If the contact does not yet exist, Atomic CRM will create it for you, using the email's domain as company name.+## Application Configuration-Example email+Store the Postmark inbound email address in a `.env` file at the root of the project, so that users can easily find it in the application.-```-From: Jane Doe <[email protected]>-To: Kim Hegmann <[email protected]>-Cc: [email protected]-Subject: Meeting with Kim Hegmann--Hi Kim,-I would like to schedule a meeting with you next week. Please let me know your availability.-```--When receiving this email, Atomic CRM will:-- Create the _Acme_ company if it does not exist-- Create the _Kim Hegmann_ contact if it does not exist-- Associate both to _Jane Doe_-- Add a note to the _Kim Hegmann_ contact with the following content--```-Meeting with Kim Hegmann--Hi Kim,-I would like to schedule a meeting with you next week. Please let me know your availability.+```sh```## Testing locallydiff --git a/doc/developer/migrations.md b/doc/developer/migrations.mdnew file mode 100644index 00000000..9b21ea57--- /dev/null+++ b/doc/developer/migrations.md@@ -0,0 +1,47 @@+# Creating Migrations++While customizing the CRM, you will probably need to update the database schema. You can do this using [Supabase migrations](https://supabase.com/docs/reference/cli/supabase-migration-new).++## Creating Migrations Locally++You can create a new migration locally using the following command:++```sh+npx supabase migration new <migration_name>+```++This will create a new migration file in the `supabase/migrations` directory. You can then update this file with the necessary changes to the database schema.++Then, apply the migrations locally using the following command:++```sh+npx supabase migration up+```++When you are ready to apply the migrations to the remote Supabase instance, push the migrations using the following command:++```sh+npx supabase db push+```++## Alternative: Creating Migrations Remotely++You can also change the schema using the Supabase Dashboard.++When it's done, generate a new migration file based on the new schema using the following command:++```sh+npx supabase db diff | npx supabase migration new <migration_name>+```++Then, apply the migrations locally using the following command:++```sh+npx supabase migration up+```++## Updating The Import Feature++From the frontend UI, users can import contacts and companies via a csv file.++If you change the data structure for a contact, don't forget to modify the sample CSV file located at `src/contacts/contacts_export.csv`. You'll also need to modify the import function found in `src/contacts/useContactImport.tsx`.diff --git a/doc/developer/prod-01-manual-deploy.md b/doc/developer/prod-01-manual-deploy.mddeleted file mode 100644index c48f1668..00000000--- a/doc/developer/prod-01-manual-deploy.md+++ /dev/null@@ -1,45 +0,0 @@-# Deploying Manually to Production--## Supabase Configuration--This guide assumes you have already configured your Supabase instance. Id you did not, please have a look at the [dedicated configuration guide](./dev-01-supabase-configuration.md).--## Testing Production Mode--If you want to test you code locally using production mode and the remote Supabase instance, you can run the following command:--```sh-make prod-start-```--Note: It will apply migrations and deploy edge functions.--You can then access the app via [`http://localhost:3000/`](http://localhost:3000/).--## Deploying The Frontend--The frontend of the CRM is a Single-Page App that can be deployed to any CDN, or to GitHub Pages.--First, build the fontend bundle with:--```sh-make build-```--This will create a `dist` directory with the built application made of static HTML, CSS, and JS files.--Then, upload this directory to the CDN of your choice. If you want to deploy it to the `gh-pages` branch of the your repository, you can use the following command:--```sh-npm run ghpages:deploy-```--## Deploying Updates--If you've modified the code, run the following command to deploy a new version of your CRM:--```sh-make prod-deploy-```--It will apply migrations, deploy edge functions and push the built applications to the `gh-pages` branch.diff --git a/doc/developer/prod-02-github-actions.md b/doc/developer/prod-02-github-actions.mddeleted file mode 100644index 39bf9a35..00000000--- a/doc/developer/prod-02-github-actions.md+++ /dev/null@@ -1,44 +0,0 @@-# GitHub Actions--## Configuration--This project supports github actions for continuous integration and delivery. To enable GitHub actions on this repo, you will-have to create the following secrets:--```bash-SUPABASE_ACCESS_TOKEN: Your personal access token, can be found at https://supabase.com/dashboard/account/tokens-SUPABASE_DB_PASSWORD: Your supabase database password-SUPABASE_PROJECT_ID: Your supabase project id-SUPABASE_URL: Your supabase project URL-SUPABASE_ANON_KEY: Your supabase project anonymous key-POSTMARK_WEBHOOK_USER: User configured in Postmark to secure the webhook-POSTMARK_WEBHOOK_PASSWORD: Password configured in Postmark to secure the webhook-POSTMARK_WEBHOOK_AUTHORIZED_IPS: List of IPs (comma separated) authorized to send requests to the Postmark webhook-```--> **Note:** The `POSTMARK_*` variables are required for Atomic CRM's email features. Have a look at the the [email features documentation](./email-features.md) to learn more about their usage and setup.--## Deploying to Another Repository--If you want to deploy the static website to another repository, you must first generete a personal access token [in the GitHub settings](https://github.com/settings/tokens?type=beta):--- Give a name to the token-- Set token expiration-- Select `Only select repositories`, and select the target repository-- On the repository permissions, select "Write Access" under "Contents"--Then you can configure the following GitHub action variable on you repository:-```bash-DEPLOY_REPOSITORY=<org>/<repository>-```--And finally, you must create the following GitHub Action secret:--```bash-DEPLOY_TOKEN=<personal_access_token>-```--You can also configure the deploy branch using-```bash-DEPLOY_BRANCH=main # Defaults to `gh-pages`-```diff --git a/doc/developer/supabase-configuration.md b/doc/developer/supabase-configuration.mdnew file mode 100644index 00000000..9fa93425--- /dev/null+++ b/doc/developer/supabase-configuration.md@@ -0,0 +1,92 @@+# Configuring Supabase++Atomic CRM uses Supabase as a backend. This document explains how to configure a remote Supabase instance hosted at [supabase.com](https://supabase.com/).++## Creating a Remote Supabase Instance++Atomic CRM comes with a CLI utility to create a backend instance on [supabase.com](https://supabase.com/):++```sh+make supabase-remote-init+```++The script will ask you for the Supabase instance name, create the database, apply the migrations and deploy the edge functions. Finally, it will create a `.env.production.local` file with your remote Supabase configuration.++## Alternative: Using An Existing Supabase Instance++If you already created a project on [supabase.com](https://supabase.com/), you can configure the Atomic CRM frontend to use it.++First, log into your Supabase account:++```sh+npx supabase login+```++Now, link the local project to the Supabase instance. You'll be asked to enter the database password.++```sh+npx supabase link --project-ref ********************+```++Then, apply the migrations and deploy the edge functions:++```sh+npx supabase db push+npx supabase functions deploy+```++Finally, add a `.env.production.local` file in the root directory with your remote Supabase credentials:++```sh+VITE_SUPABASE_URL=<instance_url>+VITE_SUPABASE_ANON_KEY=<instance_anon_token>+```++## Testing Production Mode++Before deploying the frontend code to production, you may want to test the local frontend code when connected to the remote Supabase instance.++To do so, call the following command:++```sh+make prod-start+```++Using a remote Supabase instance can be interesting if you deploy from your computer, or if you want to test your app with production data in production mode.++## Setting The Login Callback++Atomic CRM uses Supabase's authentication system. When a user logs in, Supabase redirects them to an authentication callback URL that is handled by the frontend.++When developing with a local Supabase instance, the callback URL is already configured--you don't need to do anything.++When using a remote Supabase instance, you need to configure the callback URL as follows:++1. Go to the project dashboard at [supabase.com](https://supabase.com/).+2. Go to **Authentication** > **URL Configuration**.+3. Set up the callback URL of the production frontend in the **Site URL** field.++If you host Atomic CRM under the `https://example.com/atomic-crm/` URL, the callback URL should be `https://example.com/atomic-crm/auth-callback.html`.++## Customizing Email Templates++Atomic CRM uses Supabase to send authentication-related emails (confirm signup, reset password, etc).++When developing with a local Supabase instance, you test your custom mail templates via the [supabase TOML config](../../supabase/config.toml) file. An example of a custom template has been done for the [recovery](../../supabase/templates/recovery.html) email. Note that you will need to restart your supabase instance to apply the changes.++When using a remote Supabase instance, you can configure the email templates as follows:++1. Go to the project dashboard at [supabase.com](https://supabase.com/).+2. Go to **Authentication** > **Email Templates**.+3. Choose the template you want to change using the email template tabs.+4. Paste the template source code in the editor and save.++If you want more information on how to customize email templates, check the [Customizing Email Templates](https://supabase.com/docs/guides/cli/customizing-email-templates) documentation.++## Frequently Asked Questions++**I have a *Security Definer View* error in *Security Advisor***++This warning informs you that the `init_state` state view is public and can be called by everybody.++This view is required to test if the CRM has been setup correctly. It doesn't expose any data, so you can ignore the Security Advisor error.diff --git a/doc/user/01-create-first-user.md b/doc/user/01-create-first-user.mddeleted file mode 100644index c543ebb8..00000000--- a/doc/user/01-create-first-user.md+++ /dev/null@@ -1,7 +0,0 @@-# Create the First User--The first time a user will open the Atomic CRM App, they will be prompted to create the first user. The user will automatically be granted administrator role.--https://github.com/user-attachments/assets/1969c422-d280-4139-bac9-e4d91d65eda3--Note: If the app is connected to the production database, the user will need to validate their account by mail.\ No newline at end of filediff --git a/doc/user/02-import-contacts.md b/doc/user/02-import-contacts.mddeleted file mode 100644index bb052b5d..00000000--- a/doc/user/02-import-contacts.md+++ /dev/null@@ -1,11 +0,0 @@-# Import Contacts--Atomic CRM supports contact bulk import. An example of the expected CSV file is available in the contact import modal.--The button to bulk import contact is available:-- On the dashboard if no contact has been imported yet, or there is no note added to any contact-- On the contact list page--When importing contacts, companies and tags will be automatically matched if they exist on the system, or imported ortherwise.--https://github.com/user-attachments/assets/278a1969-b67f-4128-b75f-23e1b6ac1090\ No newline at end of filediff --git a/doc/user/import-contacts.md b/doc/user/import-contacts.mdnew file mode 100644index 00000000..badc8961--- /dev/null+++ b/doc/user/import-contacts.md@@ -0,0 +1,24 @@+# Importing And Exporting Data++## Importing Data++You can import contacts and companies from a CSV file, e.g. to migrate from another CRM.++https://github.com/user-attachments/assets/278a1969-b67f-4128-b75f-23e1b6ac1090++Atomic CRM displays an import contact buttons in the initial user onboarding page, and in the contacts page.++An example of the expected CSV file is available in the contact import modal:++```csv+first_name,last_name,gender,title,company,email,phone_1_number,phone_1_type,phone_2_number,phone_2_type,background,first_seen,last_seen,has_newsletter,status,tags,linkedin_url+John,Doe,male,Sales Executive,Acme,[email protected],659-980-2015,work,740.645.3807,home,,2024-07-01,2024-07-01T11:54:49.950Z,FALSE,in-contract,"influencer, developer",https://www.linkedin.com/in/johndoe+Jane,Doe,female,Designer,Acme,[email protected],659-980-2020,work,740.647.3802,home,,2024-07-01,2024-07-01T11:54:49.950Z,FALSE,in-contract,"UI, design",https://www.linkedin.com/in/janedoe+Camille,Brown,nonbinary,Accountant,Atomic Corp,[email protected],659-910-3010,work,740.698.3752,home,,2024-07-01,2024-07-01T11:54:49.950Z,FALSE,in-contract,"payroll, accountant",,+```++When importing contacts, companies and tags will be automatically matched if they exist on the system, or imported ortherwise.++## Exporting Data++In the contacts and companies pages, an export button allows to download the list of contacts or companies in CSV format.diff --git a/doc/user/inbound-email.md b/doc/user/inbound-email.mdnew file mode 100644index 00000000..b6000f63--- /dev/null+++ b/doc/user/inbound-email.md@@ -0,0 +1,43 @@+# Inbound Email++Atomic CRM can receive inbound emails and automatically create or update contacts based on the email content. This feature is useful to keep your CRM up-to-date with the latest interactions with your contacts.++## Setup++You must setup Postmark and Supabase to use the inbound email feature. Check the [Inbound Email Setup](./developer/inbound-email.md) documentation for more information.++## Usage++Send of forward emails to Atomic CRM's inbound email address to automatically add notes to the corresponding contacts. You can find this email address in the user menu by clicking on the "My Info" menu item, in the "Inbound Email" section. It looks like `[email protected]`.++Atomic CRM uses the sender's email address to identify the user member, and the recipient's email address to identify the contact. If the contact does not yet exist, Atomic CRM creates it using the email's domain as company name.++**Tip**: Use the **Bcc** field to send emails to Atomic CRM without notifying the recipients.++## Example++Consider the following email:++```txt+From: Jane Doe <[email protected]>+To: Kim Hegmann <[email protected]>+Cc: [email protected]+Subject: Meeting with Kim Hegmann++Hi Kim,+I would like to schedule a meeting with you next week. Please let me know your availability.+```++When receiving this email, Atomic CRM will:++- Create the _Acme_ company if it does not exist+- Create the _Kim Hegmann_ contact if it does not exist+- Associate both to _Jane Doe_+- Add a note to the _Kim Hegmann_ contact with the following content:++```txt+Meeting with Kim Hegmann++Hi Kim,+I would like to schedule a meeting with you next week. Please let me know your availability.+```diff --git a/doc/user/user-management.md b/doc/user/user-management.mdnew file mode 100644index 00000000..05b5e37a--- /dev/null+++ b/doc/user/user-management.md@@ -0,0 +1,15 @@+# User Management++## Creating the First User++The first time you open the Atomic CRM App, you will be prompted to create the first user. This first user user will automatically be granted administrator role.++https://github.com/user-attachments/assets/1969c422-d280-4139-bac9-e4d91d65eda3++Note: If the application is connected to the production database, the first user will need to validate their account by mail.++## Adding Users++Any user with the administrator role can create new users. To do this, click on the avatar in the top right corner and select 'Users'. From this page, you can add new users, edit existing users, and delete users.++\ No newline at end of filediff --git a/public/img/adding-sales.png b/public/img/adding-sales.pngdeleted file mode 100644index b4b91444..00000000Binary files a/public/img/adding-sales.png and /dev/null differdiff --git a/public/img/adding-users.png b/public/img/adding-users.pngnew file mode 100644index 00000000..49b9e8f6Binary files /dev/null and b/public/img/adding-users.png differdiff --git a/src/App.tsx b/src/App.tsxindex 25c7d55e..728df5c6 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -1,26 +1,30 @@import { CRM } from './root/CRM';-import {- defaultCompanySectors,- defaultContactGender,- defaultDealCategories,- defaultDealStages,- defaultLogo,- defaultNoteStatuses,- defaultTaskTypes,- defaultTitle,-} from './root/defaultConfiguration';-const App = () => (- <CRM- contactGender={defaultContactGender}- companySectors={defaultCompanySectors}- dealCategories={defaultDealCategories}- dealStages={defaultDealStages}- logo={defaultLogo}- noteStatuses={defaultNoteStatuses}- taskTypes={defaultTaskTypes}- title={defaultTitle}- />-);+/**+ * Application entry point+ *+ * Customize Atomic CRM by passing props to the CRM component:+ * - contactGender+ * - companySectors+ * - darkTheme+ * - dealCategories+ * - dealPipelineStatuses+ * - dealStages+ * - lightTheme+ * - logo+ * - noteStatuses+ * - taskTypes+ * - title+ * ... as well as all the props accepted by react-admin's <Admin> component.+ *+ * @example+ * const App = () => (+ * <CRM+ * logo="./img/logo.png"+ * title="Acme CRM"+ * />+ * );+ */+const App = () => <CRM />;export default App;diff --git a/src/Header.tsx b/src/layout/Header.tsxsimilarity index 98%rename from src/Header.tsxrename to src/layout/Header.tsxindex 31d83e5f..79c99355 100644--- a/src/Header.tsx+++ b/src/layout/Header.tsx@@ -19,7 +19,7 @@ import {useUserMenu,} from 'react-admin';import { Link, matchPath, useLocation } from 'react-router-dom';-import { useConfigurationContext } from './root/ConfigurationContext';+import { useConfigurationContext } from '../root/ConfigurationContext';const Header = () => {const { logo, title } = useConfigurationContext();diff --git a/src/Layout.tsx b/src/layout/Layout.tsxsimilarity index 93%rename from src/Layout.tsxrename to src/layout/Layout.tsxindex dc322b17..ceb28c36 100644--- a/src/Layout.tsx+++ b/src/layout/Layout.tsx@@ -1,4 +1,4 @@-import React, { Suspense, ReactNode } from 'react';+import { Suspense, ReactNode } from 'react';import { CssBaseline, Container } from '@mui/material';import { CheckForApplicationUpdate } from 'react-admin';import { ErrorBoundary } from 'react-error-boundary';diff --git a/src/root/CRM.tsx b/src/root/CRM.tsxindex 7a2f935f..6a8a7872 100644--- a/src/root/CRM.tsx+++ b/src/root/CRM.tsx@@ -8,12 +8,17 @@ import {localStorageStore,mergeTranslations,} from 'react-admin';-import { deepmerge } from '@mui/utils';import polyglotI18nProvider from 'ra-i18n-polyglot';import englishMessages from 'ra-language-english';import { Route } from 'react-router';-import Layout from '../Layout';+import {+ ForgotPasswordPage,+ SetPasswordPage,+ raSupabaseEnglishMessages,+} from 'ra-supabase';++import Layout from '../layout/Layout';import companies from '../companies';import contacts from '../contacts';import { Dashboard } from '../dashboard/Dashboard';@@ -39,12 +44,6 @@ import {defaultTitle,} from './defaultConfiguration';-import {- ForgotPasswordPage,- SetPasswordPage,- raSupabaseEnglishMessages,-} from 'ra-supabase';-// Define the interface for the CRM component propstype CRMProps = {lightTheme?: RaThemeOptions;