This repository now contains a modular CRM foundation with:
- Node.js + TypeScript API (
apps/api) with role-based auth, 2FA setup endpoints, and domain modules. - React web app (
apps/web) with responsive dashboard, contacts search/filter, pipeline, and support views. - React Native mobile app (
apps/mobile) scaffold for iOS/Android with push notification permission flow. - Shared domain package (
packages/shared) for common CRM types. - Comprehensive relational schema (
apps/api/prisma/schema.prisma) designed for scale and compliance.
- Frontend web: React + Vite + TypeScript
- Backend: Node.js + Express + TypeScript
- Mobile: React Native (Expo) + TypeScript
- Database: PostgreSQL (via Prisma schema)
- Caching/async: Redis-ready (
docker-compose.yml)
- Organize by domain modules (
contacts,sales,marketing,support,analytics,automation,integrations,collaboration,customization). - Keep shared contracts in
packages/shared. - Use adapters for third-party providers so each integration can evolve independently.
- Start with modular monolith.
- Move heavy jobs (campaign sends, sync jobs, forecasting recomputes) to queue workers.
- Add read replicas and index tuning as data volume grows.
- JWT auth, 2FA setup/enable flows, RBAC middleware.
- Encryption helper (
apps/api/src/core/crypto.ts) for sensitive values at rest. - Helmet, rate limiting, and typed input validation.
apps/
api/ -> REST API, auth/RBAC, CRM modules, Prisma schema
web/ -> Responsive React app
mobile/ -> React Native app scaffold
packages/
shared/ -> Common types
- Install dependencies:
pnpm install
- Start infra:
docker compose up -d
- Copy env:
.env.example->.env
- Start apps:
- API:
pnpm --filter crm-api dev - Web:
pnpm --filter crm-web dev - Mobile:
pnpm --filter crm-mobile start
- API:
Implemented foundation
- Relational contact model + interaction history in Prisma schema.
- API endpoints for contact CRUD, search/filter, interaction logging.
- Bulk import/export via CSV, XLSX, and JSON API payloads.
Implementation steps
- Add Prisma repository layer for contacts/interactions and replace in-memory storage.
- Add DB indexes for
email,location, andlastInteractionAt. - Add async import jobs for large files and failure reports per row.
- Add data quality checks (duplicate detection, email/phone normalization).
Implemented foundation
- Lead capture with weighted lead scoring.
- Deal/pipeline stage tracking and pipeline grouping endpoint.
- Forecast endpoint using weighted-stage projections.
- Automation hooks on lead creation and deal-stage changes.
Implementation steps
- Persist lead scoring rules per business unit and version scoring models.
- Store stage-transition history for conversion analytics.
- Add SLA reminders and follow-up automation for stale opportunities.
- Add explainable forecast confidence bands by segment.
Implemented foundation
- Campaign CRUD, status updates, A/B test scheduling endpoint.
- Dynamic segment preview by contact attributes.
- Behavior event tracking with open/click rate updates.
Implementation steps
- Add segment rule builder (AND/OR groups) with saved predicates.
- Add drip campaign scheduler and throttled sending workers.
- Add attribution models (first-touch, last-touch, multi-touch).
- Add cross-channel orchestration and spend/revenue ROI metrics.
Implemented foundation
- Ticketing with category, priority, notes, escalation, and CSAT survey capture.
- Knowledge base authoring/search endpoints.
- Live chat endpoints for message streams.
Implementation steps
- Add assignment routing rules (skills, queue load, priority).
- Add SLA timers and breach alerts with escalation ladders.
- Add chatbot intent router and human handoff transcript linking.
- Add deflection analytics (KB views vs ticket volume).
Implemented foundation
- Dashboard KPI endpoint.
- Sales, marketing, support, and LTV report endpoints.
Implementation steps
- Introduce analytics warehouse tables and daily aggregate jobs.
- Add chart-ready APIs (time series, cohorts, funnel metrics).
- Add downloadable exports (CSV/XLSX/PDF generation workers).
- Add user-defined report templates with scheduled delivery.
Implemented foundation
- Integration registry and provider status/sync endpoints.
- API-first architecture for external app interaction.
Implementation steps
- Add OAuth2 connect flows per provider adapter.
- Add webhook ingestion + signature verification.
- Add incremental sync state checkpoints and retry policies.
- Add audit logs for all sync actions and field-level mapping.
Implemented foundation
- Internal chat endpoints.
- Shared calendar event endpoints.
- Task assignment/progress tracking endpoints.
- RBAC enforcement middleware.
Implementation steps
- Add presence/typing indicators via WebSockets.
- Add external calendar sync (Google/Outlook) with conflict handling.
- Add task dependency graph and workload balancing.
- Add @mentions and notification routing by role/team.
Implemented foundation
- React Native app with contacts, deals, and ticket views.
- Push notification permission flow.
Implementation steps
- Add secure token storage and refresh workflow.
- Add offline-first cache with conflict resolution on sync.
- Add deep-link routing from push notifications.
- Add native performance instrumentation and crash reporting.
Implemented foundation
- Custom field definitions endpoints.
- Branding settings endpoints.
- Custom report definition endpoint.
Implementation steps
- Add runtime schema registry for custom fields by entity.
- Add validation and migration flow when field definitions change.
- Add theme packs and tenant-level branding profiles.
- Add per-role/personalized dashboard layouts.
Implemented foundation
- JWT authentication, 2FA setup/enable, RBAC checks.
- Rate limiting, helmet hardening, typed validation.
- Encryption helper for sensitive data.
Implementation steps
- Add password policies, lockout rules, and session revocation.
- Add full at-rest encryption for secrets and token vaulting.
- Add consent management, DSR workflows, and retention policies.
- Add HIPAA/GDPR/CCPA audit controls and policy automation.
Implemented foundation
- Workflow rule CRUD with trigger + condition + action expressions.
- Trigger execution engine and notification/task actions.
Implementation steps
- Add visual workflow builder with branching.
- Add deterministic workflow runtime with retries/timeouts.
- Add idempotency keys and dead-letter handling for failed actions.
- Add run history with replay and diffable execution logs.
Implemented foundation
- Deterministic lead scoring baseline.
- Sentiment field support in chat schema and report hooks.
Implementation steps
- Build feature pipeline from interactions, campaigns, and support data.
- Train conversion propensity and churn-risk models.
- Add sentiment inference service for email/chat transcripts.
- Add guarded AI assistant/chatbot actions with confidence thresholds.
Implemented foundation
- Task creation/assignment/status APIs and due-date triggers.
- Interaction logging tied to contacts.
- Unified activity schema support in Prisma.
Implementation steps
- Add recurring tasks and smart follow-up templates.
- Add timeline view combining interactions, tasks, tickets, and deals.
- Add SLA-aware reminders and escalation chains.
- Add productivity metrics by team and owner.
- Unit tests
- Lead scoring, segmentation predicates, workflow condition evaluator.
- Integration tests
- API module contracts, auth/RBAC coverage, import/export flows.
- E2E tests
- Lead-to-deal lifecycle, campaign-to-conversion journey, support resolution journey.
- Security tests
- Auth/2FA brute-force resistance, permission boundary checks, input hardening.
Current seed test example:
apps/api/tests/contacts.test.ts
- Replace in-memory stores with Prisma repositories and migrations.
- Add background worker service for automation, notifications, and sync.
- Add observability (OpenTelemetry traces, logs, metrics dashboards).
- Add CI gates (typecheck, tests, security scan, migration checks).
- Add multi-tenant boundaries if serving multiple organizations.
/api/v1/auth/*/api/v1/contacts/*/api/v1/sales/*/api/v1/marketing/*/api/v1/support/*/api/v1/analytics/*/api/v1/automation/*/api/v1/collaboration/*/api/v1/customization/*/api/v1/integrations/*
This foundation is intentionally structured to support incremental delivery while preserving enterprise-grade concerns (security, scalability, testing, and maintainability).