How rails-on-services/apartment works
Main Components
a. Core Components:
• Tenant Management System
• Database Adapters Layer
• Elevator Middleware System
• Migration Handler
• Configuration Manager
b. Database Support:
• PostgreSQL (with schema support)
• MySQL
• SQLite3
Key Architectural Elements
Layer 1: Application Integration
┌─────────────────────────────────────────┐
• Rails Application │
• ┘
• ↓
┌─────────────────────────────────────────┐
• Elevator Middleware │
• (Subdomain/Domain/Host/Custom Router) │
• ┘
Layer 2: Core Apartment System
┌─────────────────────────────────────────┐
• Tenant Management │
• (Creation/Switching/Dropping) │
• ┘
• ↓
┌─────────────────────────────────────────┐
• Configuration Manager │
• (Excluded Models/Persistent Schemas) │
• ┘
Layer 3: Database Abstraction
┌─────────────────────────────────────────┐
• Adapter Layer │
• ┬────────────┬─────────────┤
• PostgreSQL │ MySQL │ SQLite3 │
• (Schemas) │ │ │
• ┴────────────┴─────────────┘
Important Relationships
• Database-specific implementations connected to the Adapter Layer
Additional Elements
Callouts for:
• Persistent Schema Management
• Extension Support (particularly for PostgreSQL)
• Model Exclusion System
• Environment Handling
Notes Section
Notes regarding:
• Multi-server setup capabilities
• Background worker integration
• Testing considerations
• Performance implications
Remember to include version compatibility information and note the key differences between database adapters, particularly PostgreSQL's schema support versus other databases' separate database approach.