Accounts Module
The Accounts Module provides a comprehensive account management system that handles multi-tenant operations, user workflows, domain configuration, and resource management within the DashClicks platform.
Module Overview
The Accounts module is divided into specialized submodules for better organization and maintainability. Each submodule focuses on specific aspects of account management while maintaining seamless integration across the entire system.
Accounts Submodules
🏢 Account Management
Core Account Operations
- Main account creation through public signup process
- Sub-account creation for multi-tenant management
- Project-based account creation and management
- Account lifecycle operations including archival and restoration
- Advanced filtering and search capabilities
- Account hierarchy management with parent-child relationships
👥 User Invitations & Management
User Workflow Management
- User invitation workflows with JWT token security
- Bulk invitation processing through CSV import
- Invitation status management and tracking
- Account-user association management
- Owner information and permission management
- Customizable invitation emails with branding
🌐 Domain Management
Custom Domain Configuration
- DashClicks subdomain generation and management
- Custom domain configuration with DNS verification
- Stripe domain verification for payment processing
- Domain lifecycle management and cleanup operations
- SSL certificate handling and renewal
🔓 Public Account Services
White-label Account Creation
- Public account request management and processing
- Token-based verification and account creation
- Approval workflows for public account requests
- White-label branding and customization support
- Public account lifecycle management
🔗 Integration Management
Third-Party Service Integration
- Google services (Analytics, Ads, Business Profile)
- Social media platforms (Facebook, TikTok, Bing Ads)
- Call tracking services (CallRail, CallTrackingMetrics)
- Payment processing (Stripe, SquareUp)
- SEO tools and business listing management
- Real-time integration status monitoring
📁 Content & Resource Management
File and Content Operations
- File management with cloud storage integration
- Project notebook creation and management
- Order tracking and fulfillment monitoring
- Account resource usage and balance tracking
- Point-of-contact information management
⚙️ Account Configuration & Branding
Customization and Settings
- Account branding and visual customization
- Onboarding progress tracking and management
- Account configuration and preference management
- Communication preference and DND settings
- Business profile integration and management
Technical Architecture
Directory Structure
internal/api/v1/accounts/
├── index.js # Module router setup
├── README.md # Module documentation
├── v1-domains.json # Legacy domain configuration
├── controller/ # Express route handlers
│ ├── index.js # Main account controller
│ └── public.account.js # Public account operations
├── routes/ # Route definitions
│ └── index.js # Account route definitions
├── services/ # Business logic layer
│ ├── index.js # Service exports
│ ├── account.service.js # Core account business logic
│ └── public.account.service.js # Public account operations
├── schemas/ # Joi validation schemas
│ ├── account.js # Account validation schemas
│ └── domain.js # Domain validation schemas
├── utils/ # Utility functions
│ └── account.js # Account utility functions
└── tests/ # Test suites
├── account.test.js # Account functionality tests
└── testing_constants.js # Test constants and fixtures
MongoDB Collections Overview
The Accounts module interacts with 25+ MongoDB collections across different domains:
Core Account Collections
_accounts- Main account records with configuration and relationships_users- User records with account associations and permissionscrm.contacts- Business contact information and relationships
Store & Commerce Collections
_store.subscriptions- Account subscriptions and tier management_store.orders- Order tracking and fulfillment data_store.prices- Pricing configurations and service tiers
Integration Collections
- Token Collections: Google, Facebook, Stripe, TikTok, CallRail integration tokens
- Configuration Collections: Service-specific settings and configurations
- Analytics Collections: Integration analytics and performance data
Content & Resource Collections
projects-files- Account file storage and managementprojects-notebooks- Project notebook content and metadataaccount-public-requests- Public account creation requestsqueues- Background processing and bulk operations
Key System Capabilities
Multi-Tenant Architecture
- Account Hierarchy: Parent-child account relationships for white-label operations
- Permission System: Role-based access control with owner privileges
- Data Isolation: Secure data separation between account hierarchies
- Resource Management: Account-specific resource allocation and usage tracking
Integration Ecosystem
- 38+ Service Methods: Comprehensive service coverage across all account operations
- External API Integration: 10+ third-party service integrations
- Real-time Status Monitoring: Live integration health checking and validation
- Token Management: Secure API token storage and validation
Scalable Processing
- Queue System: Background processing for bulk operations
- MongoDB Aggregation: Complex data processing with aggregation pipelines
- Pagination Framework: Efficient handling of large datasets
- Transaction Management: Database transactions for critical operations
Getting Started
Quick Navigation
Each submodule contains detailed documentation including:
- API Endpoints: Complete endpoint listings with request/response details
- Service Methods: Detailed service method documentation with business logic
- Workflows: Visual workflow diagrams showing process flows
- Technical Implementation: Architecture details and integration patterns
- MongoDB Collections: Database schema and collection relationships
Common Use Cases
Setting Up a New Account
- Main Account Creation: Use Account Management for public signup workflows
- Domain Configuration: Configure custom domains via Domain Management
- User Invitations: Invite team members through User Invitations
- Integration Setup: Connect services via Integration Management
Managing Sub-Accounts
- Project Creation: Create project-based accounts via Account Management
- User Management: Handle user associations through User Invitations
- Branding Setup: Customize appearance via Account Configuration
- Resource Management: Monitor usage through Content & Resource Management
White-Label Operations
- Public Account Setup: Enable public account creation via Public Account Services
- Branding Customization: Configure white-label branding via Account Configuration
- Domain Setup: Configure custom domains via Domain Management
- Integration Configuration: Set up service integrations via Integration Management
System Statistics
- 38+ Service Methods across all submodules
- 25+ MongoDB Collections for comprehensive data management
- 10+ Third-Party Integrations for external service connectivity
- 7 Specialized Submodules for organized functionality
- Multi-tenant Architecture supporting unlimited account hierarchies