Skip to content

About

A modern, modular CRM platform built with a pnpm monorepo. Includes API, web, and mobile apps for sales, marketing, support, and automation—powered by TypeScript, Prisma, and Vite. Designed for extensibility, team collaboration, and rapid business growth.

Topics

Resources

Contributing

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

CRM Platform (Professional-Grade Monorepo)

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.

1. Architecture and Technology Decisions

Core stack

  • 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)

Modularity strategy

  • 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.

Scalability strategy

  • 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.

Security strategy

  • 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.

2. Repository Structure

apps/
  api/      -> REST API, auth/RBAC, CRM modules, Prisma schema
  web/      -> Responsive React app
  mobile/   -> React Native app scaffold
packages/
  shared/   -> Common types

3. Run and Development

  1. Install dependencies:
    • pnpm install
  2. Start infra:
    • docker compose up -d
  3. Copy env:
    • .env.example -> .env
  4. Start apps:
    • API: pnpm --filter crm-api dev
    • Web: pnpm --filter crm-web dev
    • Mobile: pnpm --filter crm-mobile start

4. Detailed Implementation Steps by CRM Capability

1. Contact Management

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

  1. Add Prisma repository layer for contacts/interactions and replace in-memory storage.
  2. Add DB indexes for email, location, and lastInteractionAt.
  3. Add async import jobs for large files and failure reports per row.
  4. Add data quality checks (duplicate detection, email/phone normalization).

2. Sales Automation

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

  1. Persist lead scoring rules per business unit and version scoring models.
  2. Store stage-transition history for conversion analytics.
  3. Add SLA reminders and follow-up automation for stale opportunities.
  4. Add explainable forecast confidence bands by segment.

3. Marketing Automation

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

  1. Add segment rule builder (AND/OR groups) with saved predicates.
  2. Add drip campaign scheduler and throttled sending workers.
  3. Add attribution models (first-touch, last-touch, multi-touch).
  4. Add cross-channel orchestration and spend/revenue ROI metrics.

4. Customer Support and Service

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

  1. Add assignment routing rules (skills, queue load, priority).
  2. Add SLA timers and breach alerts with escalation ladders.
  3. Add chatbot intent router and human handoff transcript linking.
  4. Add deflection analytics (KB views vs ticket volume).

5. Analytics and Reporting

Implemented foundation

  • Dashboard KPI endpoint.
  • Sales, marketing, support, and LTV report endpoints.

Implementation steps

  1. Introduce analytics warehouse tables and daily aggregate jobs.
  2. Add chart-ready APIs (time series, cohorts, funnel metrics).
  3. Add downloadable exports (CSV/XLSX/PDF generation workers).
  4. Add user-defined report templates with scheduled delivery.

6. Third-Party Integrations

Implemented foundation

  • Integration registry and provider status/sync endpoints.
  • API-first architecture for external app interaction.

Implementation steps

  1. Add OAuth2 connect flows per provider adapter.
  2. Add webhook ingestion + signature verification.
  3. Add incremental sync state checkpoints and retry policies.
  4. Add audit logs for all sync actions and field-level mapping.

7. Collaboration Tools

Implemented foundation

  • Internal chat endpoints.
  • Shared calendar event endpoints.
  • Task assignment/progress tracking endpoints.
  • RBAC enforcement middleware.

Implementation steps

  1. Add presence/typing indicators via WebSockets.
  2. Add external calendar sync (Google/Outlook) with conflict handling.
  3. Add task dependency graph and workload balancing.
  4. Add @mentions and notification routing by role/team.

8. Mobile Access

Implemented foundation

  • React Native app with contacts, deals, and ticket views.
  • Push notification permission flow.

Implementation steps

  1. Add secure token storage and refresh workflow.
  2. Add offline-first cache with conflict resolution on sync.
  3. Add deep-link routing from push notifications.
  4. Add native performance instrumentation and crash reporting.

9. Customization and Personalization

Implemented foundation

  • Custom field definitions endpoints.
  • Branding settings endpoints.
  • Custom report definition endpoint.

Implementation steps

  1. Add runtime schema registry for custom fields by entity.
  2. Add validation and migration flow when field definitions change.
  3. Add theme packs and tenant-level branding profiles.
  4. Add per-role/personalized dashboard layouts.

10. Security and Data Privacy

Implemented foundation

  • JWT authentication, 2FA setup/enable, RBAC checks.
  • Rate limiting, helmet hardening, typed validation.
  • Encryption helper for sensitive data.

Implementation steps

  1. Add password policies, lockout rules, and session revocation.
  2. Add full at-rest encryption for secrets and token vaulting.
  3. Add consent management, DSR workflows, and retention policies.
  4. Add HIPAA/GDPR/CCPA audit controls and policy automation.

11. Workflow Automation

Implemented foundation

  • Workflow rule CRUD with trigger + condition + action expressions.
  • Trigger execution engine and notification/task actions.

Implementation steps

  1. Add visual workflow builder with branching.
  2. Add deterministic workflow runtime with retries/timeouts.
  3. Add idempotency keys and dead-letter handling for failed actions.
  4. Add run history with replay and diffable execution logs.

12. AI and Predictive Analytics

Implemented foundation

  • Deterministic lead scoring baseline.
  • Sentiment field support in chat schema and report hooks.

Implementation steps

  1. Build feature pipeline from interactions, campaigns, and support data.
  2. Train conversion propensity and churn-risk models.
  3. Add sentiment inference service for email/chat transcripts.
  4. Add guarded AI assistant/chatbot actions with confidence thresholds.

13. Task and Activity Management

Implemented foundation

  • Task creation/assignment/status APIs and due-date triggers.
  • Interaction logging tied to contacts.
  • Unified activity schema support in Prisma.

Implementation steps

  1. Add recurring tasks and smart follow-up templates.
  2. Add timeline view combining interactions, tasks, tickets, and deals.
  3. Add SLA-aware reminders and escalation chains.
  4. Add productivity metrics by team and owner.

5. Testing Strategy (Unit, Integration, E2E)

  1. Unit tests
    • Lead scoring, segmentation predicates, workflow condition evaluator.
  2. Integration tests
    • API module contracts, auth/RBAC coverage, import/export flows.
  3. E2E tests
    • Lead-to-deal lifecycle, campaign-to-conversion journey, support resolution journey.
  4. Security tests
    • Auth/2FA brute-force resistance, permission boundary checks, input hardening.

Current seed test example:

  • apps/api/tests/contacts.test.ts

6. Production Hardening Checklist

  1. Replace in-memory stores with Prisma repositories and migrations.
  2. Add background worker service for automation, notifications, and sync.
  3. Add observability (OpenTelemetry traces, logs, metrics dashboards).
  4. Add CI gates (typecheck, tests, security scan, migration checks).
  5. Add multi-tenant boundaries if serving multiple organizations.

7. API Surface Snapshot

  • /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).

About

A modern, modular CRM platform built with a pnpm monorepo. Includes API, web, and mobile apps for sales, marketing, support, and automation—powered by TypeScript, Prisma, and Vite. Designed for extensibility, team collaboration, and rapid business growth.

Topics

Resources

Contributing

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages