Developed by ETK Technologies
DatomniX is a comprehensive multi-tenant SaaS platform for attribution and analytics. Built on a modern microservices architecture, it provides brands with unified tracking across all marketing channels, advanced attribution models, and seamless integrations with major advertising platforms.
---
---
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Client Websites & Apps β
β (Tracking Pixel β’ GTM β’ Shopify β’ Direct API) β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β HTTPS
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DatomniX Web Dashboard β
β (Next.js 14 App) β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββββ β
β β Auth β βWorkspacesβ β Brands β β Dashboard β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββββ β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββββ β
β β Events β βAttributionβ βIntegrationsβ β Settings β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββββ β
ββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ
β REST API + JWT Auth
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β NestJS API Core (apps/api) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β π₯ Event Ingestion Layer β β
β β β’ Client Pixel Endpoint (/api/v1/track) β β
β β β’ Server-to-Server API (/api/v1/events) β β
β β β’ WooCommerce Webhook Handler β β
β β β’ Shopify Webhook Handler β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β βοΈ Event Processing Pipeline β β
β β β’ Normalization β Validation β Enrichment β β
β β β’ Redis Streams Publisher β β
β β β’ 3 Parallel Consumers (30x faster) β β
β β β’ Batch Processing (100 events/batch) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β π― Attribution Engine β β
β β β’ UTM Parsing & Channel Resolution β β
β β β’ Order Exclusion Rules (tag & email based) β β
β β β’ Subscription Classification β β
β β β’ Label Generation for Path Analysis β β
β β β’ Last-Click Attribution β β
β β β’ First-Click Attribution β β
β β β’ Linear Attribution β β
β β β’ Time-Decay Attribution β β
β β β’ Position-Based Attribution β β
β β β’ Configurable Lookback Windows (1-90 days) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β π Integration Orchestrator β β
β β β’ Meta CAPI (Advanced: match keys, event filters) β β
β β β’ TikTok Events API β β
β β β’ Google Analytics 4 (GA4) β β
β β β’ Custom Webhooks β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β π Reporting & Analytics β β
β β β’ Real-time Metrics β β
β β β’ Revenue Attribution by Model β β
β β β’ Customer Journey Paths β β
β β β’ Model Comparison Analysis β β
β β β’ Export Center (CSV/JSON with scheduling) β β
β β β’ Traffic Source Analysis β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ
β
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Data & Cache Layer β
β ββββββββββββββββββββββββ ββββββββββββββββββββββββββββ β
β β PostgreSQL 14+ β β Redis 6+ β β
β β β’ Users & Auth β β β’ Event Streams β β
β β β’ Workspaces β β β’ Job Queues β β
β β β’ Brands β β β’ Session Cache β β
β β β’ Events β β β’ Real-time Counters β β
β β β’ Attributions β ββββββββββββββββββββββββββββ β
β β β’ Integrations β β
β ββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ---
apps/api/src/
βββ main.ts # Application bootstrap
βββ app.module.ts # Root module
βββ app.controller.ts # Root controller
β
βββ auth/ # Authentication & Authorization
β βββ auth.service.ts # JWT generation & validation
β βββ auth.controller.ts # Login, register, refresh
β βββ users.service.ts # User management
β βββ jwt.strategy.ts # Passport JWT strategy
β βββ jwt-auth.guard.ts # Route protection
β βββ guards/ # Custom guards
β β βββ roles.guard.ts # RBAC enforcement
β β βββ super-admin.guard.ts # Super admin access
β β βββ workspace-access.guard.ts # Workspace isolation
β βββ decorators/ # Custom decorators
β βββ current-user.decorator.ts
β βββ roles.decorator.ts
β
βββ workspaces/ # Multi-tenant workspaces
β βββ workspaces.service.ts # Workspace CRUD
β βββ workspaces.controller.ts # Workspace API
β βββ workspaces.module.ts
β
βββ brands/ # Brand management
β βββ brands.service.ts # Brand CRUD & configuration
β βββ brands.controller.ts # Brand API endpoints
β βββ brands.module.ts
β βββ dto/
β βββ create-brand.dto.ts
β
βββ ingestion/ # Event ingestion
β βββ events.controller.ts # Event tracking endpoints
β βββ poller.service.ts # Background polling
β βββ poller.processor.ts # BullMQ job processor
β βββ ingestion.module.ts
β
βββ events/ # Event processing
β βββ event-normalization.service.ts # Event standardization
β βββ events.module.ts
β
βββ redis/ # Redis integration
β βββ redis.service.ts # Streams & pub/sub
β βββ redis.controller.ts # Queue stats API
β βββ redis.module.ts
β
βββ attribution/ # Attribution engine
β βββ attribution-engine.service.ts # Attribution logic
β βββ attribution-consumer.service.ts # Stream consumer (3 parallel workers)
β βββ attribution.controller.ts # Attribution API
β βββ orders.controller.ts # Order tracking
β βββ attribution.module.ts
β
βββ reporting/ # Analytics & reporting
β βββ reporting.service.ts # Aggregation queries
β βββ reporting.controller.ts # Reporting API
β βββ reporting.module.ts
β
βββ integrations/ # Platform integrations
β βββ base-integration.ts # Base class for integrations
β βββ integration-orchestrator.service.ts # Event distribution
β βββ integrations.controller.ts # Integration management API
β βββ integrations.module.ts
β βββ meta/
β β βββ meta-integration.ts # Meta CAPI
β βββ tiktok/
β β βββ tiktok-integration.ts # TikTok Events API
β βββ ga4/
β β βββ ga4-integration.ts # Google Analytics 4
β βββ shopify/
β β βββ shopify-integration.ts # Shopify webhooks
β βββ woocommerce/
β β βββ woocommerce-integration.ts # WooCommerce webhooks
β β βββ woocommerce.controller.ts # Webhook receiver
β βββ custom/
β βββ custom-integration.ts # Custom HTTP webhooks
β
βββ admin/ # Super admin features
β βββ admin.service.ts # Admin operations
β βββ admin.controller.ts # Admin API
β βββ admin.module.ts
β
βββ docs/ # Documentation serving
β βββ docs.controller.ts # Markdown renderer
β βββ docs.module.ts
β
βββ health/ # Health checks
β βββ health.controller.ts # /health endpoint
β βββ health.module.ts
β
βββ prisma/ # Database client
βββ prisma.service.ts # Prisma singleton
βββ prisma.module.ts # Global moduleapps/web/src/
βββ app/ # Next.js App Router
β βββ layout.tsx # Root layout
β βββ page.tsx # Landing page
β βββ globals.css # Global styles
β β
β βββ login/
β β βββ page.tsx # Login page
β βββ register/
β β βββ page.tsx # Registration page
β β
β βββ dashboard/ # Protected dashboard
β βββ layout.tsx # Dashboard shell with nav
β βββ page.tsx # Overview (redirect to overview/)
β βββ overview/
β β βββ page.tsx # Main dashboard
β βββ events/
β β βββ page.tsx # Event stream
β βββ attributions/
β β βββ page.tsx # Attribution list
β βββ sources/
β β βββ page.tsx # Traffic sources
β βββ integrations/
β β βββ page.tsx # Platform integrations
β βββ pixel/
β β βββ page.tsx # Pixel setup
β βββ team/
β β βββ page.tsx # Team management
β βββ settings/
β βββ page.tsx # Account settings
β
βββ components/ # Reusable components
β βββ ui/ # shadcn/ui components
β β βββ button.tsx
β β βββ card.tsx
β β βββ dialog.tsx
β β βββ input.tsx
β β βββ table.tsx
β β βββ ... (15 components)
β β
β βββ dashboard/ # Dashboard-specific
β β βββ kpi-card.tsx
β β βββ area-chart-card.tsx
β β βββ donut-chart-card.tsx
β β
β βββ theme-provider.tsx # Dark mode support
β βββ theme-toggle.tsx # Theme switcher
β βββ workspace-selector.tsx # Workspace dropdown
β βββ brand-selector.tsx # Brand dropdown
β βββ brand-management.tsx # Brand CRUD UI
β βββ team-management.tsx # Team member UI
β βββ integration-modal.tsx # Integration config
β βββ queue-indicator.tsx # Real-time queue stats
β βββ ... (more components)
β
βββ contexts/ # React Context providers
β βββ auth-context.tsx # Authentication state
β βββ brand-context.tsx # Current brand state
β βββ settings-context.tsx # User settings
β
βββ hooks/ # Custom React hooks
β βββ use-toast.ts # Toast notifications
β
βββ lib/ # Utilities
βββ api.ts # API client functions
βββ utils.ts # Helper functions
βββ theme-tokens.ts # Theme constants---
Client Website
β (JavaScript Pixel)
POST /api/v1/track
β (Validation)
Event Normalization Service
β (Canonical Schema)
Redis Streams Publisher
β (datomnix:events:brand_id)
Stream: "datomnix:events:brand_id"
β (Consumer Group)
3x Parallel Attribution Consumers
β (Batch: 100 events)
Attribution Engine
β (Last-Click Logic)
PostgreSQL Database
β (Query)
Reporting API
β (JSON Response)
Dashboard UIUser β Login Form
β (POST /auth/login)
Auth Service
β (Validate Credentials)
Generate JWT Token
β (Include: userId, role, workspaceId)
Return Token + User Data
β (Store in localStorage)
Dashboard Pages
β (Authorization: Bearer <token>)
JWT Strategy Validates
β (Attach user to request)
Role Guards Check Permissions
β (Allow/Deny)
Protected ResourcesPurchase Event Arrives
β
Lookup Session by Session ID
β
Extract UTM Parameters from Session
β
Apply Attribution Model:
β’ Last-Click: 100% to last touch
β’ First-Click: 100% to first touch
β’ Linear: Equal split
β’ Time-Decay: Exponential weighting
β’ Position-Based: 40% first, 40% last, 20% middle
β
Create Attribution Record
β
Store in Database with:
β’ Order ID
β’ Revenue
β’ Source/Medium/Campaign
β’ Model Type
β’ TimestampEvent Published to Stream
β
Integration Orchestrator Receives Event
β
Check Brand's Active Integrations
β
For Each Integration (Parallel):
βββ Meta CAPI
β βββ POST to Graph API
βββ TikTok Events API
β βββ POST to Events API
βββ Google Analytics 4
β βββ POST to Measurement Protocol
βββ Custom Webhook
βββ POST to Custom URL
β
Log Success/Failures
β
Return Aggregated Results---
All tables include tenant_id (workspace) and where applicable brand_id for complete isolation.
#
Users & Authentication
User {
id, email, passwordHash, firstName, lastName
role: SUPER_ADMIN | USER
createdAt, updatedAt
}
WorkspaceMember {
workspaceId, userId, role: OWNER | ADMIN | MEMBER
createdAt, updatedAt
}Multi-Tenancy
Workspace {
id, name, slug, ownerId
createdAt, updatedAt
}
Brand {
id, workspaceId, name, domain
pixelApiKey, serverApiKey
timezone, currency, vertical
createdAt, updatedAt
}Events & Sessions
Event {
id, eventId (unique), brandId
eventType, sessionId, userId
source, medium, campaign, content, term
metadata (JSONB), timestamp
ingestedAt, createdAt
}
Session {
id, sessionId, brandId, userId
source, medium, campaign
firstTouch, lastTouch
createdAt, updatedAt
}Attribution
Attribution {
id, orderId, brandId, sessionId, userId
modelType, value, currency
source, medium, campaign
attributedAt, createdAt
}Integrations
Integration {
id, brandId, platform
config (JSONB), isActive
lastSyncAt, createdAt, updatedAt
}-- Performance-critical indexes
CREATE INDEX events_brand_timestamp_idx ON events(brand_id, timestamp DESC);
CREATE INDEX events_session_idx ON events(session_id);
CREATE INDEX events_event_id_idx ON events(event_id); -- Unique
CREATE INDEX attributions_brand_date_idx ON attributions(brand_id, attributed_at DESC);
CREATE INDEX attributions_source_idx ON attributions(brand_id, source, medium, campaign);
CREATE INDEX sessions_brand_user_idx ON sessions(brand_id, user_id);---
---
---
Horizontal Scaling
1. Multiple API instances behind load balancer
2. Redis Streams consumer groups for parallel processing
3. PostgreSQL read replicas for reporting queries
4. CDN for static assets
Data Volume
1. Partition events table by brand and date
2. Archive old events to object storage (S3)
3. Materialized views for complex aggregations
4. Time-series database for high-frequency metrics
Performance
1. Query result caching in Redis
2. Debounced dashboard updates
3. Webhook request buffering
4. Background job processing for heavy operations
---
GET /api/v1/health - Database + Redis connectivity---
Local Machine
βββ Docker Compose
β βββ PostgreSQL (port 5432)
β βββ Redis (port 6379)
βββ API (port 3001)
βββ Web (port 3000)Internet
β
Vercel Edge Network
β (Next.js Dashboard)
Vercel Serverless Functions
β HTTPS
Railway Platform
βββ NestJS API
βββ PostgreSQL Database
βββ Redis Instance---
---
DatomniX has been enhanced to match Northbeam-level sophistication for enterprise attribution and analytics.
#
GET/PUT /brands/{brandId}/settings/utm#
equals, contains, starts_with, and regex pattern matchingsource, medium, or campaign fieldsGET/POST/PATCH/DELETE /brands/{brandId}/settings/utm/channel-rules#
GET/POST/DELETE /brands/{brandId}/settings/exclusions/order-tagsGET/POST/DELETE /brands/{brandId}/settings/exclusions/emails#
GET/POST/DELETE /brands/{brandId}/settings/subscription-tags#
#
{
event_name: "Purchase",
event_time: 1699564800,
event_id: "evt_abc123", // For deduplication
event_source_url: "https://...",
action_source: "website",
user_data: {
em: ["hash..."], // SHA-256 hashed email
ph: ["hash..."], // SHA-256 hashed phone
client_ip_address: "1.2.3.4",
client_user_agent: "Mozilla...",
fbp: "_fbp cookie value",
fbc: "fb.1.xxx.fbclid"
},
custom_data: {
currency: "USD",
value: 99.99,
content_ids: ["product_123"],
contents: [{id: "product_123", quantity: 1}],
num_items: 1
}
}#
#
excluded: - Order was filtered by exclusion rulesunattributed:first_time / unattributed:returning - No clear sourcedirect:none - Direct traffic with no referrerreferral: - Referral from specific domain | - Attributed traffic with resolved channel#
GET /reporting/brands/{brandId}/paths
?model=linear
&lookbackDays=7
&dateFrom=2025-11-01
&dateTo=2025-11-30
&minLength=2
&maxLength=20
&labelFilter=facebook,google
&limit=100#
#
GET /reporting/brands/{brandId}/model-comparison
?model1=last_click
&model2=position_based
&lookbackDays=7
&granularity=channel
&dateFrom=2025-11-01
&dateTo=2025-11-30#
[
{
"name": "Paid Social",
"revenueModel1": 50000.00,
"transactionsModel1": 250,
"revenueModel2": 67500.00,
"transactionsModel2": 270,
"deltaRevenue": 17500.00,
"deltaPercent": 35.0,
"deltaTransactions": 20
}
]#
#
#
POST /exports
{
"brandId": "brand_123",
"dataset": "orders",
"format": "csv",
"destination": "download",
"dateFrom": "2025-11-01",
"dateTo": "2025-11-30"
}
GET /exports?workspaceId=ws_123&status=completed
GET /exports/{exportId}/download
GET /exports/scheduled#
BrandUtmSettings - Custom UTM parameter configurationBrandUtmChannelRule - Channel resolution rules with priorityBrandAttributionSettings - Model and window configurationBrandOrderExclusionRule - Tag-based order filtersBrandEmailExclusion - Email-based attribution filtersBrandSubscriptionTagMapping - Subscription categorization#
Order - Conversion events with subscription classification and exclusion trackingTouchpoint - Individual customer interactions with resolved channels and labelsPathAggregate - Pre-computed customer journey paths with metrics#
ExportJob - Manual and triggered export jobsScheduledExport - Recurring export configuration#
BrandTrackingDomain - Custom tracking domain with DNS verificationManualSpendSource - Manual spend tracking for offline channelsManualSpendEntry - Individual spend entries per dateAnnotation - Marketing annotations for timeline events#
UtmService // UTM extraction and channel resolution
ExclusionService // Order exclusion logic
SubscriptionClassificationService // Subscription categorization
LabelService // Touchpoint label generation
AttributionEngineService // Core attribution calculation
AttributionConsumerService // Event processing orchestration#
PathAggregationService // Customer path generation and aggregation
PathsController // Path analysis API endpoints#
MetaIntegration // Enhanced Meta CAPI with advanced config
IntegrationOrchestrator // Multi-platform event distribution1. Event Ingestion (Pixel/API/Webhook)
β
2. UTM Extraction & Channel Resolution
β Uses BrandUtmSettings and BrandUtmChannelRules
β
3. Touchpoint Creation
β Label generation via LabelService
β Stores: source, medium, campaign, channel, clickId, label
β
4. Order Detection (if purchase event)
β Order Exclusion Check (ExclusionService)
β Subscription Classification
β Create Order record
β
5. Attribution (if not excluded)
β Multiple models + lookback windows
β Links touchpoints to orders
β
6. Integration Distribution
β Meta CAPI (with advanced config)
β TikTok, GA4, Custom webhooks
β
7. Path Aggregation (nightly)
β Generates PathAggregate records
β Per model + window + date range#
#
-- UTM and Channel Resolution
CREATE INDEX idx_touchpoint_brand_user_ts ON touchpoints(brand_id, user_id, timestamp);
CREATE INDEX idx_touchpoint_session ON touchpoints(session_id);
CREATE INDEX idx_channel_rules_priority ON brand_utm_channel_rules(brand_id, priority);
-- Order Exclusions
CREATE INDEX idx_order_brand_date ON orders(brand_id, order_date);
CREATE INDEX idx_order_excluded ON orders(excluded);
CREATE INDEX idx_email_exclusion ON brand_email_exclusions(brand_id, email);
-- Path Aggregation
CREATE UNIQUE INDEX idx_path_aggregate_unique ON path_aggregates(
brand_id, model, lookback_days, path_hash, date_from, date_to
);
-- Model Comparison
CREATE INDEX idx_attribution_comparison ON attributions(
brand_id, model_type, lookback_days, attributed_at
);---
---
---
Last Updated: November 9, 2025
Version: 1.0.0 (Production)
Developed by: ETK Technologies