fbm affiliate program
Overview
The tracking system works across all partner apps - affiliates append /aff/{id} to any URL on any product site, and all traffic is automatically attributed. Clicks, conversions, and rebills flow into a single dashboard with per-app breakdowns.
The whitelabel solution lets affiliates spin up their own branded AI chatbot app without writing code - domain, branding, and payment configuration only. They get their own product while the underlying infrastructure stays shared.
Tech Stack
Application
- Ruby on Rails
- PostgreSQL (multi-schema)
- Hotwire
Infrastructure
- Docker
- Nginx
- DigitalOcean
Multi-Schema Architecture
PostgreSQL schema separation provides logical data isolation without multiple databases. The affiliate schema holds core business data (affiliates, clicks, conversions, payments), while logs stores the audit trail. Active Record models use table name prefixes for schema routing.
The tracking system spans multiple applications - partner apps (podruga.ai, etc.) handle click recording and conversion tracking, while this dashboard provides read-only reporting and payout management.
# PostgreSQL schema configuration
schema_search_path: "affiliate,logs,public"
# Model table routing
class Click < ApplicationRecord
self.table_name = 'affiliate.clicks'
end
class ApplicationLog < ApplicationRecord
self.table_name = 'logs.application_logs'
end
# Tracking flow
1. Affiliate gets link: https://podruga.ai/aff/{code}
2. User clicks -> partner app records click, sets cookie
3. User converts -> partner app records conversion
4. Affiliate views stats on fbmhdl.com (read-only)
Defense-in-Depth Security
Six-layer security architecture from network to application level:
Layer 1: Network - UFW firewall + SSL/TLS Layer 2: Rate Limit - Rack::Attack (IP + username) Layer 3: Validation - CSRF tokens Layer 4: Auth - BCrypt hashing, secure sessions Layer 5: Authorization - before_action guards Layer 6: Audit - ApplicationLog trail