π― Projects Module
The Projects Module is the operational backbone of DashClicks' digital marketing service delivery platform. It orchestrates the complete lifecycle of managed servicesβfrom initial order placement through onboarding, setup, active management, and ongoing optimizationβensuring seamless coordination between agencies, their clients, and service delivery teams.
π― Overviewβ
Purposeβ
The Projects module solves the complex challenge of managing multi-tiered digital marketing service delivery at scale. It handles:
- Service Lifecycle Management: Orchestrating the full journey from order β onboarding β setup β active delivery β reporting
- Multi-Party Coordination: Managing interactions between platform admins, agency partners, end clients, and delivery teams
- Onboarding Workflows: Streamlining client data collection through form management and approval processes
- Task & Communication: Enabling real-time collaboration with status tracking and notification systems
- Documentation & Reporting: Maintaining comprehensive records of service delivery, files, and performance metrics
- Client Portal Integration: Providing white-labeled client dashboards with SSO and scoped access controls
Supported Service Typesβ
The module manages delivery for these managed subscription services:
Advertising Services:
- Meta (Facebook) Ads - Campaign setup, optimization, and reporting
- Google Ads - Search, Display, Shopping campaigns
- TikTok Ads - Creative-first advertising campaigns
SEO & Local Services:
- SEO Management - Technical optimization and content strategy
- Backlink Building - Link acquisition campaigns
- GBP (Google Business Profile) - Local ranking optimization
Content Services:
- Content Creation - Blog posts, articles, website content
- Social Media Posts - Multi-platform content creation
Web & Listings:
- Website Development - Custom site builds
- Business Listings Management - Multi-directory presence
Service Tiersβ
Most services are offered in performance-based tiers:
- Pro - Entry-level service with essential features
- Plus - Enhanced service with expanded deliverables
- Platinum - Premium tier with maximum deliverables and priority support
π Directory Structureβ
internal/api/v1/projects/
βββ π index.js # Express router setup
βββ π README.md # Module documentation
β
βββ π controllers/ # Request handlers (13 controllers)
β βββ accounts.controller.js # Sub-account listing for projects
β βββ activity.controller.js # Activity history tracking
β βββ analytics.controller.js # Revenue and performance metrics
β βββ dashboard.controller.js # Dashboard data aggregation
β βββ files.controller.js # File storage management
β βββ notebooks.controller.js # Project documentation
β βββ onboardings.controller.js # Onboarding workflow management
β βββ pulses.controller.js # Real-time project updates
β βββ reports.controller.js # Service delivery reports
β βββ subscriptions.controller.js # Subscription lifecycle
β βββ task.controller.js # Task and communication management
β βββ work-summary.controller.js # Weekly work summaries
β
βββ π routes/ # API route definitions with validation
β βββ index.js # Route aggregation
β βββ ... # (mirrors controllers)
β
βββ π services/ # Business logic layer (13 services)
β βββ accounts.service.js # Account retrieval and filtering
β βββ task.service.js # Task orchestration (2066 lines)
β βββ onboardings.service.js # Onboarding state machine (780 lines)
β βββ analytics.service.js # Performance calculations
β βββ files.service.js # File CRUD operations
β βββ ... # (other services)
β
βββ π validations/ # Joi validation schemas
β βββ ... # (validation for each feature)
β
βββ π utils/ # Utility functions
β βββ analytics.js # Time/cost calculations
β
βββ π tests/ # Test suites (7 test files)
ποΈ MongoDB Collectionsβ
π Detailed Schema: See Database Collections Documentation
Core Projects Collectionsβ
projects.tasksβ
- Purpose: Task management and communication between parties
- Model:
shared/models/projects-tasks.js - Primary Use: Task creation, status tracking, communication threads, pending actions
projects.pulseβ
- Purpose: Real-time project status updates and milestones
- Model:
shared/models/projects-pulse.js - Primary Use: Status broadcasts, timeline events, stakeholder notifications
projects-filesβ
- Purpose: Document storage with metadata
- Model:
shared/models/projects-file.js - Primary Use: File uploads, client-specific document management, access control
projects-notebooksβ
- Purpose: Structured project documentation
- Model:
shared/models/projects-notebook.js - Primary Use: Service documentation, internal notes, client-visible docs
projects-dashboard-preferencesβ
- Purpose: Client portal SSO and scope configuration
- Model:
shared/models/projects-dashboard-preferences.js - Primary Use: White-label dashboard setup, permission scoping, sub-account filtering
Store Collections (Read-Heavy)β
_store.ordersβ
- Purpose: Order records linking subscriptions to services
- Operations: Read (primary), Status updates
- Usage: Order lookups, timeline tracking, onboarding status
_store.subscriptionsβ
- Purpose: Active subscription data from Stripe
- Operations: Read (primary), Metadata updates
- Usage: Service status, billing info, cancellation tracking
Onboarding Collectionsβ
onboarding.typeform.requestsβ
- Purpose: Onboarding form requests sent to clients
- Operations: Create, Read, Update status
- Usage: Form generation, tracking sent forms, resend logic
onboarding.typeform.responseβ
- Purpose: Client-submitted onboarding form data
- Operations: Create, Read, Update (approval workflow)
- Usage: Response validation, approval/issue tracking, data extraction
ποΈ Architecture Overviewβ
Design Pattern: Service-Oriented Architectureβ
The Projects module follows a layered architecture:
Request β Route (Validation) β Controller (HTTP) β Service (Business Logic) β Models (Data)
Key Responsibilities:
- Coordination Layer (Controllers) - HTTP handling, auth checks, response formatting
- Business Logic Layer (Services) - Complex aggregations, multi-collection orchestration, state machines
- Data Access Layer (Models) - MongoDB operations, schema validation
Critical Design Decisionsβ
Dashboard Preferences Pattern:
The module implements sophisticated access control for white-labeled client portals:
// SSO and Client Dashboard access controlled via preferences
if (dashboardPreferences?.allow_client_dashboard || dashboardPreferences?.sso) {
// Apply scoped filtering
options.parent_account = dashboardPreferences.parent_account;
options._id = { $in: dashboardPreferences.sub_account_ids };
// Apply scope restrictions
if (!dashboardPreferences.scopes.includes('activity.onboarding_dates')) {
delete response.createdAt; // Hide sensitive timestamps
}
}
This enables:
- White-labeled client portals with custom branding
- Granular permission control at feature level
- Multi-sub-account access for agency clients
- Selective data exposure based on scopes
Why Aggregation-Heavy?
- Multi-tenant data requires complex filtering across 5-10 collections
- Performance: Single aggregation pipeline vs multiple queries
- Client portal access requires sophisticated permission checks at query time
- Rich data presentation needs (tasks with order + subscription + account + user data)
π Feature Modulesβ
Core Service Managementβ
- π Accounts - Sub-account listing and filtering for project views
- οΏ½ Activity - Event logging, status change history, audit trails
- π Analytics - Revenue metrics, profit calculations, retention tracking
- π Dashboard - Dashboard data aggregation and client portal views
Task & Communicationβ
- οΏ½π Task Management - Task lifecycle, communication threads, pending actions, multi-party coordination
- π Onboardings - Form workflows, approval processes, client data collection
- π Pulses - Real-time project status updates and milestones
Data & Documentationβ
- π Files - Document storage, client-specific file organization, secure access control
- π Notebooks - Project documentation, structured notes, collaborative editing
- π Reports - Service delivery reports, performance tracking, client reporting
- οΏ½ Work Summaries - Weekly work summary generation
Subscription Managementβ
- οΏ½ Subscriptions - Service status tracking, order timelines, subscription lifecycle
π Core Data Flowsβ
Order to Active Service Flowβ
flowchart TD
A[π Order Placed in Store] --> B[π¦ Order Created]
B --> C{Service Type?}
C -->|Managed Service| D[π Generate Onboarding Request]
C -->|Self-Service| E[β
Auto-Approve]
D --> F[π€ Send Onboarding Form]
F --> G{Form Submitted?}
G -->|β³ Waiting| H[Status: sent]
G -->|β
Submitted| I[Status: received]
I --> J[π Review Submission]
J --> K{Issues Found?}
K -->|β Issues| L[Status: issues]
K -->|β
Approved| M[Status: approved]
L --> N[π Request Revision]
N --> G
M --> O[π Queue Setup Tasks]
E --> O
O --> P[π Active Service Delivery]
style A fill:#e1f5ff
style P fill:#e1ffe1
style L fill:#ffe1e1
Task Communication Flowβ
sequenceDiagram
participant Agency
participant Platform
participant Client
participant System
Platform->>System: Create Task (type: onboarding_issues)
System->>System: Store in projects.tasks
System->>Agency: Notify via Socket + Email
Agency->>System: Reply to Task
System->>Platform: Notify Response
Platform->>System: Update Status (completed)
System->>System: Log Activity
System->>Agency: Notify Completion
System->>Client: Update Dashboard (if applicable)
π Authentication & Authorizationβ
Authentication Layersβ
- JWT Token Validation - All routes require valid JWT
- Account Association - User must belong to account
- Dashboard Preferences - SSO/client dashboard users have restricted access
- Role-Based Access - Some features require specific roles (e.g., PROJECT_ROLES)
Authorization Patternsβ
Agency Access (Full Access):
{
account_id: agency_id,
parent_account: agency_id,
// Full access to all sub-accounts
}
Client Dashboard Access (Scoped):
{
dashboardPreferences: {
allow_client_dashboard: true,
parent_account: agency_id,
sub_account_ids: [allowed_sub_account_ids],
scopes: ['tasks.view', 'files.download', ...]
}
}
βοΈ Configurationβ
Key Constantsβ
// Managed service types
const MANAGED_SUBSCRIPTIONS = [
'facebook_ads',
'google_ads',
'tiktok_ads',
'seo',
'backlinks',
'gbp_ranking',
'content',
'social_posts',
'site',
'listings',
];
// Task types
const TASK_TYPES = [
'onboarding_issues',
'onboarding_submission',
'onboarding_qa',
'onboarding_approved',
'subscription_past_due',
'request',
'approval',
'setup',
];
// Onboarding statuses
const ONBOARDING_STATUSES = ['pending', 'sent', 'received', 'issues', 'approved'];
Supported Scopesβ
const AVAILABLE_SCOPES = [
'tasks.view',
'tasks.create',
'tasks.reply',
'files.view',
'files.download',
'files.upload',
'activity.view',
'activity.onboarding_dates',
'reports.view',
'analytics.view',
'onboardings.view',
];
β οΈ Important Notesβ
- π¨ Data Isolation: Client dashboard queries MUST filter by
dashboardPreferences.sub_account_idsto prevent data leakage - π‘ Scope Enforcement: Always check
dashboardPreferences.scopesbefore exposing sensitive data - π Task Creator Field: The
creatorfield distinguishes platform tasks ('dashclicks') from agency tasks - β‘ Aggregation Performance: Ensure proper indexes on
parent_account,account_id,subscription,order_id - π Real-time Updates: Task status changes emit socket events for live dashboard updates
- π Onboarding State Machine: Status progression is mostly one-way (except issuesβreceived via revision)
π Related Documentationβ
- Store Module - Order and subscription management
- Accounts Module - Account hierarchy and permissions
- Database Collections - Detailed schema documentation
Last Updated: 2025-10-08
Module Version: v1
API Base Path:/v1/projects