development

AI Chaos: Building an AI Image Generation Platform

Date Published

🎨 What This Post Covers

The journey of building AI Chaos — a comprehensive AI image generation platform powered by Ruby on Rails, Telegram Bot API, and multiple AI providers. From architecture decisions to public beta launch.

Introducing AI Chaos

We just launched AI Chaos into public beta — a full-featured AI image generation platform that lives entirely within Telegram. Users can generate stunning AI artwork through natural language prompts, with a public gallery showcasing the best creations at aichaos.ru.

What is AI Chaos?

AI Chaos combines three interconnected components:

🤖 Telegram Bot

The primary user interface — interact with AI through natural language in @aichaos_bot

🖼️ Web Gallery

Public showcase at aichaos.ru with search, grid display, and multilingual support

⚙️ Rails Backend

Powerful API orchestrating multiple AI providers with background job processing

Architecture Overview

The platform leverages a modern Ruby stack designed for reliability and scalability:

Tech Stack

  • Ruby on Rails 8.0.1 — Core backend framework
  • PostgreSQL — Persistent data storage
  • Sidekiq + Redis — Background job processing
  • Shrine + AWS S3 — Image upload and CDN delivery
  • Searchkick + OpenSearch — Full-text search across generations
  • ActiveAdmin — Administration interface
  • Sentry — Error tracking and monitoring

⚠️ Multi-Provider Architecture

One of our key design decisions was supporting multiple AI providers from day one. The system integrates with Together AI, local Ollama models, and ComfyUI workflows — allowing us to route requests optimally and add new providers without code changes.

Core Features

AI Image Generation

Users can generate images using state-of-the-art AI models:

🎯 Available Models

  • Flux.1
  • Stable Diffusion 3.5
  • DreamShaper XL
  • Shuttle 3 Diffusion
  • More models added regularly

📐 Aspect Ratios

  • 1:1 (Square)
  • 3:4 (Portrait)
  • 9:16 (Mobile portrait)
  • 4:3 (Standard)
  • 16:9 (Widescreen)
  • Custom dimensions

Monetization & Credits

We built a sustainable credit economy:

Credit System

  • 10 free daily credits for registered users
  • Paid credits via Telegram Stars
  • Premium tiers with increased limits
  • Referral program with invite rewards
  • Promo code system for campaigns

💡 Why Telegram Stars?

Telegram's native payment system provides a seamless checkout experience without leaving the app. Users purchase Stars, exchange them for credits, and start generating — all within the familiar Telegram interface.

Technical Implementation

Data Models

The core data structure reflects the generation pipeline:

User          # Telegram users with credits and settings
Prompt        # User input with moderation status
Generation    # Generated images with AI metadata
AI            # Available models with cost configuration
Payment       # Transaction tracking

Background Job Pipeline

Sidekiq orchestrates the complete generation workflow:

Job Flow

  1. BotCreateGeneration — Validates input and enqueues job
  2. ProcessPromptJob — Filters and enhances prompts
  3. TranslatePromptJob — AI-powered translation for best results
  4. RunGenerationJob — Routes to optimal AI provider
  5. RemoveBgJob — Optional background removal
  6. ResetLimitsJob — Daily credit reset

Content Moderation

Building a public-facing AI platform requires robust safety measures:

🛡️ Automated Protection

  • Multi-layer bad word detection
  • Prompt filtering for inappropriate content
  • Automated image analysis
  • Post-moderation for trusted users

👮 Admin Tools

  • Comprehensive moderation queue
  • User complaint system
  • Trust level management
  • Content policy enforcement

Deployment & Infrastructure

🐳 Docker-Based Deployment

The entire application runs in Docker containers with production-ready configuration. We use PostgreSQL for persistence, Redis for job queues, and AWS S3 for image storage with CDN delivery.

Testing & Quality Assurance

We maintain high code quality standards:

Quality Measures

  • RSpec — Comprehensive test suite
  • VCR Cassettes — Recorded API responses for reliable testing
  • Rubocop — Style enforcement
  • Brakeman — Security analysis
  • CI/CD Pipeline — Automated testing and deployment

User Experience

Telegram Bot Workflow

The bot provides an intuitive generation flow:

Generation Flow

  1. /start — Begin interaction with account setup and welcome message
  2. Send Prompt — Type or paste your image description
  3. AI Generation — Background job processes your request
  4. Receive Image — Get your generated artwork with metadata

The public gallery at aichaos.ru offers:

🔍 Discovery

Browse recently generated images from the community

🔎 Search

Find images by prompts, styles, or AI models with full-text search

📋 Detail View

Inspect generation parameters, model used, and creation metadata

📱 Responsive

Optimized experience for mobile and desktop viewing

What Makes AI Chaos Different?

🔄 Multi-Provider

Support for multiple AI providers ensures reliability and model variety. We route requests optimally and can add new models without code changes.

💬 Native Telegram

Seamless interaction within the Telegram ecosystem with built-in payments, rich UI, and familiar chat interface.

🎨 Public Gallery

Community showcase inspires creativity and demonstrates platform capabilities.

💰 Sustainable Model

Credit economy balances free access with premium features, ensuring platform longevity.

Future Roadmap

We have exciting plans ahead:

Planned Features

  • Advanced Editing — Image-to-image transformation and inpainting
  • Style Transfer — Apply artistic styles to existing images
  • Video Generation — Expand to AI video creation
  • Social Features — User profiles, favorites, and interactions
  • Enhanced API — Programmatic access for developers
  • Mobile App — Dedicated application for enhanced experience

Development Status

🚢 Public Beta

AI Chaos is currently in public beta at aichaos.ru. The platform is stable and actively used, with regular updates and new features being added. We welcome feedback from early adopters.

✨ Live Now

Platform launched in public beta with core features fully functional

Try It Out

Ready to explore AI-generated art?

Get Started

  1. Open Telegram and search for @aichaos_bot
  2. Send /start to begin
  3. Type your creative prompt
  4. Receive your generated artwork
  5. Visit aichaos.ru to see the public gallery

📊 By The Numbers

Built with Rails 8.0.1, the platform demonstrates the power of modern Ruby for AI applications. With multiple AI providers, robust moderation, and a sustainable business model — AI Chaos proves that well-architected backend systems can deliver cutting-edge AI experiences at scale.


Building AI Chaos has been an incredible journey exploring the intersection of AI, chat platforms, and creative tools. The platform represents our vision for accessible AI creativity — powerful enough for professionals, simple enough for everyone.

#Current work#rails#telegram#ai#sidekiq#postgresql#ruby