Skip to main content

DashClicks Back-End

Welcome to the DashClicks Back-End - a comprehensive microservices architecture powering the DashClicks platform for digital marketing agencies worldwide.

What is DashClicks?โ€‹

DashClicks is a complete white-label digital marketing platform that provides agencies with tools for CRM, analytics, billing, project management, and client communications. The back-end is a sophisticated monorepo containing 15+ microservices that work together to deliver a seamless experience.

Architecture Overviewโ€‹

๐Ÿ—๏ธ Microservices Architectureโ€‹

  • Independent Services: Each service handles specific business domains
  • Service Communication: HTTP proxying through centralized API Router (Using Traefik on production)
  • Scalable Design: Each service can be deployed and scaled independently
  • Shared Components: Common models and utilities across all services

๐Ÿš€ Modern Tech Stackโ€‹

  • Node.js + Express (JS): Fast, scalable server-side JavaScript
  • Deno + Hono (TS): Lightweight runtime for AI services, TypeScript support
  • MongoDB + Mongoose: Flexible document database with ODM
  • Socket.IO: Real-time communication for chat and live updates
  • Redis: Caching and session management for socket services
  • pnpm: Fast, disk space efficient package manager for monorepos
  • Jest: Comprehensive testing framework with coverage requirements

Core Services & Portsโ€‹

The DashClicks back-end consists of multiple specialized microservices as defined in .vscode/launch.json:

