FlexCRM โ€” Multi-Industry Self-Customizable CRM Platform

A production-grade, multi-tenant SaaS CRM built with a metadata-driven architecture, enabling any industry (Real Estate, Legal, Sales) to customize entities, fields, and workflows without code changes. Features include dynamic Kanban boards, Role-Based Access Control, Google OAuth, Stripe billing integration, and a powerful automation engine.

Next.js
NestJS
TypeScript
PostgreSQL
Prisma
Multi-Tenancy
SaaS
RBAC
OAuth
Turborepo
TailwindCSS
Full-Stack

Note: Some repositories are private to protect proprietary logic. Full source code access can be shared with recruiters on request.

Technical Documentation

๐Ÿ—๏ธ CRM Platform - Technical Documentation

Note to Recruiters: This documentation provides a high-level overview of the CRM architecture, technical decisions, and feature set. It is intended to demonstrate system design capabilities and full-stack proficiency.

๐Ÿš€ Project Overview

This is a Multi-Tenant, Industry-Agnostic CRM Platform designed to be highly customizable for various business sectors (Real Estate, Legal, Sales, etc.).

Why this builds? Most CRMs are either too generic (Salesforce) or too niche (Clio for Law). This platform solves that by using a Metadata-Driven Architecture. The "Entities" (Contacts, Deals, Properties) are not hardcoded but defined in the database, allowing specific "Industries" to have their own terminology, fields, and workflows without changing the code.

๐Ÿ› ๏ธ Technology Stack

Frontend (@crm/web)

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS + Radix UI (Headless components)
  • State Management: Zustand (Global store) + TanStack Query (Server state)
  • Forms: React Hook Form + Zod validation
  • Drag & Drop: @dnd-kit (for Kanban boards)

Backend (@crm/api)

  • Framework: NestJS (Modular architecture)
  • Runtime: Node.js
  • Database ORM: Prisma (PostgreSQL)
  • Authentication: Passport.js (JWT + Google OAuth 2.0)
  • Queue/Async: Redis (BullMQ via wrappers) - Planned/Partial
  • Validation: Class-Validator + DTOs

Infrastructure & DevOps

  • Monorepo Tool: Turborepo
  • Containerization: Docker & Docker Compose
  • Database: PostgreSQL 16
  • Cache: Redis 7
  • Mail: MailHog (Local dev)

๐Ÿ›๏ธ System Architecture

The project follows a Monorepo structure to share code effectively between the API and Client.

/
โ”œโ”€โ”€ apps/
โ”‚   โ”œโ”€โ”€ web/          # Next.js Frontend Application
โ”‚   โ””โ”€โ”€ api/          # NestJS Backend API
โ”œโ”€โ”€ packages/
โ”‚   โ”œโ”€โ”€ types/        # Shared TypeScript Interfaces/DTOs
โ”‚   โ”œโ”€โ”€ config/       # Shared Constants & ENV parsing
โ”‚   โ”œโ”€โ”€ ui/           # Shared React Component Library (Design System)
โ”‚   โ””โ”€โ”€ utils/        # Shared Helper functions
โ”œโ”€โ”€ prisma/           # Database Schema & Migrations
โ””โ”€โ”€ docker-compose.yml

๐Ÿ’พ Data Modeling (ER Diagram)

The core strength of this system is its relationship model. It uses a Multi-Tenant strategy where data is isolated by Workspace.

Loading Diagram...

Key Design Decisions:

  1. JSONB for Flexibility: The Record table uses a data JSONB column. This allows us to store dynamic fields defined by the Entity metadata without altering the database schema for every new customer field.
  2. RBAC (Role-Based Access Control): Permissions are granular (e.g., contacts.view, contacts.edit) and assigned to Roles, which are then assigned to WorkspaceMembers.

โšก Data Flow & Logic

1. Authentication Flow (Hybrid)

We support both standard Email/Password and Google OAuth.

Loading Diagram...

2. Request Lifecycle (NestJS)

Every API request goes through a strict pipeline to ensure security and validation.

  1. Guard: Checks Access-Token (JWT). Validation fails -> 401.
  2. Interceptor: Adds User context to request.
  3. Pipe: Validates input body against DTOs (Data Transfer Objects) using zod or class-validator.
  4. Controller: Routes request to correct service.
  5. Service: executing business logic (e.g., "Create Workspace").
  6. Repository (Prisma): interactions with DB.

๐ŸŒŸ Key Features Implemented

ModuleStatusDescription
Authโœ…JWT, Google OAuth, Session Management
Multi-Tenancyโœ…Workspace creation, switching, member management
Dynamic CRMโœ…Creating Records based on metadata (Entity/Field definitions)
Automation๐ŸšงEvent-driven triggers (Create Record -> Send Email). Queue implemented.
Billing๐ŸšงStripe Integration models prepared (Subscription, Invoice)
RBACโœ…Role & Permission Guard system
Audit Logsโœ…Tracking who did what (IP, User Agent, Action)

๐Ÿงช Future Improvements

  • Websockets: Real-time updates for Kanban boards.
  • AI Integration: Using the OpenAI API to summarize CRM records (foundations in place).
  • Mobile App: React Native app sharing packages/types and packages/client.