Operator console
Operator console
Last updated 5/24/2026
CNBS Operator Console
Document ID: OPS-CONSOLE-001
Version: 0.1 (Spark)
System: Cannabis Business System (CNBS) — midwestco/cnbs
Audience: Platform operators, DevOps engineers, support engineers, on-call responders
Table of Contents
- System Overview
- Admin Dashboard & Routes
- Internal Tooling Inventory
- Operational Workflows
- Monitoring & Alerting
- Support Workflows
- Environment Management
- Secret Management
- Health Check Endpoints & Status
1. System Overview
CNBS is a multi-tenant Cannabis Business System built on Next.js 15 (App Router), Supabase (PostgreSQL + Realtime), and Clerk for identity management. The platform provides point-of-sale, inventory management, compliance reporting, analytics, and ecommerce capabilities for licensed cannabis dispensaries.
| Attribute | Value |
|---|---|
| Framework | Next.js 15 (App Router, Turbopack) |
| Runtime | Node.js (containerized via Docker) |
| Database | Supabase (PostgreSQL + Realtime) |
| Identity | Clerk (organization-based multi-tenancy) |
| Deployment target | Vercel (primary), Docker (self-hosted) |
| CI/CD | GitHub Actions (5 active workflows) |
| Package name | dispensary-pos v0.1.0 |
The system operates a parent–child organization hierarchy (see docs/architecture/PARENT_CHILD_ORGANIZATION_ARCHITECTURE.md). Each child organization (individual dispensary location) maps to a Clerk organization and a Supabase row-level-security tenant.
2. Admin Dashboard & Routes
2.1 Admin API Routes
All admin API routes are prefixed /api/admin/ and require elevated Clerk role verification enforced at the route handler level via /api/auth/check-role.
| Route ID | Path | Handler File | Purpose |
|---|---|---|---|
| API-001 | POST /api/admin/onboarding/complete | src/app/api/admin/onboarding/complete/route.ts | Marks an organization's onboarding workflow complete; triggers initial Clerk sync |
| API-002 | GET/POST /api/auth/check-role | src/app/api/auth/check-role/route.ts | Validates caller's Clerk role against required permission level |
| API-003 | GET /api/auth/check-user-context | src/app/api/auth/check-user-context/route.ts | Returns active org context, role, and session metadata for the authenticated user |
| API-004 | POST /api/clerk/add-to-organization | src/app/api/clerk/add-to-organization/route.ts | Adds a Clerk user to a target organization with a specified role |
| API-005 | POST /api/clerk/sync/organization | src/app/api/clerk/sync/organization/route.ts | Bidirectional sync of Clerk organization data to Supabase organizations table |
| API-006 | POST /api/clerk/sync/user | src/app/api/clerk/sync/user/route.ts | Syncs individual Clerk user record to Supabase users table |
| API-007 | POST /api/clerk/sync/customer | src/app/api/clerk/sync/customer/route.ts | Syncs customer identity record from Clerk to Supabase |
| API-008 | POST /api/clerk/sync/membership/add | src/app/api/clerk/sync/membership/add/route.ts | Adds org membership in Supabase when Clerk membership webhook fires |
| API-009 | POST /api/clerk/sync/membership/remove | src/app/api/clerk/sync/membership/remove/route.ts | Removes org membership in Supabase; does not delete the user record |
| API-010 | POST /api/clerk/sync | src/app/api/clerk/sync/route.ts | Catch-all Clerk webhook dispatcher; routes to user/org/membership sub-handlers |
| API-011 | POST /api/auth/employee | src/app/api/auth/employee/route.ts | Issues short-lived employee PIN/session tokens for POS station login |
2.2 Analytics & Reporting Routes
These routes power the internal analytics dashboards accessible to dispensary managers and CNBS operators.
| Route ID | Path | Purpose |
|---|---|---|
| API-012 | GET /api/analytics/dashboard | Aggregate dashboard KPIs (revenue, units sold, customer count) |
| API-013 | GET /api/analytics/dashboard/real-time | WebSocket-compatible real-time metrics feed via Supabase Realtime |
| API-014 | GET /api/analytics/dashboard/performance | System and transaction performance indicators |
| API-015 | GET /api/analytics/dashboard/trends | Period-over-period trend data (daily, weekly, monthly) |
| API-016 | GET /api/analytics/revenue | Revenue breakdown by product category and location |
| API-017 | GET /api/analytics/customers | Customer cohort and segmentation data |
| API-018 | GET /api/analytics/inventory | Current inventory levels, turnover rates |
| API-019 | GET /api/analytics/inventory-insights | AI-augmented inventory recommendations |
| API-020 | GET /api/analytics/predictions | ML-based demand forecasting |
| API-021 | GET /api/analytics/insights | Cross-dimensional insight aggregations |
| API-022 | GET /api/analytics/vitals | Core Web Vitals and application performance metrics |
| API-023 | GET /api/analytics/performance | Backend latency, query performance |
| API-024 | GET /api/analytics/reports | Report index listing available report types |
| API-025 | GET /api/analytics/reports/sales | Sales report with configurable date range |
| API-026 | GET /api/analytics/reports/inventory | Inventory snapshot reports |
| API-027 | GET /api/analytics/reports/compliance | Compliance audit trail reports for METRC submission |
2.3 Operational API Routes
| Route ID | Path | Handler File | Purpose |
|---|---|---|---|
| API-028 | GET/POST /api/backup | src/app/api/backup/route.ts | Triggers or retrieves database backup operations |
| API-029 | GET/POST /api/cash-drawer | src/app/api/cash-drawer/route.ts | Cash drawer open/close/count operations tied to POS sessions |
| API-030 | GET/POST /api/associates | src/app/api/associates/route.ts | List and create associate (budtender) records |
| API-031 | GET/PUT/DELETE /api/associates/:associateId | src/app/api/associates/[associateId]/route.ts | Individual associate management |
| API-032 | POST /api/careers/apply | src/app/api/careers/apply/route.ts | Career application intake; does not require auth |
2.4 Canonical Data Routes (Reference Data Management)
| Route ID | Path | Purpose |
|---|---|---|
| API-033 | GET/POST /api/canonical/brands | Manage canonical brand records shared across organizations |
| API-034 | GET/POST /api/canonical/categories | Manage canonical product category taxonomy |
| API-035 | GET/POST /api/canonical/effects | Manage canonical cannabis effects/terpene reference data |
2.5 AI Tooling Routes
These routes are used by the CMS and product management interface to generate assets.
| Route ID | Path | Handler File | Purpose |
|---|---|---|---|
| API-036 | POST /api/ai/generate-image | src/app/api/ai/generate-image/route.ts | Generates product images via OpenAI/Anthropic SDK |
| API-037 | POST /api/ai/generate-hero | src/app/api/ai/generate-hero/route.ts | Generates storefront hero section images |
| API-038 | POST /api/ai/generate-promotion | src/app/api/ai/generate-promotion/route.ts | Generates promotional copy and visuals |
| API-039 | POST /api/ai/extract-colors | src/app/api/ai/extract-colors/route.ts | Extracts brand color palette from uploaded images |
| API-040 | POST /api/ai/save-generated-image | src/app/api/ai/save-generated-image/route.ts | Persists AI-generated images to Supabase Storage |
3. Internal Tooling Inventory
3.1 Node.js Scripts (scripts/)
All scripts are invoked via npm run <script> or directly with node scripts/<name>.js.
| Tool ID | Script File | NPM Command | Purpose | Security Notes |
|---|---|---|---|---|
| TOOL-001 | scripts/detect-hook-provider-mismatches.js | npm run validate:hooks | Pre-build validation; detects React hook/provider ordering errors | Runs as prebuild hook automatically |
| TOOL-002 | scripts/scan-style-violations.js | npm run lint:style | Scans source for inline style violations against docs/STYLE_RULES.md | Read-only; safe for CI |
| TOOL-003 | scripts/build-errors-only.sh | npm run build:errors | Runs Next.js build and extracts only TypeScript errors from output | Requires bash |
| TOOL-004 | scripts/sync-clerk-data.js | npm run sync-clerk | Syncs all Clerk organizations and users to Supabase; also called by npm run db:reset | Requires CLERK_SECRET_KEY and Supabase service role key |
| TOOL-005 | scripts/test-db-setup.js | npm run db:setup / npm run db:seed | Seeds the database with test fixtures; in NODE_ENV=test seeds test-isolated data | Do not run against production |
| TOOL-006 | scripts/sync-puffutica-inventory.js | npm run sync:puffutica | Pulls inventory data from the Puffutica third-party API into Supabase products table | PR #105 open: 2 security issues flagged |
| TOOL-007 | scripts/process-product-images.js | npm run process:images | Batch-processes product image assets (resize, optimize, upload to Supabase Storage) | Requires Storage bucket write access |
| TOOL-008 | scripts/test-puffutica-api.js | npm run test:puffutica-api | Manual integration test for Puffutica API connectivity and response shape | Do not use in production pipelines — has open security PR #105 |
| TOOL-009 | scripts/setup-complete-db.js | (direct invocation) | Full database schema setup script | PR #102 closed: 6 security issues fixed |
| TOOL-010 | scripts/migrate-to-cloud.js | (direct invocation) | Migrates local Supabase schema to cloud instance | PR #103 closed: 9 security issues fixed |
3.2 Database Migration Files (database/)
These SQL files are applied manually or via Supabase CLI. They are not managed by an automated migration runner.
| File | Purpose |
|---|---|
database/local_schema.sql | Baseline schema for local development |
database/cloud_migration.sql | Schema delta for cloud (Supabase) deployment |
database/combined-migrations.sql | Consolidated migration set |
database/migrations-to-apply.sql | Pending migrations queue |
database/data_migration.sql | Data transformation migration |
database/customers_inserts.sql | Customer seed data |
database/users_inserts.sql | User seed data |
database/organizations_inserts.sql | Organization seed data |
database/locations_inserts.sql | Location seed data |
database/user_orgs_inserts.sql | User-organization junction seed data |
database/insert-all-brands.sql | Canonical brand data seed |
database/insert-products-batch1.sql | Initial product catalog seed (batch 1) |
Operational note: There is no automated migration runner present in this repository. Migrations must be applied manually via supabase db reset (development) or direct SQL execution against the target Supabase project (production). Coordinate with the database owner before applying any file from database/.
3.3 Data Export Files (data_export/)
These CSV files represent point-in-time data exports and are used for migration validation and audit purposes. They are not live data and must not be used as source-of-truth in production operations.
| File | Contents |
|---|---|
data_export/organizations.csv | Organization registry snapshot |
data_export/users.csv | User account snapshot |
data_export/customers.csv | Customer record snapshot |
data_export/products.csv | Product catalog snapshot |
data_export/brands.csv | Brand registry snapshot |
data_export/vendors.csv | Vendor registry snapshot |
data_export/locations.csv | Location data snapshot |
data_export/payment_sessions.csv | Payment session log snapshot |
data_export/request_logs.csv | API request log snapshot |
data_export/webhook_events.csv | Webhook event log snapshot |
data_export/delivery_zones.csv | Delivery zone configuration snapshot |
3.4 Data Migration Source Files (data-migration/)
Reference data used for seeding canonical cannabis product attributes.
| File | Contents |
|---|---|
data-migration/cannabis-strain-database.json | Strain names, genetics, and cannabinoid profiles |
data-migration/07_cannabis_pricing_structures.json | Tiered pricing structure definitions |
data-migration/08_cannabis_vendor_database.json | Vendor contact and product catalog data |
data-migration/09_lab_testing_database.json | Lab test result reference data |
data-migration/sample-products.json | Sample product catalog for seeding |
data-migration/sample-products.csv | CSV format of sample products |
3.5 GitHub Actions CI/CD Workflows (.github/workflows/)
| Workflow ID | File | Trigger | Purpose |
|---|---|---|---|
| TECH-001 | cannabis-pos-testing.yml | Push / PR | Runs the full POS and compliance test suite including Cypress specs |
| TECH-002 | performance-monitoring.yml | Schedule / Push | Executes tests/performance/performance-test-suite.js and reports against thresholds |
| TECH-003 | pre-commit.yml | Pre-commit hook via push | Runs validate:hooks and lint:style before merges |
| TECH-004 | test.yml | Push / PR to main & staging | Jest unit, integration, and security test suite |
| TECH-005 | visual-regression.yml | PR | Playwright visual regression baseline comparison |
3.6 Docker Infrastructure (infrastructure/docker/)
| File | Purpose |
|---|---|
infrastructure/docker/Dockerfile | Production container image definition |
infrastructure/docker/docker-compose.production.yml | Multi-service production compose configuration |
4. Operational Workflows
4.1 Deployment
CNBS supports two deployment targets: Vercel (primary) and Docker self-hosted.
Vercel Deployment
# Standard deployment via Vercel CI (triggered on merge to main)
# Build command used by Vercel:
npm run vercel-build # equivalent to: next build
# Pre-build validation runs automatically:
npm run prebuild # runs scripts/detect-hook-provider-mismatches.js
Environment variables must be set in the Vercel dashboard for the target environment. See Section 8 for the full secret inventory. The SKIP_ENV_VALIDATION=true flag is available but should never be set in production (npm run build:nolint uses it; this command is for local debugging only).
Docker Self-Hosted Deployment
# Build production image
docker build -f infrastructure/docker/Dockerfile -t cnbs:latest .
# Start all services
docker-compose -f infrastructure/docker/docker-compose.production.yml up -d
# Verify container health
docker-compose -f infrastructure/docker/docker-compose.production.yml ps
Branch Strategy
| Branch | Environment | Auto-Deploy |
|---|---|---|
main | Production | Yes (Vercel) |
staging | Staging | Yes (Vercel Preview) |
| Feature branches | Preview | Yes (Vercel Preview per PR) |
PRs from feature branches merge into staging first (see PR history: #95, #100, #101 follow the pattern feature → staging → main).
4.2 Rollback
Vercel Rollback
Navigate to the Vercel dashboard → Project → Deployments. Select the last known-good deployment and click Promote to Production. This is an instant cut-over with no downtime.
Database Rollback
There is no automated database rollback mechanism. Database changes must be reversed manually:
- Identify the migration file that introduced the regression (check
database/migrations-to-apply.sqland git history). - Write a compensating SQL statement.
- Apply to Supabase via the SQL editor in the Supabase dashboard or via
psqlwith the service role connection string. - Notify the team via the incident channel before applying any compensating migration to production.
Docker Rollback
# Tag and push a known-good image before deploying
docker tag cnbs:latest cnbs:rollback-<date>
# To rollback:
docker-compose -f infrastructure/docker/docker-compose.production.yml down
docker tag cnbs:rollback-<date> cnbs:latest
docker-compose -f infrastructure/docker/docker-compose.production.yml up -d
4.3 Feature Flags
No dedicated feature flag service (e.g., LaunchDarkly) is present in the repository. Feature gating is currently implemented at the component and API route level using environment variables and Clerk organization metadata.
Current pattern:
- Environment variable
NEXT_PUBLIC_FEATURE_<NAME>=true/falsecontrols client-side feature visibility. - Server-side gating uses Clerk's organization metadata checked via
GET /api/auth/check-user-context.
Operator procedure to enable a feature for a specific organization:
- Access Clerk Dashboard → Organizations → select target org.
- Add a metadata key matching the feature flag convention (confirm with engineering for current key names).
- Changes take effect on the next user session refresh; no deployment required.
4.4 User Management
Creating a New Dispensary Organization
- Create the organization in Clerk Dashboard or via the CNBS admin signup flow.
- Trigger organization sync:
POST /api/clerk/sync/organizationwith the Clerk org ID. - Verify the organization row appears in Supabase
organizationstable. - Complete onboarding:
POST /api/admin/onboarding/completewith the org ID.
Adding a User to an Organization
Via API:
POST /api/clerk/add-to-organization
Body: { "userId": "<clerk_user_id>", "organizationId": "<clerk_org_id>", "role": "org:admin|org:member" }
Via Script (bulk operations):
npm run sync-clerk # Re-syncs all Clerk users and org memberships to Supabase
Webhook-driven (production path):
Clerk fires organizationMembership.created → hits POST /api/clerk/sync → dispatches to POST /api/clerk/sync/membership/add.
Removing a User
POST /api/clerk/sync/membership/remove removes the Supabase membership record. The Clerk membership must be removed separately via Clerk Dashboard. User record is retained in both systems.
Employee POS Access
Budtenders access POS stations using short-lived tokens issued by POST /api/auth/employee. These tokens are scoped to the employee's associated organization and expire on session end. PINs are managed through the associate management interface (/api/associates).
4.5 Database Reset (Development Only)
# Full reset: drops and recreates local Supabase schema, then re-syncs Clerk data
npm run db:reset
# Seed only (no schema reset)
npm run db:seed
# Test environment seed
npm run db:seed:test
Never run npm run db:reset against a production Supabase project. The supabase db reset command destroys all data.
4.6 Inventory Sync (Puffutica)
# Sync Puffutica inventory to Supabase products table
npm run sync:puffutica
# Test connectivity without syncing
npm run test:puffutica-api
Current status: scripts/sync-puffutica-inventory.js has 2 open security issues (PR #105). Do not use in production until PR #105 is merged and verified.
5. Monitoring & Alerting
5.1 What Is Observed
| Signal | Source | Route/Mechanism |
|---|---|---|
| Real-time transaction metrics | Supabase Realtime + API | GET /api/analytics/dashboard/real-time |
| System performance indicators | Next.js telemetry + API | GET /api/analytics/dashboard/performance |
| Core Web Vitals | Next.js + Vercel Analytics | GET /api/analytics/vitals |
| Backend query latency | Supabase + API | GET /api/analytics/performance |
| Compliance audit events | Cypress E2E + compliance API | GET /api/analytics/reports/compliance |
| Load test results | tests/performance/performance-test-suite.js | GitHub Actions: performance-monitoring.yml |
| Real-time analytics load | __tests__/load/real-time-analytics-load.test.ts | Jest load suite |
5.2 GitHub Actions Performance Workflow
The .github/workflows/performance-monitoring.yml workflow runs tests/performance/performance-test-suite.js on a schedule and on push. Failures in this workflow indicate performance regressions. Review the workflow run output in GitHub Actions for threshold details.
The load test file __tests__/load/real-time-analytics-load.test.ts validates that the real-time analytics pipeline sustains concurrent load without degradation.
5.3 Application Performance Monitoring
The GET /api/analytics/vitals endpoint returns Core Web Vitals data. Vercel automatically captures Web Vitals when deployed to Vercel infrastructure and surfaces them in the Vercel Speed Insights dashboard.
Customer analytics performance is validated by __tests__/performance/customer-analytics-performance.test.ts. This test establishes latency baselines; review it for current threshold values.
5.4 Security Monitoring
__tests__/security/customer-data-security.test.ts— validates that customer PII is not exposed through API responses.src/__tests__/security/cms-security.test.ts— validates CMS endpoint authorization controls.tests/security/security-test-suite.js— invoked vianpm run test:security; covers authentication bypass, injection, and authorization escalation scenarios.- GDPR/CCPA compliance:
__tests__/compliance/gdpr-ccpa-compliance.test.ts
Security test runs are integrated into the main CI pipeline via .github/workflows/test.yml. Any failure blocks merge.
5.5 Alerting
No external alerting platform (PagerDuty, OpsGenie, etc.) is configured in the repository. Current alerting operates through:
- GitHub Actions failures — Workflow failures on
mainbranch should be treated as P1 and immediately routed to the on-call engineer. - Vercel deployment failure notifications — Configure in Vercel Dashboard → Notifications to route to your team's Slack/email.
- Supabase dashboard alerts — Configure database connection pool exhaustion and query timeout alerts in the Supabase project settings.
Escalation path (current):
- GitHub Actions failure notification → engineering Slack channel.
- If production is affected: open a Jira/Linear ticket (current ticket prefix:
ZP-as seen in commit history). - On-call engineer coordinates rollback per Section 4.2.
6. Support Workflows
6.1 Ticket Triage
Current tickets follow the ZP-XXXX numbering system (visible in commit messages: ZP-4305, ZP-4298, etc.). Use this prefix when filing production incidents.
Severity classification:
| Severity | Definition | Target Response |
|---|---|---|
| P1 | Production outage, payment processing failure, compliance system down | Immediate (< 15 min) |
| P2 | Analytics unavailable, user cannot log in, inventory sync failure | < 2 hours |
| P3 | UI display errors, report generation slow, non-critical feature broken | Next business day |
| P4 | Cosmetic issues, documentation gaps | Backlog |
6.2 Common Issues & Resolution Playbooks
PLAY-001: User Cannot Access Organization After Invitation
Symptom: User accepts Clerk invitation but receives authorization error in CNBS.
Root cause: Clerk membership webhook may not have fired or POST /api/clerk/sync/membership/add failed silently.
Resolution:
- Verify the user exists in Supabase
userstable. - Verify the
user_organizationsjunction record exists. - If missing, trigger manual sync:
POST /api/clerk/sync/membership/add Body: { "userId": "<clerk_id>", "organizationId": "<clerk_org_id>", "role": "org:member" } - Have the user sign out and back in to refresh their Clerk session.
- Reference: commit
22451dc(fix ZP-4298: invitation-fix).
PLAY-002: Onboarding Not Completing
Symptom: New dispensary organization stuck at onboarding step; POST /api/admin/onboarding/complete returns 4xx.
Root cause: Organization not yet synced to Supabase, or missing required fields in the org record.
Resolution:
- Verify org exists in Supabase: check the
organizationstable for the Clerk org ID. - If missing, run:
POST /api/clerk/sync/organizationwith the Clerk org ID. - Retry
POST /api/admin/onboarding/complete. - See
docs/analysis/CNBS_ADMIN_SIGNUP_ANALYSIS.mdfor the full onboarding state machine.
PLAY-003: POS Station Employee Login Failure
Symptom: Budtender cannot log in to POS station; PIN rejected or session not created.
Root cause: Employee associate record missing or POST /api/auth/employee returning an error.
Resolution:
- Verify the associate record exists:
GET /api/associatesfiltered by the employee's name/email. - If missing, create the associate:
POST /api/associates. - Re-issue POS credentials via the associate management interface.
- Check
src/components/budtender/__tests__/BudtenderHeader.test.tsxfor session token validation logic.
PLAY-004: Puffutica Inventory Sync Failure
Symptom: npm run sync:puffutica exits with error; products not updating in Supabase.
Root cause: API key rotation, network connectivity to Puffutica, or the open security issues in PR #105.
Resolution:
- Run
npm run test:puffutica-apito test raw API connectivity. - Verify
PUFFUTICA_API_KEY(or equivalent secret) is current. - Check Puffutica API status page externally.
- Do not deploy
scripts/sync-puffutica-inventory.jsto automated pipelines until PR #105 is resolved.
PLAY-005: Analytics Dashboard Returning Stale Data
Symptom: GET /api/analytics/dashboard returns data that doesn't reflect recent transactions.
Root cause: Cache staleness or Supabase Realtime subscription dropped.
Resolution:
- Check
src/__tests__/lib/cache.test.tsfor current cache TTL configuration. - Verify Supabase Realtime WebSocket connectivity: the CSP
connect-srcdirective innext.config.tsallowswss://*.supabase.co. - Check
GET /api/analytics/dashboard/real-timefor active subscriber count. - If cache is stale: trigger cache invalidation per the cache layer's API (implementation in
src/lib/cache).
PLAY-006: Build Failure Due to Hook/Provider Mismatch
Symptom: npm run build fails with React hook error; prebuild step exits non-zero.
Root cause: scripts/detect-hook-provider-mismatches.js detected a hook called outside its required provider context.
Resolution:
- Run
npm run validate:hooksto get the full error report. - Locate the component flagged and wrap it with the appropriate provider.
- See
docs/PROVIDER_PATTERNS.mdfor the canonical provider hierarchy.
PLAY-007: Logo Upload Failing in Branding Settings
Symptom: Organization logo upload returns an error; branding page shows no logo after upload.
Root cause: Supabase Storage write permissions or image processing pipeline failure.
Resolution:
- Verify
NEXT_PUBLIC_SUPABASE_URLand service role key are correct for the environment. - Run
npm run process:imagesmanually to test the image processing pipeline. - Check Supabase Storage bucket policies for the
logosbucket. - Reference: commit
bfb98f8(fix ZP-4300: upload-logo-branding).
6.3 Compliance-Specific Escalation
Cannabis compliance failures (METRC integration, purchase limit violations, waste tracking) are P1 by default and must be escalated to the compliance officer in addition to engineering. Relevant test specs:
cypress/e2e/cannabis-compliance.cy.tscypress/e2e/cannabis-purchase-limits.cy.tscypress/e2e/cannabis-transfer-manifest.cy.tscypress/e2e/cannabis-waste-tracking.cy.tscypress/e2e/metrc-package-scanning.cy.tscypress/e2e/regulatory-reporting.cy.ts
Compliance report data is available at GET /api/analytics/reports/compliance.
7. Environment Management
7.1 Environment Matrix
| Environment | Branch | Database | Clerk Instance | Purpose |
|---|---|---|---|---|
| Development | Feature branches | Local Supabase (supabase start) | Clerk dev instance | Local development |
| Staging | staging | Supabase staging project | Clerk staging instance | Pre-production validation |
| Production | main | Supabase production project | Clerk production instance | Live dispensary operations |
7.2 Development Environment Setup
# Start local Supabase instance
supabase start
# Reset database with schema and seed data
npm run db:reset
# Start Next.js development server
npm run dev
# If SSL issues with external APIs:
npm run dev:unsafe-ssl
# Debug mode with Node.js inspector:
npm run dev:debug
7.3 Environment Variables
The following environment variables are required. Values differ per environment. Set them in:
- Local:
.env.local(gitignored) - Staging/Production: Vercel Environment Variables