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.
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:
- JSONB for Flexibility: The
Recordtable uses adataJSONB column. This allows us to store dynamic fields defined by theEntitymetadata without altering the database schema for every new customer field. - RBAC (Role-Based Access Control): Permissions are granular (e.g.,
contacts.view,contacts.edit) and assigned toRoles, which are then assigned toWorkspaceMembers.
โก 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.
- Guard: Checks
Access-Token(JWT). Validation fails -> 401. - Interceptor: Adds
Usercontext to request. - Pipe: Validates input body against
DTOs(Data Transfer Objects) usingzodorclass-validator. - Controller: Routes request to correct service.
- Service: executing business logic (e.g., "Create Workspace").
- Repository (Prisma): interactions with DB.
๐ Key Features Implemented
| Module | Status | Description |
|---|---|---|
| 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/typesandpackages/client.