Skip to content

About

Autonomous Multi-Tenant Persistence & Lifecycle Orchestrator for Stratum-Core. Zero-trust database provisioner, streaming backups, and gateway management.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Stratum-CLI

CLI Version Platform Architect License

«Aislamiento por diseño, no por disciplina» — (“Isolation by design, not by discipline”)

Plano de control administrativo y orquestador del conjunto Stratum Sovereign Multi-Tenant Architecture.
Stratum es una arquitectura de referencia y un conjunto de herramientas para operar múltiples organizaciones (inquilinos) sobre una misma infraestructura, con aislamiento de red por organización y un plano de control administrativo en línea de comandos. Está diseñada para reducir la dependencia de la disciplina operativa en el aislamiento entre inquilinos, y no constituye garantía de resultado.

📖 Guía de Uso & Manual de Operaciones en Español
📚 Overleaf Community Edition Integration & Architecture


1. Overview

stratum-cli is the command-line orchestrator designed to operate and automate multi-organization infrastructure running on Stratum-Core.

It automates database scripting, mitigates configuration drift, and streamlines tenant management by providing deterministic, zero-dependency management commands.

       stratum db create <org> <service> --engine [mongo|postgres]
                                 │
                 ┌───────────────┴───────────────┐
                 ▼                               ▼
       MongoDB Engine                   PostgreSQL Engine
   [org]_[service] (DB)              [org]_[service] (DB)
   [org] (readWrite User)            [org] (Owner Role)
   Auto-Generated Password           Auto-Generated Password
                 │                               │
                 └───────────────┬───────────────┘
                                 ▼
                     Output Ready-to-Copy .env

2. Key Features

  • 🔒 Deterministic Naming Pattern: Enforces [org]_[service] (e.g. sgpt_overleaf, isora_portal, client_nextcloud).
  • 📁 Agnostic Directory Architecture: Zero hardcoded paths. Automatic sibling repository auto-discovery (../stratum-core), configuration via JSON profile (/etc/stratum/config.json or ~/.config/stratum/config.json), CLI flag override (-C / --core-path), and environment variables (STRATUM_CORE_PATH).
  • 🔑 Cryptographic Password Generation: Generates 24-character high-entropy alphanumeric credentials automatically via CSPRNG.
  • ⚡ Zero External Dependencies: Built with Python standard library (subprocess, argparse, secrets, pathlib) to run immediately on any Linux host.
  • 🛡️ Isolated Tenant Backups: Creates compressed, isolated database dumps (.archive.gz / .pgdump) without touching other tenants.
  • 🌐 Declarative Ingress Routing: Generates and hot-reloads modular Layer 7 Nginx virtual hosts in sovereign organization islands with zero downtime.
  • 🩺 Health & Status Inspector: Real-time visibility into the health of all platform containers with dynamic tunnel discovery.
  • 🌐 Full Internationalization (i18n): Native support for Spanish (es) and English (en) via -l / --lang or persistent config.

3. Prerequisites

Before installing and executing stratum-cli, verify that the following platform and system dependencies are satisfied:

3.1 Stratum Target Platforms

stratum-cli operates directly against the infrastructure layers of the Stratum Platform:

  1. Stratum-Core
    The foundational infrastructure tier (Tier 1). Must be deployed or cloned locally. stratum-cli manages its database containers (stratum-database-postgres, stratum-database-mongo) and network boundaries.

  2. Stratum-Org
    The Organization Island infrastructure tier (Tier 2). Required when managing tenant ingress virtual host routes via stratum route.

3.2 System Requirements

Item Requirement Notes
Python 3.10 or later Uses only standard library modules (subprocess, argparse, secrets, pathlib)
Docker Engine 24.0 or later Required for container inspection, backup exec, and status commands
Docker Compose v2.20 or later Required for cluster management and health monitoring
Operating System Linux (x86_64 or arm64) Production VPS, physical server, or dev environment

4. Installation

Quick Interactive Install on VPS / Server

Clone the repository anywhere on your system and run the installer:

# Clone the repository
git clone https://github.com/sandra-puerto/stratum-cli.git /opt/stratum-cli
cd /opt/stratum-cli

# Run the installer
sudo bash install.sh

The installer auto-detects stratum-core if cloned in the sibling directory, configures the default backup directory as a sibling (../stratum-backups), creates timestamped safety backups of any existing binary/config before upgrading with automated rollback, and sets up /usr/local/bin/stratum.