๐Ÿ”Œ Primary Servicesโ€‹

  • Dashboard Gateway (5000) - Frontend proxy for React dashboard
  • API Router (5001) - Main API gateway, routes to internal/external services/AI service (Local Development Only)
  • Internal API (5002) - Proprietary DashClicks features (/v1/* routes)
  • External API (5003) - 3rd party integrations (/v1/e/* routes)

๐Ÿ”„ Real-time & Communication Servicesโ€‹

  • Conversation Socket (6001) - Real-time messaging with Socket.IO
  • General Socket (4000) - General real-time events and notifications
  • Notification Service (5008) - Email/SMS notifications and alerts
  • Queue Manager (6002) - Background job processing and task scheduling

๐Ÿ› ๏ธ Utility & Integration Servicesโ€‹

  • AI Service (5010) - Advanced AI/ML capabilities using Deno runtime with OpenAI integration
  • Callrail Recordings (5004) - Call recording proxy service
  • Currency Service (5005) - Multi-currency support
  • Yext Publishers (5006) - Publisher data management
  • Yext Publishers Logo (5007) - Publisher image management
  • Proxy Server (6003) - Internal proxy routing
  • Google Maps Integration (5009) - Maps and location services

Prerequisitesโ€‹

Before you begin, ensure you have the following installed:

๐Ÿ“‹ Required Softwareโ€‹

  • Node.js v18+ (Download)
  • Deno v2.0+ (Download) - Required for AI Service
  • pnpm v10+ (npm install -g pnpm)
  • MongoDB running locally or MongoDB Atlas access
  • Redis for socket services and caching
  • VS Code with debugger extensions
  • Git for version control
  • Docker for containerized services
  • Postman for API testing
  • MongoDB Compass for database visualization
  • Redis Insight for Redis monitoring

Getting Started - Production Setupโ€‹

โšก Step 1: Environment Setupโ€‹

Clone the repository and install dependencies using pnpm:

# 1. Clone the repository
git clone https://github.com/DashClicks-LLC/Back-End.git
cd Back-End

# 2. Install pnpm globally if not already installed
npm install -g pnpm

# 3. Install all dependencies across the monorepo
pnpm install

๐Ÿ” Step 2: Environment Configurationโ€‹

Set up your environment files for all services:

# 1. Copy the main environment template
cp .env.sample .env

# 2. Edit the main .env file with your credentials
nano .env

Required Environment Variablesโ€‹

Add these essential variables to your .env file from the sample .env.sample

๐Ÿ”„ Step 3: Shared Files Managementโ€‹

CRITICAL: Always run this after environment setup:

# Copy shared models and utilities to all services
pnpm run copySharedFiles

Understanding Shared Architectureโ€‹

  • /shared/models/ - 150+ Mongoose schemas used across all services
  • /shared/utilities/ - Common business logic and helper functions
  • Service-level models/ and utilities/ folders are Git-ignored
  • Never edit files in service-level folders - they get overwritten!

๐Ÿš€ Step 4: Redis Setupโ€‹

IN local DEVELOPMENT, Redis is optional (Required for Queue Manager, Sockets, Notification Service) but recommended for full functionality using Docker

Running Services with VS Code Debuggerโ€‹

๐Ÿšจ IMPORTANT: We ONLY run services through VS Code debugger configurations - never directly in terminal!

๐Ÿ› Launch Configurationsโ€‹

Our .vscode/launch.json contains 20+ pre-configured debug setups:

Core API Servicesโ€‹

Open VS Code โ†’ Debug Panel (Ctrl+Shift+D) โ†’ Select any service:

  • Dashboard Gateway (5000) - Frontend proxy service (Always Run)
  • API Router (5001) - Main routing service (Always Run)
  • API Internal (5002) - Internal business logic and proprietary features
  • API External (5003) - Third-party integrations

Real-time & Communication Servicesโ€‹

  • SOCKET Conversation (6001) - Real-time messaging with Socket.IO
  • General Socket (4000) - General real-time events and notifications
  • Notification Service (5008) - Email/SMS notifications and alerts
  • Notification queue (5008) - Queue-enabled notification processing

Background Processing Servicesโ€‹

  • Queue Manager (6002) - Background job processing and task scheduling

Utility & Integration Servicesโ€‹

  • MISC - Callrail Recordings (5004) - Call recording proxy service
  • MISC - Currency (5005) - Multi-currency conversion utilities
  • MISC - Yext Publishers (5006) - Publisher data management
  • MISC - Yext Publishers Logo (5007) - Publisher image management
  • MISC - Proxy (5007) - Internal proxy routing
  • Proxy server (6003) - General proxy functionality

Specialized Servicesโ€‹

  • AI Service (5010) - Advanced AI/ML capabilities using Deno runtime
  • External - Google maps (5009) - Maps and location services integration

Testing & Development Servicesโ€‹

  • Test forms notifications - Forms notification testing utility
  • Test forms contact notifications - Contact reminder testing utility
  • Function - Deals automation - Deals automation testing

๐Ÿš€ Starting Development Environmentโ€‹

# In VS Code:
# 1. Go to Debug Panel (Ctrl+Shift+D)
# 2. Select "Start All" compound configuration
# 3. Press F5 or click green play button

Method 2: Individual Service Developmentโ€‹

For focused development on specific services:

# In VS Code Debug Panel:
# 1. Select the specific service (e.g., "API Internal")
# 2. Press F5 to start with debugger attached
# 3. Set breakpoints in your code
# 4. Debugger will pause at breakpoints for inspection

๐Ÿ” Debugger Featuresโ€‹

  • Automatic Restart: Services restart on file changes
  • Environment Variables: Loaded from .env files
  • Breakpoint Support: Full debugging capabilities
  • Console Output: All service logs in Debug Console
  • Variable Inspection: Real-time variable values
  • Call Stack: Complete execution trace

Essential Development Workflowโ€‹

๐Ÿšจ CRITICAL: Shared Folder Rulesโ€‹

โš ๏ธ NEVER edit files in service-level models/ or utilities/ folders

The shared code system has Git ignore patterns that developers must understand:

# These folders are Git-ignored in ALL services:
internal/api/v1/models/ # โŒ DON'T EDIT
internal/api/v1/utilities/ # โŒ DON'T EDIT
external/Integrations/models/ # โŒ DON'T EDIT
external/Integrations/utilities/ # โŒ DON'T EDIT
conversation-socket/models/ # โŒ DON'T EDIT
# ... and so on for all services

โœ… Correct Development Workflowโ€‹

# 1. Edit shared files only
nano shared/models/user.js
nano shared/utilities/auth.js

# 2. Copy changes to all services
pnpm run copySharedFiles

# 3. Restart affected services in VS Code debugger
# (Services DO NOT auto-restart on file changes)

# 4. Test your changes with debugger breakpoints

๐Ÿ”„ Development Commandsโ€‹

# Install dependencies (use pnpm, not npm!)
pnpm install

# Copy shared files after editing them
pnpm run copySharedFiles

# Run tests across all services
pnpm test

# Generate coverage reports (40% branch, 50% function minimum)
pnpm run coverage

# Build documentation
pnpm run docs

Monorepo Structureโ€‹

Understanding the DashClicks back-end organization:

๐Ÿ“ Core Directoriesโ€‹

Back-End/
โ”œโ”€โ”€ .vscode/
โ”‚ โ””โ”€โ”€ launch.json # 20+ VS Code debug configurations
โ”œโ”€โ”€ shared/ # Shared code for all services
โ”‚ โ”œโ”€โ”€ models/ # 150+ Mongoose schemas
โ”‚ โ””โ”€โ”€ utilities/ # Common business logic
โ”œโ”€โ”€ internal/ # Internal API service (5002)
โ”‚ โ””โ”€โ”€ api/v1/ # Internal business endpoints
โ”œโ”€โ”€ external/ # External API service (5003)
โ”‚ โ””โ”€โ”€ Integrations/ # 25+ third-party integrations
โ”œโ”€โ”€ dashboard-gateway/ # Frontend proxy (5000)
โ”œโ”€โ”€ router/ # API routing service (5001)
โ”œโ”€โ”€ conversation-socket/ # Real-time messaging (6001)
โ”œโ”€โ”€ general-socket/ # General events (4000)
โ”œโ”€โ”€ queue-manager/ # Background jobs (6002)
โ”œโ”€โ”€ notifications/ # Email/SMS service (5008)
โ”œโ”€โ”€ ai-service/ # AI features using Deno (5010)
โ”œโ”€โ”€ misc/ # Utility services (5004-5007)
โ”‚ โ”œโ”€โ”€ callrail-recordings/ # Call recording proxy
โ”‚ โ”œโ”€โ”€ currency/ # Currency conversion
โ”‚ โ”œโ”€โ”€ proxy-server/ # Internal proxy (6003)
โ”‚ โ”œโ”€โ”€ yext-publishers/ # Publisher data
โ”‚ โ””โ”€โ”€ yext-publishers-logo/ # Publisher images
โ”œโ”€โ”€ functions/ # Serverless functions
โ”œโ”€โ”€ tests/ # Centralized testing suite
โ””โ”€โ”€ docs/ # Documentation system

๐ŸŒ Service URLs (Development)โ€‹

When all services are running via VS Code debugger:

Core API Servicesโ€‹

Real-time & Communication Servicesโ€‹

Background Processing Servicesโ€‹

Utility & Integration Servicesโ€‹

Specialized Servicesโ€‹

Key Features & Integrationsโ€‹

๐Ÿ”Œ Third-Party Integrationsโ€‹

DashClicks connects with 30+ external services located in external/Integrations/:

Marketing & Advertisingโ€‹

  • Google Ads - PPC campaign management and optimization
  • Facebook - Social media advertising and analytics
  • BingAds - Microsoft advertising platform integration
  • TikTok - Social media advertising for TikTok platform
  • Google Analytics - Web analytics and reporting
  • SEMrush - SEO and competitive analysis tools

CRM & Sales Managementโ€‹

  • Salesforce - Enterprise CRM integration
  • Pipedrive - Sales pipeline management
  • HubSpot - Inbound marketing and sales platform
  • Keap - Small business CRM and automation
  • Zoho - Business suite integration
  • ActiveCampaign - Email marketing and automation

Communication & Messagingโ€‹

  • Twilio - SMS/Voice communication services
  • SendGrid - Email delivery and marketing
  • Mailchimp - Email marketing campaigns
  • ConstantContact - Email marketing platform
  • FCM - Firebase Cloud Messaging for push notifications
  • Beamer - Product update notifications

Call Tracking & Analyticsโ€‹

  • Callrail - Call tracking and analytics
  • CallTrackingMetrics - Advanced call tracking solutions

Payments & Financial Servicesโ€‹

  • Stripe - Payment processing and subscriptions
  • Squareup - Point of sale and payment solutions
  • Tipalti - Automated payables and payments

Website & Development Toolsโ€‹

  • Duda - Website builder integration
  • Cloudflare - CDN and security services
  • GoogleBusiness - Google My Business integration
  • GoogleMap - Maps and location services
  • Yext - Digital knowledge management
  • Wasabi - Cloud storage solutions

Data & APIsโ€‹

  • RapidAPI - API marketplace and integration platform

๐Ÿ“Š Core Platform Featuresโ€‹

Based on internal/api/v1/ modules, DashClicks provides:

Account & User Managementโ€‹

  • Accounts - Multi-tenant account management and domain configuration
  • Users - User authentication, roles, permissions, and profile management
  • Auth - JWT-based authentication, session management, and OAuth integrations

Customer Relationship Managementโ€‹

  • CRM - Complete contact management, deal tracking, and pipeline automation
  • Activities - User activity tracking and audit logs
  • Forms - Lead capture forms and form submission handling

Sales & Marketing Toolsโ€‹

  • Funnels - Sales funnel creation and conversion tracking
  • Templates - Marketing template management and customization
  • URL Shortener - Branded link shortening and click tracking
  • Reviews - Online reputation management and review monitoring

Website & Content Managementโ€‹

  • InstaSites - Automated website generation and management
  • Sites - Agency website builder and hosting platform
  • InstaReports - Automated reporting and analytics generation
  • Public - Public-facing content and landing pages

Communication & Collaborationโ€‹

  • Conversations - Client messaging and internal team communication
  • Conversation-v2 - Enhanced real-time messaging system
  • Notifications Center - Centralized notification management

Business Operationsโ€‹

  • Store - White-label marketplace for digital marketing products
  • Billing - Subscription management, invoicing, and payment processing
  • Projects - Task management and project collaboration tools
  • OneBalance - Unified billing and credit management system

System & Administrationโ€‹

  • Admin - System administration and configuration management (DashClicks internal use only)
  • Webhooks - External service webhook handling and processing
  • Filters - Data filtering and search functionality
  • Inbound - Lead capture and inbound marketing automation

Analytics & Reportingโ€‹

  • Shared - Shared analytics and reporting components
  • Mobile App - Mobile application API endpoints

Advanced Featuresโ€‹

  • Affiliates - Partner and affiliate program management
  • OAuth - Third-party application authentication
  • CORS Proxy - Cross-origin request handling

Database Architectureโ€‹

๐Ÿ—„๏ธ MongoDB Collectionsโ€‹

The system uses 150+ Mongoose models organized by domain in /shared/models/:

Core Business Modelsโ€‹

  • Account Management: account.js, account-user.js, account-credit.js, account-signup-code.js, account-public-request.js, account-import-results.js
  • User Management: user.js, workspace-*.js, user-*.js
  • CRM & Sales: contact.js, deal.js, pipeline.js, automation.js, automation-log.js, crm-log.js, crm-note.js, crm-tag.js
  • Billing & Commerce: billing-*.js (charges, customers, disputes, products, subscriptions), store-*.js, consumer-*.js
  • Analytics & Reporting: analytics-*.js (callrail, facebook-ads, google-analytics, seo, tiktok), semrush.js, campaign-data.js

Communication & Messaging Modelsโ€‹

  • Conversations: conversation.js, conversation-*.js (channel, group, message, prospect, room), communication.js
  • Notifications: notification-*.js, fcm-notification.js, fcm-token.js, expo-push-tokens.js
  • Forms & Lead Capture: forms-*.js, lead-*.js, prospect-*.js

Content & Website Managementโ€‹

  • Sites & Templates: site.js, sites-*.js, template.js, templates-*.js, agency-website.js, agency-website-template.js
  • InstaSites: instasites-*.js, instasite-*.js
  • InstaReports: instareports-*.js, report-*.js
  • Projects: project.js, project-*.js, task-*.js

Third-Party Integration Modelsโ€‹

  • API Authentication: *-key.js, *-token.js patterns for service credentials
    • Google: google-*.js (ads, analytics, business, map tokens)
    • Social Media: facebook-*.js, tiktok-*.js, bing-ads-token.js
    • Email Marketing: mailchimp-*.js, constant-contact-key.js, active-campaign-key.js
    • CRM Integrations: salesforce-*.js, hubspot-*.js, pipedrive-*.js
    • Call Tracking: callrail-key.js, calltrackingmetrics-key.js
    • Payment Processing: stripe-*.js, tipalti-*.js
    • Website Tools: duda-*.js, yext-*.js

System & Administrative Modelsโ€‹

  • API Management: api-*.js (apps, grants, refresh-tokens, scopes, sessions)
  • OAuth & Authentication: oauth-*.js, session-*.js
  • Queue Management: queue-*.js, csv-queue.js, contact-queue.js, edocs-queue.js
  • Webhooks & Events: webhook-*.js, event-*.js
  • Admin & Teams: admin-team.js, team-*.js

Specialized Feature Modelsโ€‹

  • Affiliates: affiliate-*.js, affiliates-leaderboard.js
  • Reviews & Reputation: review-*.js, reputation-*.js
  • Scheduling: availability-scheduler.js, event-type*.js, scheduler-*.js
  • E-Documents: edocs-*.js (categories, contacts, documents, files, templates)
  • Filters & Search: filter.js, fields-filter.js
  • Currency & Localization: currency.js, timezone.js

๐Ÿ”ง Database Connection & Initializationโ€‹

The system uses a centralized database connection utility in shared/utilities/db.js:

Connection Managementโ€‹

const { connect, isConnected, disconnect } = require('./service-name/utilities/db');

// Initialize MongoDB connection with event logging
await connect({
uri: process.env.MONGO_DB_URL,
initiator: 'service-name',
options: { maxPoolSize: 10 },
overrideEvents: [], // or ['connecting'] to skip default events
});

Key Featuresโ€‹

  • Automatic Event Logging: Registers MongoDB lifecycle events (connecting, connected, open, reconnected, disconnected, close, error)
  • Connection Pooling: Default maxPoolSize of 10 connections
  • Error Handling: Comprehensive error logging with service context
  • Graceful Shutdown: Clean disconnection with proper logging
  • Connection State Monitoring: isConnected() helper for health checks
  • Event Customization: Configurable event logging per service

Connection Statesโ€‹

  • readyState 0: Disconnected
  • readyState 1: Connected (target state)
  • readyState 2: Connecting
  • readyState 3: Disconnecting

Best Practicesโ€‹

// Service initialization pattern
const db = require('./shared/utilities/db');

async function startService() {
try {
// Connect with service-specific logging
await db.connect({
initiator: 'internal-api',
overrideEvents: ['connecting'], // Skip default connecting event
});

// Check connection health
if (db.isConnected()) {
console.log('Service ready with database connection');
}
} catch (error) {
console.error('Failed to initialize database:', error.message);
process.exit(1);
}
}

// Graceful shutdown
process.on('SIGTERM', async () => {
await db.disconnect('internal-api');
process.exit(0);
});

Schema Patternsโ€‹

  • Global Configuration: shared/models/_globalSchemaOptions.js defines consistent schema defaults
  • Validation Patterns: Standardized validation rules across all models
  • Mongoose Middleware: Pre/post hooks for automation and data integrity
  • Index Optimization: Strategic indexing for query performance
  • Timestamp Management: Automatic createdAt/updatedAt with immutable createdAt option

Testing & Quality Assuranceโ€‹

๐Ÿงช Testing Architectureโ€‹

# Run all tests across services
pnpm test

# Run tests with coverage
pnpm run coverage

# Run specific service tests
pnpm test -- --testPathPattern=internal

# Run integration tests
pnpm test -- tests/integration

๐Ÿ“Š Coverage Requirementsโ€‹

  • 40% minimum branch coverage
  • 50% minimum function coverage
  • 50% minimum line coverage
  • MongoDB Memory Server for isolated testing
  • Supertest for API endpoint testing

๐Ÿ”ง Jest Configurationโ€‹

  • Multi-project setup with service-specific configs
  • Shared test utilities in /tests/
  • Mock data in /tests/fixtures/
  • Integration tests in /tests/integration/

Advanced Development Topicsโ€‹

๐Ÿš€ Background Job Processingโ€‹

The Queue Manager service (port 6002) is a comprehensive background processing system with multiple specialized queues and cron jobs:

Queue Categories & Environment Controlsโ€‹

# Core Business Process Queues
QM_SUBSCRIPTION_CANCEL=false # Subscription cancellation processing
QM_SUBSCRIPTION_ACTIVATE=false # Subscription activation workflows
QM_SUBSCRIPTION_PENDING_SUBACCOUNT_CHARGE=false # Pending subaccount billing
QM_SUBSCRIPTION_CHARGE_MAINACCOUNT=false # Main account billing

# Contact & CRM Management
QM_CONTACTS=false # Contact processing and automation
QM_CONTACTS_EXPORT=false # Contact data export jobs
QM_CONTACTS_EXPORT_CLEANUP=false # Export cleanup tasks
QM_DEALS=false # Deal processing workflows
QM_DEALS_AUTOMATIONS=false # Deal automation triggers

# Website & Content Generation
QM_INSTASITES_BUILD=false # InstaSites website building
QM_INSTASITES_PURGE=false # InstaSites cleanup (90 days)
QM_INSTAREPORT_BUILD=false # InstaReports generation
QM_SITES_BUILD_THUMBNAILS=false # Site thumbnail generation
QM_FUNNELS_BUILD_THUMBNAILS=false # Funnel thumbnail generation
QM_FUNNELS_CLONING=false # Funnel duplication processes

# Financial & Billing Operations
QM_ONEBALANCE_BALANCE_RELOAD=false # OneBalance credit reloading
QM_ONEBALANCE_BALANCE_RELOAD_STREAM=false # Real-time balance updates
QM_ONEBALANCE_BALANCE_CHARGE=false # OneBalance charging
QM_ONEBALANCE_BALANCE_CHARGE_STREAM=false # Real-time charge processing
QM_BILLING_NEW_AUTH=false # New billing authorization
QM_BILLING_CONTACTS=false # Billing contact management

# Communication & Support
QM_SUPPORT_SNOOZE=false # Support ticket snoozing
QM_SUPPORT_MESSAGE_STATUS=false # Support message status updates
QM_SUPPORT_NOTIFICATION=false # Support notifications
QM_SUPPORT_COMMUNICATION_CHECK=false # Communication health checks

# System & Infrastructure
QM_HOOKS=false # Webhook processing and retries
QM_WEBHOOK=false # General webhook handling
QM_TRIGGERS=false # System trigger processing
QM_PROJECTS=false # Project management automation
QM_AFFILIATES=false # Affiliate program processing
QM_REPUTATION=false # Online reputation monitoring

# Domain & Infrastructure Management
QM_LIGHTNING_DOMAIN_VALIDATION=false # Lightning domain validation
QM_LIGHTNING_DOMAIN_RENEWAL=false # Domain renewal automation
QM_VERIFY_STRIPE_DOMAINS=false # Stripe domain verification
QM_SITE_UPDATE_BUSINESS=false # Business information updates
QM_CHECK_ACCOUNT_ACTIVE=false # Account status validation

# Monitoring & Analytics
QM_SCHEDULE_UTILIZATION_MONITORING=true # Resource utilization tracking (ENABLED)

Queue Manager Architectureโ€‹

Based on the queue-manager/ folder structure:

Core Components:

  • Queues/ - Individual queue processors for each business domain
  • Crons/ - Scheduled task management organized by feature area
  • Streams/ - Real-time data processing streams
  • Triggers/ - Event-driven automation handlers
  • Services/ - Business logic services for queue operations

Specialized Queue Areas:

  • Accounts - Account lifecycle and management
  • Affiliates - Partner program automation
  • Billing - Financial transaction processing
  • Communication - Email/SMS notification delivery
  • Contacts - CRM contact synchronization
  • Conversations - Message processing and routing
  • Deals - Sales automation workflows
  • Domains - DNS and domain management
  • Funnels - Marketing funnel operations
  • InstaSites - Website building and deployment
  • InstaReports - Report generation and delivery
  • OneBalance - Credit system management
  • Reviews - Reputation monitoring
  • Sites - Website management and optimization
  • Store - E-commerce transaction processing
  • Webhooks - External service integration

Key Integrations & Servicesโ€‹

# External Service Endpoints
DUDA_INTERNAL_ENDPOINT=http://localhost:5001/v1/e/duda
TWILIO_WEBHOOK_URL=https://...ngrok-free.app/v1/e/twilio/webhook
WASABI_PUBLIC_IMAGE_DOWNLOAD=http://localhost:5001/v1/e/wasabi/public/download_by_key
SHORT_URL_SERVICE=http://localhost:5002/v1/url

# Service Communication
API_BASE_URL=http://localhost:5001
SOCKET_API=http://localhost:4000
CONVERSATION_SOCKET=http://localhost:6001

Processing Capabilitiesโ€‹

  • Subscription Management - Automated billing cycles, cancellations, and activations
  • Content Generation - Website building, report creation, and thumbnail generation
  • CRM Automation - Contact processing, deal workflows, and lead nurturing
  • Financial Operations - Payment processing, credit management, and billing
  • Communication Delivery - Email/SMS notifications and messaging
  • System Monitoring - Resource utilization and health checks
  • Domain Management - DNS validation, renewals, and verification
  • Webhook Processing - External service integration and retry logic
  • Data Synchronization - Real-time streams and batch processing
  • Reputation Monitoring - Review tracking and online presence management

๐Ÿ”Œ Real-time Featuresโ€‹

DashClicks uses dual Socket.IO services for comprehensive real-time communication:

Conversation Socket Service (Port 6001)โ€‹

Dedicated messaging and communication hub:

  • Real-time Messaging - Client-to-client and internal team communication
  • Chat Rooms - Multi-participant conversation management
  • Message Delivery - Instant message routing and delivery confirmation
  • Conversation Management - Channel creation, group messaging, and prospect communication
  • Authentication Middleware - Secure socket connections with user verification
  • Message Persistence - Integration with conversation models for message history

Key Features:

  • Client messaging systems
  • Team collaboration tools
  • Prospect communication channels
  • Message threading and history
  • File sharing and media support
  • Typing indicators and read receipts

General Socket Service (Port 4000)โ€‹

System-wide real-time event distribution:

Integration Modules (based on general-socket/Integrations/):

  • Conversation - Cross-service conversation events
  • LeadFinder - Real-time lead discovery notifications
  • LiveChat - Live chat widget functionality
  • Prospect - Prospect activity and status updates
  • RestAPI - API event broadcasting
  • Shared - Common real-time utilities
  • Utils - Socket utility functions

Authentication & Security:

  • is-auth.js - Standard user authentication middleware
  • is-auth-visitor.js - Visitor/guest authentication for public features
  • scope.js - Permission-based access control for socket events

Real-time Event Categories:

  • System Notifications - Platform-wide alerts and updates
  • Live Updates - Real-time data synchronization across services
  • Lead Tracking - Prospect activity and engagement monitoring
  • Widget Communication - Live chat and form submission events
  • Cross-service Events - Inter-service communication and state synchronization
  • Dashboard Updates - Real-time analytics and metrics updates

Architecture & Scalingโ€‹

Service Communication:

# Inter-service socket communication
SOCKET_API=http://localhost:4000 # General Socket endpoint
CONVERSATION_SOCKET=http://localhost:6001 # Conversation Socket endpoint

Key Implementation Features:

  • Dual-Service Architecture - Specialized services for different real-time needs
  • Authentication Layers - Multiple auth middleware for different user types
  • Event Namespacing - Organized event routing by feature domain
  • Cross-Service Integration - Seamless communication between socket services
  • Modular Design - Plugin-based integration system for extensibility
  • Middleware Stack - Comprehensive authentication and authorization
  • Real-time Synchronization - Live data updates across all connected clients

Use Cases:

  • Client Communication - Agency-to-client messaging and support
  • Team Collaboration - Internal team chat and notifications
  • Live Chat Widgets - Website visitor engagement
  • System Alerts - Platform notifications and status updates
  • Lead Engagement - Real-time prospect interaction tracking
  • Dashboard Monitoring - Live analytics and performance metrics

๐Ÿง  AI Service Integrationโ€‹

The AI Service uses Deno (not Node.js):

# Configured in .vscode/launch.json as:
"runtimeExecutable": "deno"
"program": "${workspaceFolder}/ai-service/src/main.ts"
  • Hono framework for HTTP handling
  • TypeScript for type safety
  • OpenAI API integration
  • Separate containerization

Troubleshooting & Common Issuesโ€‹

๐Ÿšจ Common Development Problemsโ€‹

Shared Files Not Updatingโ€‹

# Problem: Changes in shared/ not reflecting in services
# Solution: Always run after editing shared files
pnpm run copySharedFiles

Service Won't Start in Debuggerโ€‹

# Problem: Port already in use
# Solution: Check running processes
lsof -i :5001 # Replace with your port
kill -9 <PID> # Kill the process

Environment Variables Not Loadingโ€‹

# Problem: .env not being read
# Solution: Check file locations
ls -la .env # Main environment
ls -la notifications/.env # Notification service

๐Ÿ” Debugging Tipsโ€‹

  1. Use VS Code Breakpoints: Set breakpoints in your code, debugger will pause
  2. Console Logs: Use console.log() - output appears in Debug Console
  3. Variable Inspection: Hover over variables during debug sessions
  4. Call Stack: Use Debug Panel to trace execution flow
  5. Environment Check: Verify .env variables in debug session

Next Steps for New Developersโ€‹

๐ŸŽฏ Learning Pathโ€‹

Week 1: Environment & Structureโ€‹

  1. Complete environment setup using this guide
  2. Start all services via VS Code debugger
  3. Explore /shared/models/ to understand data structure
  4. Review service-specific routes in each service directory

Week 2: Development Workflowโ€‹

  1. Make small changes in shared files
  2. Practice pnpm run copySharedFiles workflow
  3. Set breakpoints and debug API endpoints
  4. Write basic tests following existing patterns

Week 3: Business Logicโ€‹

  1. Study controller โ†’ service โ†’ model patterns
  2. Understand JWT authentication flow in shared/utilities/auth.js
  3. Learn Socket.IO implementation for real-time features
  4. Explore third-party integrations in external/Integrations/

Week 4: Advanced Featuresโ€‹

  1. Work with Queue Manager background jobs
  2. Implement new API endpoints with proper validation
  3. Add new integration following existing patterns
  4. Contribute to test coverage improvements

๐ŸŽ‰ Welcome to the Team!โ€‹

You're now ready to contribute to the DashClicks Back-End! This monorepo powers a comprehensive platform serving thousands of digital marketing agencies worldwide.

Remember: Always use VS Code debugger, manage shared files properly, and leverage pnpm for package management. Happy coding! ๐Ÿš€


Need help? Check the team documentation, ask in Teamwork chat, or set up a pair programming session with a senior developer.

๐Ÿ’ฌ

Documentation Assistant

Ask me anything about the docs

Hi! I'm your documentation assistant. Ask me anything about the docs!

I can help you with:
- Code examples
- Configuration details
- Troubleshooting
- Best practices

Try asking: How do I configure the API?
09:30 AM