Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ency07/B2B-import/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks you through spinning up a fully functional local instance of B2B Import ERP — complete with a seeded multi-tenant database, RLS policies, and both demo tenant dashboards — in under 10 minutes.
SUPABASE_SERVICE_ROLE_KEY is a privileged server-side secret that bypasses Row Level Security. It is used exclusively inside Next.js Server Actions via the supabaseAdmin client. Never expose this key to the browser, include it in client-side bundles, or commit it to source control. Treat it with the same care as a root database password.

Steps

1

Clone the repository

Clone the project from GitHub and navigate into the project directory.
git clone https://github.com/ency07/B2B-import.git
cd B2B-import
2

Install dependencies

Install all Node.js dependencies using your preferred package manager.
npm install
3

Configure environment variables

Create a .env.local file in the project root and populate it with the three required Supabase credentials. All three values are available in your Supabase project dashboard under Project Settings → API.
.env.local
NEXT_PUBLIC_SUPABASE_URL=https://<your-project-ref>.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=<your-anon-public-key>
SUPABASE_SERVICE_ROLE_KEY=<your-service-role-secret-key>
VariableWhere to find itVisibility
NEXT_PUBLIC_SUPABASE_URLProject Settings → API → Project URLPublic (safe for browser)
NEXT_PUBLIC_SUPABASE_ANON_KEYProject Settings → API → anon public keyPublic (safe for browser)
SUPABASE_SERVICE_ROLE_KEYProject Settings → API → service_role secret keyServer-only — never expose
The NEXT_PUBLIC_ prefix makes the first two variables available in client-side code. The SUPABASE_SERVICE_ROLE_KEY intentionally has no such prefix — Next.js will keep it server-side only.
4

Run database migrations

All schema definitions, RLS policies, seed data, and function declarations live in the supabase/migrations/ directory. The project ships with 31 migration files covering every module from the core tenant schema through the pre-engineering wizard assistant.Option A — Supabase CLI (recommended):
supabase db push
This applies all pending migrations to your linked Supabase project in the correct order.Option B — Supabase Dashboard SQL Editor:Navigate to your project’s SQL Editor and run each file from supabase/migrations/ in ascending filename order (migrations are prefixed with a timestamp, e.g. 20260617000001_seed_master_data.sql).
Migrations must be applied in strict chronological order. Later migrations reference tables, functions, and RLS policies created by earlier ones. Skipping or reordering files will cause foreign-key or policy errors.
5

Start the development server

Launch the Next.js development server.
npm run dev
The server starts at http://localhost:3000. You should see the platform landing page for the default tenant.
6

Access the dashboard

The active tenant is selected via the tenant query parameter on every dashboard route. Navigate to either of the pre-seeded demo tenants:
http://localhost:3000/dashboard?tenant=acme
http://localhost:3000/dashboard?tenant=apex
Valid values for the tenant parameter are acme, apex, and default (which resolves to acme). Any unrecognised value also falls back to acme.
The tenant code is resolved server-side in every Server Action via the getTenantId() helper in src/app/actions.ts. It maps the short code to the full UUID used for all tenant_id database queries.

Available Test Tenants

The project ships with two fully seeded demo tenants, each with its own brand identity, product catalog, clients, quotes, invoices, and inventory records.

AeroMax Industrial

Tenant code: acmeTheme: Sky blue / industrialUUID: a0000000-0000-0000-0000-000000000000The primary reference implementation. Demonstrates the full ventilation and industrial engineering vertical, including the pre-engineering wizard, SCADA-style dashboards, and PDF diagnostic reports.

Apex Logística B2B

Tenant code: apexTheme: Green / logisticsUUID: b0000000-0000-0000-0000-000000000000A second tenant proving the white-label isolation. All brand colors, logos, and settings are independently configured. Data is completely isolated from acme at the RLS layer.

Test Scripts

The project includes a comprehensive suite of per-module test scripts you can run independently. Each script seeds data and exercises its module’s Server Actions in isolation — no shared test state.
npm run test:clients          # Client CRUD and contact management
npm run test:requirements     # Technical requirements module
npm run test:quotes           # Quote creation and line items
npm run test:approvals        # Multi-level approval workflows
npm run test:jobs             # Work order lifecycle
npm run test:inventory        # Stock, warehouses, and movements
npm run test:invoices         # Invoice creation and status transitions
npm run test:warranties       # Post-sale warranty claims
npm run test:crm              # CRM leads and pipeline
npm run test:marketing        # Marketing and website module
npm run test:dashboards       # Analytics KPIs and dashboard widgets
npm run test:white-label      # White-label branding and tenant settings
npm run test:security-audit   # RLS policies and audit log integrity
npm run test:multitenant      # Cross-tenant isolation verification
npm run test:go-live          # Full end-to-end pre-production checklist
Run npm run test:multitenant first after applying migrations — it validates that RLS policies correctly isolate acme and apex data before you test individual modules.

Build docs developers (and LLMs) love