Non-Root / User-Space Install

For developers and sysadmins without sudo privileges:

INSTALL_DIR=~/.local/bin bash install.sh

Automated / CI-CD Install (Non-interactive)

sudo bash install.sh --yes --core-path /srv/infra/stratum-core

Verify the installation:

stratum config show
stratum doctor

5. Command Reference & Examples

5.1 Configuration Management (stratum config)

Inspect and modify your deployment paths without manual file editing:

# Display active paths and resolution sources
stratum config show

# Set a custom Stratum-Core path
stratum config set core_path /srv/apps/stratum-core

# Set custom backup storage location
stratum config set backup_dir /mnt/backups

# Set default CLI language
stratum config set default_lang es

5.2 Provision a Tenant Database (stratum db create)

Creates an isolated database, creates the application user, sets permissions, and prints the connection strings ready for the tenant's .env:

MongoDB Example (e.g. Overleaf):

stratum db create sgpt overleaf --engine mongo

Output:

========================================================================
[+] STRATUM MULTI-TENANT PROVISIONING SUCCESSFUL (MongoDB)
========================================================================
  Tenant Database .... : sgpt_overleaf
  Application User ... : sgpt
  Generated Password . : K9x#mP2vL!8wQzRtY4uX7nB1
  Proxy Boundary Host  : stratum-database-nginx:27017
  Auth Source ........ : sgpt_overleaf
------------------------------------------------------------------------
  Copy-Paste for Tenant .env file:

# --- Stratum Boundary Persistence (Tenant: SGPT) ---
STRATUM_DB_HOST=stratum-database-nginx
MONGO_APP_USER=sgpt
MONGO_APP_PASSWORD=K9x#mP2vL!8wQzRtY4uX7nB1
MONGO_DB_NAME=sgpt_overleaf
MONGO_AUTH_SOURCE=sgpt_overleaf
MONGO_URL=mongodb://sgpt:K9x#mP2vL!8wQzRtY4uX7nB1@stratum-database-nginx:27017/sgpt_overleaf?authSource=sgpt_overleaf
========================================================================

PostgreSQL Example (e.g. Nextcloud / Strapi):

stratum db create isora nextcloud --engine postgres

5.3 Manage Sovereign Ingress Routes (stratum route)

Configures, inventories, validates, and hot-reloads Nginx virtual host routes inside the tenant's sovereign boundary router (stratum-org/nginx/conf.d/<service>.conf). It performs syntax testing inside the running container (nginx -t) and executes an automated rollback if syntax validation fails, ensuring zero traffic disruption:

# Provision an ingress route for Overleaf (auto-resolves /opt/<ORG>/stratum-org)
stratum route add sgpt overleaf --domain latex.sgpt.local --target overleaf:80

# Provision a route with custom upload limit (e.g. 250M for file sharing)
stratum route add isora nextcloud --domain cloud.isora.com --target nextcloud:80 --max-body 250M

# Inventory all active routes for an organization
stratum route list sgpt

# Test configuration and trigger zero-downtime hot reload
stratum route reload sgpt

# Remove an obsolete route
stratum route remove sgpt overleaf

5.4 Backup a Tenant Database (stratum backup)

Creates an isolated, compressed dump of only that specific client's data:

stratum backup sgpt overleaf --engine mongo

Default Output: <parent-directory>/stratum-backups/sgpt/sgpt_overleaf_YYYYMMDD_HHMMSS.archive.gz

You can also specify a custom destination directory:

stratum backup sgpt overleaf --engine mongo -o /mnt/storage/backups

5.5 Generate Cryptographic Secrets & Physical Entropy Harvester (stratum secret)

Generates high-entropy, shell-safe alphanumeric credentials, Redis passwords, session keys, and tokens. In addition to OS-level CSPRNG (/dev/urandom / CryptGenRandom), Stratum incorporates a Multi-Layered Real Entropy Harvester:

  • Planetary Atmospheric Chaos: Queries real-time meteorological sensors (temperature, barometric pressure, wind speed, relative humidity) across randomized global locations (e.g. Reykjavik, Tokyo, Ushuaia, Nairobi, Honolulu, Svalbard).
  • Network Transit Jitter: Samples nanosecond socket propagation variations.
  • Micro-architectural Hardware Jitter: Analyzes nanosecond CPU execution variations across cache lines and branch predictors.
  • HMAC-SHA512 Entropy Sponge: Cryptographically compresses all environmental and physical measurements with kernel entropy.
  • Zero-Friction Offline Resilience: If the node is offline or behind strict firewalls, it automatically falls back with zero latency to local CPU hardware jitter and kernel CSPRNG.
