botbase.uk

High-performance B2B lead generation platform for AI chatbot integration services. Rails 8, Docker multi-stage builds, Kamal orchestration, zero-downtime deploys. Sub-100ms TTFB, 95+ Lighthouse score.

Overview

botbase.uk is a marketing and lead generation platform for enterprise AI chatbot solutions. The site serves as the primary customer acquisition channel, showcasing service offerings, live demos, and capturing qualified leads through an intelligent contact system.

Built with Rails 8 and deployed via containerized infrastructure on Google Cloud. The architecture prioritizes performance - jemalloc memory optimization, HTTP/2 via Thruster, fingerprinted asset caching - achieving sub-100ms time-to-first-byte and 95+ Lighthouse scores.

Tech Stack

Application

  • Rails 8, Ruby 3.3
  • PostgreSQL 15
  • Hotwire (Turbo + Stimulus)
  • Tailwind CSS

Deployment

  • Docker multi-stage builds
  • Kamal orchestration
  • Google Cloud
  • Thruster (HTTP/2, gzip)

Request Flow

Traffic flows through multiple optimization layers before reaching the Rails application:

Internet (HTTPS)
    |
    v
[Kamal Proxy] -----> SSL termination, request routing
    |
    v
[Thruster] --------> HTTP/2 multiplexing, gzip, cache headers
    |
    v
[Puma] ------------> Rails app server (3 threads)
    |
    v
[PostgreSQL 15] ---> Persistent storage, ACID compliance

Key Features

Zero-Downtime Deployments

Kamal orchestrates atomic traffic switching - new container starts, health check passes, proxy routes traffic, old container drains. Database migrations run in entrypoint before app starts. ~90 second deploy time.

Memory Optimization

jemalloc replaces glibc malloc via LD_PRELOAD. 15-20% memory reduction, lower fragmentation over time. Baseline ~125MB vs ~150MB with default allocator.

Multi-Stage Docker Build

Build stage installs dependencies and compiles assets. Runtime stage copies only artifacts to clean ruby-slim base. Final image ~250MB vs ~800MB unoptimized. Non-root user for security.

Dark/Light Theme

Glassmorphism design with CSS custom properties for instant theme switching. Inline script in head prevents flash - reads localStorage before first paint. Respects system prefers-color-scheme.

Technical Challenges

Asset Cache Invalidation

1-year cache headers meant stale assets after deploys. Propshaft fingerprinting appends content hash to filenames - new deploys generate new hashes, old cached assets remain valid for in-flight requests.

Theme Flash Prevention

Theme toggle caused visible flash as JavaScript initialized. Solved by inlining critical theme script in head - reads localStorage synchronously and applies class before body renders.