Atomic CRM Documentation

repository·main·Indexed 20 days ago

https://github.com/marmelab/atomic-crm

An open-source CRM built with React, shadcn-admin-kit, and Supabase. It features contact management, task tracking, Kanban sales pipelines, and automated email capture. The documentation covers local installation using Make, Docker, and Node 22 LTS, testing with Jest and Playwright, and component customization via the Shadcn Registry. It also details the Agent Harness, a specialized Claude Code agent pipeline for implementing feature requests.

Tokens
38.6K
Snippets
112
Records
174
Agent score
76%

What's inside atomic-crm

  1. Overview of Admin Components capabilities

    main

    The Admin Components provide a suite of building blocks for single-page applications (SPAs). They are built on top of a modern stack including TanStack Query, React Hook Form, React Router, ra-core, Radix UI, and Shadcn UI.

    Key features provided by these components include:

    • Data Management: Data fetching, lists, data tables, rapid CRUD generation, and relationship management.
    • User Interface: Forms & validation, search & filtering, theming, i18n, loading/error management, and notifications.
    • Advanced UX: Optimistic UI, undo functionality, bulk actions, and user preferences.
    • Security: Authentication, roles, and permissions.
  2. Use CRM Builder for a sandboxed environment

    main

    The CRM Builder is a containerized, browser-based alternative to running the harness locally. It is ideal if you want to avoid local setup or security concerns.

    Key features include:

    • Containerized Environment: Run the harness without affecting your local machine.
    • Pre-installed Toolchain: No need to manually install Claude Code, Node, or Supabase.
    • Live Preview: See the CRM update in real-time as the harness applies changes.
    • Session Dashboard: Visual tracking of agent progress and activity.
    • Mode Switching: Easily toggle between Demo and Full-stack modes via the UI.
  3. Configure data providers: Supabase vs FakeRest

    main

    Atomic CRM supports two interchangeable data providers:

    • Supabase: The production-ready provider for persistent storage.
    • FakeRest: An in-browser demo provider. Note that data in FakeRest is ephemeral and resets on every page reload.
  4. Understand the Atomic CRM declarative schema model

    main

    Atomic CRM uses a declarative database schema approach. The source of truth for the database structure is located in the supabase/schemas/ directory. Migrations are auto-generated from these files.

    Important: Do not edit files in supabase/migrations/ directly unless you need to fix a specific SQL statement (e.g., changing a DROP/CREATE to an ALTER TABLE RENAME). Always ensure your changes are reflected in the supabase/schemas/ files to maintain consistency.

    | File | Contents |
    |------|----------|
    | `01_tables.sql` | Tables, foreign keys, indexes, extensions |
    | `02_functions.sql` | All PL/pgSQL functions |
    | `03_views.sql` | Views (`contacts_summary`, `companies_summary`, `activity_log`, `init_state`) |
    | `04_triggers.sql` | All triggers (public tables + auth.users) |
    | `05_policies.sql` | Row Level Security policies |
    | `06_grants.sql` | Grants and default privileges |
    | `07_storage.sql` | Storage bucket policies |
  5. Understand the core resources in Atomic CRM

    main

    Atomic CRM is built around several core business resources. When building custom views or integrations, expect to interact with:

    • contacts
    • companies
    • deals (managed via a Kanban pipeline)
    • tasks
    • notes
    • tags
    • sales (representing team members)
  6. Use database views for complex data queries

    main

    To reduce HTTP overhead and simplify frontend logic, Atomic CRM uses PostgreSQL database views to aggregate data from multiple tables.

    For example, the contact list page uses the contacts_summary view to display the number of tasks associated with each contact. This view is defined in supabase/migrations/init_db.sql.

    Note: If you are using the FakeRest data provider, these database views are emulated in the frontend layer.

  7. Understand the Starlight project structure

    main

    A Starlight project follows a specific directory structure for content and assets:

    • src/content/docs/: Place your .md or .mdx files here. Starlight automatically generates routes based on the filenames.
    • src/assets/: Store images here to embed them in Markdown using relative links.
    • public/: Place static assets like favicons here.
    • astro.config.mjs: The main configuration file for the Astro project.
    • package.json: Defines dependencies and scripts.
    .
    ├── public/
    ├── src/
    │   ├── assets/
    │   ├── content/
    │   │   └── docs/
    │   └── content.config.ts
    ├── astro.config.mjs
    ├── package.json
    └── tsconfig.json
  8. Understand user data synchronization via Triggers

    main

    Because Supabase's auth.users table cannot be modified with custom columns, Atomic CRM stores additional user details in a separate sales table.

    A database trigger is used to automatically synchronize records between these tables (e.g., syncing first_name and last_name fields) whenever a user is created or updated. The trigger implementation is located in supabase/migrations/20240730075425_init_triggers.sql.

  9. Configure domain options via CRM props

    main
    Domain-specific options such as genders, sectors, deal stages/categories, note statuses, and task types are not hardcoded. Instead, they are passed as <CRM> props in src/App.tsx. To customize the business logic or dropdown options of the CRM, you must modify these props.
  10. Understand the Atomic CRM architecture

    main

    Atomic CRM is built using a decoupled architecture consisting of a React-based Single-Page Application (SPA) for the frontend and Supabase for the backend.

    Frontend Stack:

    • Routing: React Router
    • Data Fetching & Caching: React Query
    • Form Management: React Hook Form
    • UI Components: Shadcn UI and Radix UI
    • Styling: Tailwind CSS
    • Framework Glue: Shadcn Admin Kit

    Backend Stack (Supabase):

    • Database: PostgreSQL
    • API: REST API
    • Authentication & Storage: Supabase built-in services
    • Logic: Supabase Edge Functions (used for user management and inbound email processing)
  11. Configure API Authentication headers

    main

    Atomic CRM uses two types of API keys from your Supabase project:

    1. Publishable API key: Use this for frontend or client-side code. It has limited permissions and respects Row Level Security (RLS) policies.
    2. Secret API key: Use this only on the server side. It provides full database access and should never be exposed to the client.

    All requests must include the apikey header. For protected data, you must also include the Authorization: Bearer <jwt_token> header.