# Generate a single 32-character secret with real atmospheric & hardware entropy
stratum secret

# Generate a 24-character database password
stratum secret -l 24

# Generate 3 secrets at once in a single harvest (for Redis, Overleaf session secret, and tokens)
stratum secret -n 3

# Fast, air-gapped generation without external network calls
stratum secret --offline

# Machine-readable output for bash scripts or .env automation (prints raw strings only)
stratum secret -q

5.6 Inspect Platform Health (stratum status)

Dynamically discovers core services and all running tenant tunnels:

stratum status

5.7 System Diagnostics & Doctor (stratum doctor)

Runs an enterprise audit of Linux kernel parameters (vm.overcommit_memory), secret .env file permissions, Docker daemon health, backup destination write permissions, and configuration topology:

stratum doctor

6. Developer Guide: How to Add a New Database Engine

stratum-cli uses the Strategy & Registry Pattern. Adding support for a new engine (e.g. MariaDB, ClickHouse, SQLite) takes less than 30 lines of code without touching the core CLI:

  1. Create a new file stratum_cli/engines/mariadb.py:
    from .base import BaseDatabaseEngine, ProvisioningResult, register_engine
    
    @register_engine("mariadb")
    class MariaDBEngine(BaseDatabaseEngine):
        @property
        def engine_name(self) -> str:
            return "MariaDB Relational Engine"
    
        @property
        def target_container(self) -> str:
            return "stratum-database-mariadb"
    
        def provision(self, org: str, service: str, password=None) -> ProvisioningResult:
            # Implement provisioning logic via exec_in_container
            ...
    
        def backup(self, org: str, service: str, output_dir) -> Path:
            # Implement streaming dump via mariadb-dump
            ...
  2. Import the new class in stratum_cli/engines/__init__.py.
  3. The new engine will immediately be available in stratum db create <org> <service> -e mariadb and stratum db list-engines.

7. Architectural Credits, Ownership & Upward Model

Stratum-CLI was architected and implemented by Sandra Gabriela Puerto Torres and is the intellectual property of the author and all her associated brands (including Isora Cloud Group).

Upward-Only Architectural Dependency Model

As the administrative control plane, stratum-cli manages multi-tier infrastructure by strictly respecting the upward dependency chain:

  1. Tier 1 (stratum-core): Platform foundation, Layer 4 database proxy, and shared DMZ network.
  2. Tier 2 (stratum-org): Organization island boundary router and dedicated tenant network.
  3. Tier 3 (Workloads): Application workloads that attach upward to Tier 2 and Tier 1.

stratum-cli does not introduce cyclic dependencies between layers.


8. License

This project is licensed under the Functional Source License, Version 1.1, Apache 2.0 Change License (FSL-1.1-Apache-2.0). See the LICENSE file for details.


9. Legal Disclaimer & Trademarks Notice

IMPORTANT LEGAL NOTICE / AVISO LEGAL:
No Guarantee of Outcome (Obligación de medio, no de resultado):
stratum-cli is an administrative utility and reference orchestrator designed to assist operators in executing configuration and container management workflows. It is provided on an "AS IS" and "AS AVAILABLE" basis, without warranties of any kind, whether express, implied, statutory, or otherwise, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, title, security, or non-infringement.

While stratum-cli automates provisioning according to isolation-by-design patterns, it does NOT guarantee absolute operational security, system uptime, or prevention of misconfigurations resulting from improper environment inputs or unauthorized host-level modifications. Operators and deploying organizations remain solely responsible for validating generated credentials, managing backups, and securing host environments.

Trademarks & Nominative Fair Use

All product names, trademarks, registered trademarks, service marks, and company names mentioned in this tool and documentation (including Docker®, PostgreSQL®, MongoDB®, Nginx®, Python®, and Cloudflare®) are the property of their respective holders. Their use is strictly nominative and descriptive, and does not imply affiliation, sponsorship, or endorsement.

About

Autonomous Multi-Tenant Persistence & Lifecycle Orchestrator for Stratum-Core. Zero-trust database provisioner, streaming backups, and gateway management.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages