podruga.ai codebase
Multi-tenant AI platform architecture running 3 brands across 24 locales through domain-aware schema routing. Text, voice, image, video, infinite personalities, contextual learning, censored / uncensored. Whitelabel-ready. Scales to thousands. One codebase.
Overview
podruga.ai is an enterprise-grade multi-tenant platform architecture designed to scale to thousands of independent applications from a single codebase. Each tenant operates as a completely isolated app with its own database schema, branding, locale, user base, and configuration - while sharing the same deployment infrastructure.
Currently powering 3 brands across 8 languages (24 total locales), the architecture supports unlimited tenant expansion. Adding a new app requires only domain configuration and database schema creation - no code changes. The platform features real-time chat with streaming LLM responses, voice synthesis with cloning, AI image/video generation, and multi-gateway payment processing.
Tech Stack
Frontend
- Vue 3 with Composition API
- Quasar Framework (PWA)
- Pinia for state management
- Socket.IO Client
- Vite build tooling
Backend
- FastAPI + Gunicorn
- PostgreSQL + SQLAlchemy
- Python-SocketIO
- Alembic migrations
- JWT authentication
AI / ML
- LLM integration for chat
- Voice cloning and TTS
- Image generation pipeline
- OpenCV for processing
Infrastructure
- DigitalOcean Droplets
- Nginx reverse proxy
- Systemd services
- Custom deploy scripts
Scalable Multi-Tenant Architecture
The core innovation is a two-level tenancy system that enables unlimited app scaling. Domain detection identifies the brand/app, while locale detection routes to the correct database schema. This means adding a new app is purely configuration - no code deployment required.
Each tenant gets complete isolation: separate user tables, separate characters, separate subscriptions, separate payment history. The middleware automatically routes every request to the correct schema based on the incoming domain and locale headers.
# tenant routing podruga.ai + en -> podruga_en schema -> /api/en podruga.ai + de -> podruga_de schema -> /api/de podruga.ai + fr -> podruga_fr schema -> /api/fr podruga.ai + es -> podruga_es schema -> /api/es podruga.ai + it -> podruga_it schema -> /api/it podruga.ai + pt-br -> podruga_pt_br schema -> /api/pt-br podruga.ai + ja -> podruga_ja schema -> /api/ja podruga.ai + ru -> public schema -> /api pidor.ai + en -> pidor_en schema -> /api/pidor/en pidor.ai + de -> pidor_de schema -> /api/pidor/de ... # x3 brands, 24 total schemas
1
Codebase
∞
Possible Apps
0
Code Changes to Add
Key Features
Real-Time Chat
WebSocket-based messaging with Socket.IO featuring streaming LLM responses, typing indicators, read receipts, and automatic reconnection with exponential backoff. Supports 16MB image buffers for media sharing.
Voice Synthesis
Personalized text-to-speech with voice cloning capabilities. Each AI companion has a unique voice that can be trained from audio samples, creating a more immersive experience.
AI Image Generation
On-demand image generation with custom character consistency. Users can request images of their AI companion in various scenarios while maintaining visual identity.
Subscription & Payments
Tiered subscription system (Guest, Free, Plus) with usage limits on messages, voice minutes, and media generation. Supports both card and cryptocurrency payments with multi-gateway redundancy.
Dual Authentication
Seamless guest-to-user migration system. Users can start chatting immediately as guests with limited features, then upgrade to full accounts without losing conversation history.
Engineering Challenges
Zero-Code Tenant Provisioning
Designed a tenant system where new apps are added through configuration only. Domain middleware detects the tenant, locale middleware selects the schema, and the entire request chain operates in complete isolation. No deployments, no code changes - just DNS and database setup.
PostgreSQL Schema Isolation
Each tenant operates in its own PostgreSQL schema with identical table structures. Migrations run across all schemas simultaneously. Connection pooling is shared but queries are schema-scoped, enabling thousands of tenants on a single database instance.
Real-Time WebSocket Routing
Socket.IO connections are tenant-aware from authentication onward. Each connection carries tenant context, ensuring real-time messages, typing indicators, and streaming LLM responses are isolated per-tenant while sharing the same server infrastructure.
Multi-Gateway Payment Processing
Multiple payment gateways (card, crypto, regional) with tenant-specific configurations. Webhooks always return 200 to prevent retries, with async verification ensuring payment integrity. Each tenant can have different gateway preferences and failover chains.
3
Brands
24
Locales
4
Payment Gateways
1
Codebase