Dashboards Application Overview
Legacy System Notice: Dashboards is a standalone Node.js application that has not yet been incorporated into BERT. A serverless migration plan exists to retire this application by splitting it into a CDK-based Audit Repository and migrating all user-facing functionality to BERT.
What is Dashboards?
The Dashboards application provides every person at Path2Response with an individualized and actionable view into the metrics, opportunities, tasks, and data that need their attention. It serves as the central hub for business intelligence, financial operations, and data synchronization across the company.
Purpose
Dashboards serves three primary functions:
- Business Intelligence - 30+ specialized reports covering financial, operational, development, and client management aspects
- Data Synchronization - The Audit system synchronizes data between Salesforce, QuickBooks, MongoDB, Slack, and Jira
- Financial Operations - Invoice generation, payment recording, broker commission processing, and revenue forecasting
Current Architecture
Technology Stack
| Component | Technology |
|---|---|
| Runtime | Node.js |
| Framework | Express |
| View Engine | EJS templates |
| Authentication | Google OAuth 2.0 via Passport |
| Session Management | express-session with file store |
| Process Manager | PM2 |
Project Structure
The application consists of two main components:
/dashboards/
├── app.js # Main Express server
├── /dashboards/ # Dashboard modules (account, finance, engineering)
├── /routes/ # Express route handlers
├── /views/ # EJS templates
├── /public/ # Static assets (CSS, client-side JS)
├── /users/ # User data storage (JSON files)
├── /sessions/ # Session file storage
└── /reports/ # Audit and reporting system
├── audit.js # Main audit script
├── /audit/ # Audit data output (JSON files)
├── /cache/ # Report cache
└── /lib/ # Core business logic
├── /audit/ # Data synchronization engine
├── /forecast/ # Revenue prediction engine
├── /reports/ # 30+ report modules
└── /common/ # Shared utilities
Core Systems
1. Audit System
The Audit System is the core data synchronization engine. It fetches data from multiple external sources, assembles and processes it, performs analysis, and saves structured data that powers all reports and dashboards.
Six-Stage Pipeline
Load → Fetch → Assemble → Process → Analyze → Save
- Load - Load existing Google users/groups and configuration
- Fetch - Pull raw data from external sources
- Assemble - Combine and structure raw data
- Process - Transform and enrich assembled data
- Analyze - Identify issues, generate findings, calculate metrics
- Save - Persist processed data to JSON files
Data Sources
| Source | Data Retrieved |
|---|---|
| Salesforce | Accounts, Opportunities, Tasks, Users |
| QuickBooks | Invoices, Payments, Customers, Bills, Estimates |
| MongoDB | Operations, Statistics, Order Processing |
| Slack | Users and Groups |
| Jira | Sprints, Issues, Users |
Running Audits
# Incremental audit (only changed data since last run)
./audit.js -d
# Complete audit (fetch all data from scratch)
./audit.js -c -d
Standard Audit Flow (Production)
run_audit.sh
├── audit.js -d
├── clear_cache.sh
└── [Production Only]
├── generate_invoices.sh
├── record_payments.sh
├── record_mailfiles.sh
├── update_salesforce.sh
└── sync_to_s3.sh
2. Reports System
The Reports System generates comprehensive business intelligence reports, transforming audit data into actionable insights. It consists of 30+ specialized reports.
Report Categories
Financial Reports
| Report | Purpose |
|---|---|
revenue.js | Monthly revenue tracking with daily breakdown |
invoicing.js | Invoice management and credit memo processing |
billing.js | Outstanding balances and payment status |
broker_commissions.js | Monthly broker commission calculations |
dso.js | Days Sales Outstanding and receivables aging |
payment_history.js | Historical payment trends |
recurring.js | Year-over-year revenue comparisons |
Client Management Reports
| Report | Purpose |
|---|---|
status.js | Account status overview by vertical/classification |
opportunities.js | Sales pipeline and win/loss analysis |
client_results.js | Client ROI and performance benchmarking |
titles.js | Title/account management and relationships |
Operations Reports
| Report | Purpose |
|---|---|
production.js | Job tracking and production schedules |
mailings.js | Mail file tracking and drop analysis |
files.js | File transfer and data file inventory |
Development Reports (Jira Integration)
| Report | Purpose |
|---|---|
sprint.js | Current sprint status |
backlog.js | Product backlog overview |
branches.js | Git branch management and age analysis |
grooming.js | Backlog grooming status |
Report Architecture
Reports follow a standard pattern:
- Define audit data requirements (
audit_parts) - Load audit data via
loadAudit - Process data according to business rules
- Generate HTML output via
HtmlBuilder - Return HTML string or JSON data
Reports are cached in /reports/cache/ and invalidated when new audits complete.
3. Forecast System
The Forecast System is a sophisticated revenue prediction engine that analyzes historical ordering patterns to forecast future revenue up to 3 years out.
“The best predictor of future behavior is past behavior.”
Four-Stage Pipeline
Audit Data → Analyze → Predict → Forecast → Google Sheets
- Analyze - Consolidate orders monthly, detect ordering frequency
- Predict - Detect trends and statistical patterns
- Forecast - Generate revenue projections
- Google - Publish results to Google Sheets
Account Classifications
By Maturity:
- Mature Titles - Ordering with P2R for ~1 year or more (high confidence)
- Young Titles - New to P2R, limited history (uses vertical averages)
- Stubbed Titles - Placeholder accounts for projected BizDev pipeline
By Vertical: Catalog, DTC, Nonprofit, Non Participating, PreScreen, Publishing
By Classification: Class A (largest), Class B, Class C, Class D (smallest)
Key Features
- Custom year definition (365 days from first order, not calendar)
- Monthly order consolidation for consistent analysis
- CV (credit mailer) filtering from revenue trends
- Forecast locking after 3rd of each month
- New client acquisition modeling from BizDev pipeline
Business Process Scripts
Core Operations
| Script | Purpose | Frequency |
|---|---|---|
run_audit.sh | Complete audit cycle orchestration | Cron (multiple times daily) |
generate_invoices.sh | Create QuickBooks invoices | After audit (production) |
record_payments.sh | Record QB payments in Salesforce | After audit (production) |
record_mailfiles.sh | Update Salesforce with mail file data | After audit (production) |
update_salesforce.sh | Push calculated statistics to Salesforce | After audit |
Monthly Processes
Broker Commissions - Critical monthly finance process:
- Finance validates broker invoices and credit memos
- Engineering runs
generateBrokerCommissions.js -m YYYY-MM - System creates Journal Entries, Bills, and Vendor Credits in QuickBooks
- Finance reconciles and closes books
# Run for previous month (e.g., if current month is July 2026)
./generateBrokerCommissions.js -m 2026-06
Revenue Forecasting
# Generate algorithmic revenue forecast
./forecast_revenue.sh
Output written to /reports/cache/revenueForecast/ and published to Google Sheets.
Integration Points
Data Pipeline
MongoDB/Salesforce/QuickBooks → Audit → Cache → Reports → Dashboards
Authentication Flow
Google OAuth → Passport → Session → User JSON files
External URLs
| System | Base URL |
|---|---|
| Salesforce | https://path2response.lightning.force.com/lightning/r/ |
| QuickBooks | https://qbo.intuit.com/app/ |
| Jira | https://caveance.atlassian.net/browse/ |
| Dashboards | https://dashboards.path2response.com/ |
Environment Configuration
Required Environment Variables
# Salesforce
SALESFORCE_ACCOUNT="account"
SALESFORCE_PASSWORD="password"
SALESFORCE_TOKEN="token"
# Slack
SLACK_TOKEN="token"
# MongoDB
MONGO_ORDERPROCESSING="connection_string"
MONGO_OPERATIONS="connection_string"
MONGO_STATISTICS="connection_string"
# AWS
P2R_BUCKET_URI="s3://bucket-name"
P2R_RUNTIME_ENVIRONMENT="production" # Controls post-audit operations
Serverless Migration Plan
Executive Summary
The current Dashboards repository will be retired and split into two projects:
- New Audit Repository (CDK Serverless) - Core data processing, audit, forecast, and post-audit tools
- BERT Integration - All user-facing functionality including routes, views, and report generation
Migration Phases
Phase 1: Create Audit Repository (CDK)
- Extract
/reports/lib/audit/→ Lambda functions - Extract
/reports/lib/forecast/→ Step Functions workflow - Migrate post-audit scripts → EventBridge + Lambda
- Store data in S3 instead of local JSON files
Phase 2: Migrate User-Facing to BERT
- Convert Express routes → BERT React Router
- Convert EJS templates → React components
- Convert report modules → BERT report components
- Migrate authentication to BERT’s auth system
Phase 3: Integration and Testing
- Connect BERT to Audit Repository APIs
- Parallel operation with gradual user migration
- Performance validation
Phase 4: Retirement
- Complete migration of all users
- Decommission Dashboards repository
Target Architecture
┌─────────────────────────────────────────────────────────────┐
│ BERT Application │
│ (All Dashboard/Report UI) │
│ • Routes (migrated from /routes) │
│ • Components (migrated from /views + /reports/lib/reports) │
│ • Dashboards (migrated from /dashboards) │
└──────────────────────┬──────────────────────────────────────┘
│ API Calls
↓
┌──────────────────┐
│ Audit Repository │
│ (CDK Project) │
│ API Gateway │
└──────┬───────────┘
│
┌──────────────┼────────────┐
↓ ↓ ↓
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Lambda │ │ Lambda │ │ Step │
│ (Audit) │ │(Forecast)│ │Functions │
└─────┬────┘ └─────┬────┘ └─────┬────┘
│ │ │
└────────────┼────────────┘
↓
┌────────────────────────────┐
│ Data Storage │
│ S3 Buckets | EventBridge │
│ (Audit/Forecast/Cache) │
└────────────────────────────┘
AWS Services in Target Architecture
| Service | Purpose |
|---|---|
| Lambda | Audit functions, forecast functions, post-audit tools |
| Step Functions | Long-running audit/forecast orchestration |
| EventBridge | Scheduled audit triggers |
| S3 | Audit data, forecast results, cache storage |
| API Gateway | BERT integration endpoints |
| SQS/SNS | Process notifications |
| Systems Manager | Configuration and secrets |
Key Benefits
- Scalability - Automatic scaling based on demand
- Availability - Multi-region deployment options
- Maintenance - Reduced server management overhead
- Cost - Pay-per-use model vs. always-on EC2
Risk Mitigations
| Risk | Mitigation |
|---|---|
| Lambda cold starts | Provisioned concurrency for critical functions |
| 15-minute Lambda timeout | Step Functions for long-running processes |
| Session management | DynamoDB with TTL or JWT tokens |
| File storage migration | S3 with versioning and lifecycle policies |
Related Documentation
- Data Tools Overview - Another legacy system also targeted for BERT migration
- BERT Overview - Target platform for consolidated applications
- Production Team Overview - Production operations that use Dashboards
- Data Acquisition Overview - Data operations that trigger audits
Important Notes
- Audit freshness is critical - Most operations require recent audit data
- Never run multiple audits simultaneously
- Production safety - Many modules include testing flags to prevent accidental modifications
- Network access - MongoDB connections require VPN/developer network access
- Broker commissions - Requires Finance department coordination before running
- Data dependencies - Reports depend on audit system; forecast depends on audit
Source: Dashboards repository documentation (README.md, reports/README.md, lib/README.md, lib/audit/README.md, lib/forecast/README.md, lib/reports/README.md) Documentation created: 2026-01-24