fbm admin panel

Centralized control center for the fbmhdl.com affiliate program and a multi-tenant AI chatbot codebase - real-time analytics, fraud detection, content management, and operational tooling from a single interface.

Internal Tool

Overview

A production-grade Ruby on Rails 8 administrative dashboard managing multiple AI-powered chat applications serving thousands of users. The panel implements a sophisticated multi-database, multi-tenant architecture that enables managing multiple apps and their regional variants from a unified interface.

Key capabilities include real-time analytics dashboards, algorithmic fraud detection with risk scoring, LLM testing playground, payment aggregation across 6 processors, affiliate program management, centralized logging with automated alerts, and blog content management with cross-server synchronization.

Screenshots

Dashboard - Analytics overview

Dashboard with real-time metrics, user growth charts, and activity heatmaps

Centralized logging

Centralized log aggregation with filtering, search, and real-time streaming

LLM Testing Playground

LLM Testing Playground for API experimentation and model comparison

Tech Stack

Backend

  • Ruby on Rails 8.0.2
  • PostgreSQL 16 (multi-schema)
  • Solid Queue / Cache / Cable
  • Devise + Pundit
  • Puma application server

Frontend

  • Hotwire (Turbo + Stimulus)
  • Tailwind CSS
  • Chartkick + Groupdate
  • Pagy pagination
  • Importmap (ESM)

Data Architecture

  • Read-only external DBs
  • Thread-safe tenant switching
  • PostgreSQL schema isolation
  • Cross-database queries

Infrastructure

  • DigitalOcean + Nginx
  • CloudFlare CDN + SSL
  • systemd services
  • Zero-downtime deploys

Multi-Tenant Architecture

Thread-safe tenant context switching with PostgreSQL schema-based isolation. Each tenant (app + locale combination) operates in its own schema with dynamic SET search_path routing. Session-persisted tenant selection with real-time UI switching.

Read-only database protection via abstract base class pattern - all write operations blocked at model level, with selective WritableBase exceptions for authorized content management.

# Thread-safe tenant switching with schema isolation
around_action :with_tenant_schema

def with_tenant_schema
  PodrugaBase.connection_pool.with_connection do |conn|
    conn.execute("SET search_path TO #{current_tenant.schema}")
    yield
  end
end

# Read-only protection with selective writes
class PodrugaBase < ActiveRecord::Base
  def readonly? = true
  def save(*) = raise ActiveRecord::ReadOnlyRecord
end

class BlogPost < PodrugaWritableBase  # Exception for CMS
end

Key Features

Real-Time Analytics

Live dashboards showing user metrics (subscription tiers, verification rates), revenue tracking across payment processors, engagement analytics (active users, message volume), and AI character popularity rankings. Chartkick + Groupdate for temporal aggregations.

Fraud Detection

Algorithmic multi-account detection with risk scoring (0-100). Identifies suspicious patterns: IP clustering, burst account creation, sequential emails, similar names via Levenshtein distance. Risk-ranked IP lists with timeline visualizations and subnet analysis.

LLM Testing Playground

Comprehensive AI model testing interface - chat completions with SSE streaming, image generation/editing/upscaling, face swapping, model discovery, template management, and metrics tracking (latency, tokens, cost estimation).

Payment Aggregation

Unified view across 6 payment processors (card, P2P, regional, crypto). Transaction management, refund handling, dispute tracking, and reconciliation with audit trails.

Blog CMS

ActionText-powered content editor with Stimulus autosave, automatic thumbnail generation, draft/published workflow, and SSH-based cross-server image synchronization.

Logging & Monitoring

Centralized log aggregation with multi-level filtering, app-specific views, real-time Turbo Streams updates, full-text search, error rate metrics, and automated Telegram/email alerts for critical errors.

Technical Challenges

Multi-Database Transaction Isolation

Rails 8 changed connection pool management, causing connection leaks when switching databases. Implemented explicit pool management with with_connection blocks and proper schema path setting per request.

Streaming LLM Responses

Traditional HTTP couldn't handle real-time token streaming. Built Server-Sent Events (SSE) implementation with session-based parameter storage and GET-based EventSource connections for browser compatibility.

Fraud Detection at Scale

Identifying multi-account abuse across thousands of users without performance impact. Efficient SQL aggregations in single queries, subnet-aware IP detection, computation caching, and lazy evaluation of detailed analysis.

High-Performance Pagination

Standard pagination on tables with millions of rows caused timeouts. Pagy with cursor-based pagination, minimal COUNT operations, and index-optimized ordering keeps response times fast.

Why Rails 8?

Solid Suite

Database-backed Queue, Cache, and Cable eliminate Redis dependency entirely.

Native Multi-DB

First-class support for multiple databases without third-party gems.

Hotwire

Rich interactivity without maintaining a separate frontend codebase.

Developer Speed

Rapid iteration on admin features without compile steps or build complexity.

300K+

Daily Logs

<100ms

Response Time

99.9%

Uptime

0

Redis Dependencies