How t-sharabi/tenant-onboarding works
Project type and purpose
• This is a small Python-based CLI tool (“Tenant Schema Automation”) for onboarding new tenants in a multi-tenant SaaS platform (e.g., Odoo).
• It exposes two scripts:
• create_tenant.py (creates schema + inserts tenant record)
• create_dns_record.py (optionally registers DNS entries)
File structure
• Top level only:
• .env.example – template for environment variables
• README.md – project description
• create_tenant.py – main tenant-creation logic
• create_dns_record.py – DNS API integration
• No web UI or frontend; purely a backend/CLI automation.
README for additional insights
• Scripts expect a PostgreSQL database with a “tenant_base.tenants” registry table.
• Environment variables drive DB connectivity.
• The tool logs results to stdout or log file (not shown in tree).
• Intended use: CLI workflows, DevOps/Cloud automation.
Main components & interactions (
a. Python CLI Application
• Module A: Tenant Creator (create_tenant.py)
• Module B: DNS Record Creator (create_dns_record.py)
b. External Services
• PostgreSQL Database (single instance, with postgres role)
• DNS Provider API (e.g., AWS Route53, Cloudflare)
c. Configuration
• Environment Variables (.env)
Relationships & data flows
• The CLI App reads .env ➔ config loader.
• Tenant Creator module connects to PostgreSQL over TCP, issues DDL (CREATE SCHEMA) and INSERT into tenant registry.
• DNS Record Creator module invokes DNS provider’s REST/SDK to provision a DNS record for the new tenant.
• Optionally, return status/logs back to the operator.
Architectural patterns & design principles
• Single responsibility per script (separate concerns: schema vs DNS).
• Externalize config (12-factor style via environment variables).
• Idempotent CLI operations (safe to re-run).
• Logging & error handling (important for automation pipelines).
Final checklist
• [ ] Annotation of protocols (TCP:5432, HTTPS) and config sources