Technology Stack
Relevant source files
The following files were used as context for generating this wiki page:
DRX CRM utilizes a modern, modular technology stack designed for retail dispensaries and small businesses. The architecture emphasizes a "privacy-first" approach, utilizing local-first data principles alongside robust cloud synchronization for multi-business support. The stack is strictly governed by a "Modular Stack" policy that prohibits direct vendor SDK imports in favor of standardized interfaces.
The platform is built as a full-stack application using Next.js 16 and TypeScript, leveraging a Backend-as-a-Service (BaaS) model initially centered on Supabase, with ongoing migrations toward a more diversified infrastructure including Clerk for authentication and Prisma ORM for database management.
Sources: README.md:3-9, README.md:21-25, CHANGELOG.md:12-14, CHANGELOG.md:25-30
Frontend Architecture
The frontend is built on the Next.js 16 App Router framework, utilizing React 19 for component management. It follows a utility-first styling approach and uses a set of high-quality UI primitives to ensure a consistent, mobile-optimized experience.
Core Frontend Components
- Next.js 16 (App Router): Serves as the primary framework for routing and server-side rendering.
- TypeScript: Ensures type safety across the entire application.
- Tailwind CSS & Shadcn/ui: Used for styling and accessible UI components.
- Framer Motion: Provides animations, specifically for mobile navigation.
- Lucide React: The standard icon library for the interface.
Sources: README.md:35-42, package.json:59-65, CHANGELOG.md:123-125
Frontend Data Flow
The following diagram illustrates how the frontend interacts with server-side components via Next.js Server Actions and API routes.
This diagram shows the interaction between the User Interface and the backend services via Server Actions and standardized API routes.
Sources: README.md:52-53, CHANGELOG.md:25-36
Backend & Infrastructure
The DRX CRM backend is currently in a transition phase, moving from a tightly-coupled Supabase implementation to a modular architecture using Prisma ORM and specialized providers for Auth and Storage.
Backend Evolution
| Component | Legacy | Current / Migrating To |
|---|---|---|
| Authentication | Supabase Auth | Clerk |
| Database Access | supabase-js | Prisma ORM |
| Storage | Supabase Storage | Cloudflare R2 / AWS S3 |
| Database | PostgreSQL | Neon / Doppler (PostgreSQL) |
Sources: README.md:46-51, CHANGELOG.md:25-45, package.json:34-39
Database Schema and ORM
The system uses PostgreSQL as its primary data store. Prisma ORM is utilized to manage multi-tenancy through businessId checks, ensuring strict tenant isolation. Key tables include business_profile, inventory, sales, and user_roles.
Sources: README.md:104-112, CHANGELOG.md:31-34, testsprite_tests/standard_prd.json:44-50
Security & Compliance
Security is enforced through a multi-layered approach involving both database-level policies and application-level role hierarchies.
Security Implementation
- Row Level Security (RLS): Enforced on all PostgreSQL tables to prevent unauthorized data access between tenants.
- Role-Based Access Control (RBAC): Granular permissions defining roles such as Super Admin, Manager, Supervisor, and Cashier.
- Audit Logging: Immutable system audit trails capture sensitive actions like price overrides, inventory changes, and voids.
- PII Masking: Support for Right-to-be-Forgotten (RTBF) requests via a dedicated API to mask Personally Identifiable Information.
Sources: README.md:175-181, testsprite_tests/standard_prd.json:15-22, testsprite_tests/standard_prd.json:107-111
This sequence diagram demonstrates the multi-layered security check involving application roles and database-level RLS.
Sources: README.md:46-51, testsprite_tests/standard_prd.json:52-58, CHANGELOG.md:118-120
Development & DevOps
The project employs strict versioning and pre-commit protocols to maintain code quality and stack integrity.
Tooling and Automation
- Package Manager:
pnpmfor efficient dependency management. - Testing: Vitest for unit/integration testing and Playwright for End-to-End (E2E) testing.
- Monitoring: Sentry for error tracking and PostHog for product analytics.
- Versioning: A custom TypeScript script (
scripts/version.ts) acts as the helper for the "Wrelik Brands Versioning Protocol," using a rootVERSIONfile as the source of truth. - CI/CD Constraints:
CHECKLIST_PRECOMMIT.mdandCHECKLIST_PRERELEASE.mdenforce rules such as banning direct vendor SDK imports (e.g., directsupabaseorclerkcalls outside of library wrappers).
Sources: package.json:7-17, scripts/version.ts:25-30, CHECKLIST_PRECOMMIT.md:1-13, CHANGELOG.md:12-18
Environment and Deployment
| Service | Purpose |
|---|---|
| Vercel | Primary hosting and deployment platform. |
| Doppler | Environment variable management and secrets injection. |
| Sentry | Performance monitoring and error feedback. |
| Supabase CLI | Local database development and migrations. |
Sources: README.md:61-64, README.md:155-160, package.json:10
Summary
The DRX CRM technology stack is a transitionary but highly structured architecture. By moving from a monolith BaaS (Supabase) toward a modular provider model (Clerk, Prisma, Neon), the project ensures scalability and vendor independence. The combination of Next.js 16, TypeScript, and strict RLS policies provides a secure, type-safe environment suitable for the regulated retail sectors it serves.
Sources: README.md:21-25, CHANGELOG.md:25-45, testsprite_tests/standard_prd.json:44-50