Skip to content

Artwo Academy: System Architecture & Production Overview

Production Domains: artwo.ir · media.artwo.ir · docs.artwo.ir
Infrastructure Model: Hybrid Host-Native & Multi-Container Docker Architecture
Base Operating System: Ubuntu 22.04.5 LTS (Jammy Jellyfish) — Linux Kernel 5.15


1. Executive Summary

Artwo Academy is a digital language instruction platform integrating asynchronous learning management (Moodle 5.3 LMS), synchronous virtual classrooms (BigBlueButton via SHA1 API), high-availability instructional media streaming, e-commerce co-hosting (WordPress/WooCommerce), and enterprise accounting (Hesabix ERP).

Initially deployed on a managed Platform-as-a-Service (PaaS) environment, the platform encountered severe operational bottlenecks, including hard-coded HTTP 413 ingress payload limits, lack of host-level cron scheduling, and inability to tune PHP-FPM or InnoDB kernel parameters. To resolve these constraints, the entire infrastructure was re-architected onto a self-managed Ubuntu 22.04 LTS Virtual Private Server fronted by ArvanCloud CDN edge proxies.

The resulting production architecture utilizes a hybrid execution model: I/O-intensive LMS execution (Moodle 5.3 + PHP 8.3-FPM + Nginx) runs natively on the Ubuntu host filesystem to eliminate Docker overlay storage latency, while ingress routing (Nginx Proxy Manager), relational database persistence (MariaDB 11.4), e-commerce (Poustine), and ERP microservices (Hesabix) operate inside isolated Docker Compose bridge networks.


2. Production Topology & Data Flow

graph TD
    subgraph Edge ["Global Edge & DNS Layer"]
        CDN["ArvanCloud CDN & WAF<br/>(Anycast Edge / TLS Termination)"]
        BBB["Dedicated BigBlueButton Cluster<br/>(External API / WebRTC Node)"]
    end

    subgraph VPS ["Production Cloud VPS — Ubuntu 22.04.5 LTS"]
        subgraph Ingress ["Containerized Ingress Layer (nginx-proxy_default)"]
            NPM["Nginx Proxy Manager (OpenResty)<br/>Ports 80 / 443"]
        end

        subgraph HostStack ["Host-Native LMS Stack (/srv/artwo)"]
            HostNginx["Host Nginx Web Server<br/>(Local Loopback / Bridge Ingress)"]
            PHPFPM["PHP 8.3-FPM Worker Pool<br/>(Unix Socket: php8.3-fpm.sock)"]
            Moodle["Moodle 5.3 Core (/public)<br/>& Moodledata Repository"]
            MediaDisk["Secondary Block Volume (70GB ext4)<br/>Custom JSON/JS Media SPA (/srv/media)"]
        end

        subgraph DockerStacks ["Isolated Docker Compose Environments"]
            MariaDB["MariaDB 11.4 LTS<br/>(artwo_default — 127.0.0.1:3306)"]
            Poustine["E-Commerce Stack (WordPress + MariaDB)<br/>(Isolated Internal Bridge)"]
            Portfolio["Portfolio Static Web (nginx:alpine-slim)<br/>(Container: portfolio_web)"]
        end
    end

    subgraph DR ["3-2-1 Disaster Recovery Tier"]
        S3["S3-Compatible Object Storage<br/>(7-Day Lifecycle Policy)"]
        Offsite["Off-Site Workstation Vault<br/>(Automated SSH/SCP Pull Kit)"]
    end

    CDN -->|HTTPS / Real-IP| NPM
    NPM -->|Internal Bridge Proxy| HostNginx
    NPM -->|Internal Bridge Proxy| MediaDisk
    NPM -->|Docker DNS| Poustine
    NPM -->|Docker DNS| Portfolio
    HostNginx -->|FastCGI| PHPFPM
    PHPFPM --> Moodle
    Moodle -->|TCP Loopback :3306| MariaDB
    Moodle <-->|SHA1 Checksum API| BBB
    MediaDisk -->|CORS Slide & Audio Delivery| BBB
    VPS -->|Automated Nightly Snapshot| S3
    VPS -->|Encrypted Key-Auth SCP| Offsite

3. Core Architectural Components

3.1 Compute, Storage & Network Foundation

The underlying hardware allocation is partitioned across two distinct block devices to isolate operating system operations from large static instructional assets:

Resource Layer Specification / Device Mount Point / Binding Architectural Purpose
Primary System Disk 40 GB SSD (/dev/vda1, ext4) / Ubuntu 22.04 OS, Docker Engine volumes, Moodle 5.3 core codebase, and live MariaDB 11.4 tablespaces.
Dedicated Media Volume 70 GB Block Storage (/dev/vdb, ext4) /srv/media Persistent UUID mount in /etc/fstab storing ~50 GB of instructional audio, PDFs, and interactive slide decks.
DNS & Network Stack systemd-resolved + Netplan Primary Interface (IPv4 Priority) Custom DNS hierarchy neutralizing upstream DHCP overrides and prioritizing IPv4 transport (precedence ::ffff:0:0/96 100) to prevent IPv6 package repository timeouts.
Perimeter Security UFW + OpenSSH + CDN Edge-Proxied Ingress Strict key-based SSH authentication (0600 key enforcement), non-root execution, origin IP masking behind CDN, and disabled public database bindings.

3.2 Hybrid Execution Strategy (Host vs. Containerization)

Rather than forcing all workloads into containers or running conflicting dependency chains directly on the host OS, workloads are segregated by their I/O profile and dependency lifecycle:

  1. Host-Native High-I/O Application Layer (/srv/artwo/moodle):
  2. Moodle 5.3 LTS executes directly on the Ubuntu host filesystem via Nginx and PHP 8.3-FPM (ondrej/php PPA).
  3. Engineering Rationale: Moodle performs intensive small-file read/write operations across moodledata/cache and moodledata/localcache. Running PHP-FPM natively over a Unix domain socket (/run/php/php8.3-fpm.sock) bypasses Docker bridge NAT overhead and OverlayFS file-locking bottlenecks.
  4. Process Management: Configured with dynamic PHP-FPM worker scaling, max_input_vars = 5000, extended FastCGI read timeouts (300s), and an isolated www-data system cron runner executing admin/cli/cron.php every minute.

  5. Containerized Database & Multi-Tenant Services:

  6. Nginx Proxy Manager (OpenResty): Handles multi-domain virtual host routing, Let's Encrypt SSL/TLS lifecycle automation, HTTP/2 delivery, and custom security headers across an isolated proxy bridge network.
  7. MariaDB 11.4 LTS (artwo-mariadb): Runs inside an isolated Docker Compose stack with persistent volume mapping, bound strictly to 127.0.0.1:3306 so the host PHP-FPM pool can query the LMS database without exposing port 3306 externally. Host-level mariadb.service daemons are masked via systemd to prevent boot-time port collisions.
  8. Multi-Tenant E-Commerce Stack: Self-contained WordPress and MariaDB e-commerce deployment operating on an isolated internal Docker bridge network.
  9. Documentation Portal (portfolio_web): Hardened nginx:stable-alpine-slim container with dropped Linux capabilities (cap_drop: ALL), no-new-privileges:true, a 128MB RAM ceiling, and read-only static volume mounts (:ro).

3.3 Custom Zero-Dependency Media Portal (media.artwo.ir)

To serve 50+ GB of instructional textbooks, audio tracks, and BigBlueButton presentation slides without consuming LMS database resources or paying external cloud egress fees, the /dev/vdb volume is exposed through a dedicated host Nginx virtual host (media.artwo.ir):

  • JSON Autoindex API & Vanilla JS SPA: Instead of relying on third-party binary Nginx modules (ngx-fancyindex) that complicate OS upgrades, Nginx is configured with autoindex on; autoindex_format json;. A lightweight, zero-dependency Vanilla JavaScript and CSS Single-Page Application (SPA) fetches the JSON directory payloads and renders a responsive, searchable file explorer with breadcrumb navigation and instant media previews.
  • BigBlueButton CORS Integration: Configured with strict Cross-Origin Resource Sharing (Access-Control-Allow-Origin) headers, enabling external BigBlueButton virtual classroom nodes to fetch PDF slide decks and audio streams directly from the VPS block storage during live classes.

3.4 Kernel I/O Tuning & Security Hardening

To maintain sub-second response times under concurrent classroom load on a 40 GB root SSD, several kernel-level and application-level optimizations are enforced:

  • Eliminating ext4 jbd2 Journaling Deadlocks: Systemd journal logging (systemd-journald) is capped at SystemMaxUse=200M and kernel virtual memory dirty-page ratios (vm.dirty_background_ratio = 5, vm.dirty_ratio = 10) are tuned in /etc/sysctl.conf to prevent synchronous disk flush spikes from freezing PHP-FPM workers and triggering HTTP 504 Gateway Timeouts.
  • Moodle 5.3 Front-Controller & CIS Permission Hardening: Upgraded to Moodle 5.3 utilizing the /public web root isolation and /r.php front-controller router. File permissions follow strict least-privilege standards with config.php restricted to 0440 (sysadmin:www-data), stripping world-readable and executable bits, and isolating database user privileges from root.
  • Role & Capability Auditing: Audited and hardened Moodle's internal permission tree to prevent privilege escalation or unauthorized course-level modifications by standard student accounts.

3.5 Automated 3-2-1 Disaster Recovery Pipeline

Data resilience is enforced through a multi-tiered backup architecture combining nightly cloud synchronization with on-demand full-server disaster recovery snapshots:

  1. Zero-Plaintext Automated Nightly Backups (run_backups.sh):
  2. Executed daily at 03:00 AM via system crontab.
  3. Database credentials are stored inside a 0600 permission-locked .my.cnf file mounted read-only (:ro) into the MariaDB container, eliminating plaintext passwords from process lists (ps aux).
  4. Generates single-transaction, gzip-compressed SQL dumps and moodledata archives, enforces a local 7-day rolling retention policy (find -mtime +7 -delete), and synchronizes archives to S3-Compatible Object Storage governed by a 7-day bucket lifecycle rule.
  5. Full Portable VPS Disaster Recovery Kit (create_dr_kit.sh):
  6. A fail-fast (set -eo pipefail) single-pass packaging script that exports consistent --single-transaction SQL dumps across all running database containers, archives /etc/nginx, /etc/php, /etc/ufw, /etc/netplan, /etc/systemd/system, cron tables, installed apt package manifests (dpkg --get-selections), and Docker Compose stacks into a unified .tar.gz kit while excluding volatile cache directories and redundant binary tablespaces.
  7. Paired with an automated workstation script (pull_full_vps_kit.bat) that retrieves the encrypted archive over SSH key authentication directly to local offline storage and reclaims VPS SSD headroom upon verification.

4. Production Configuration Artifacts

Host Nginx Configuration for Moodle 5.3 (/etc/nginx/sites-available/moodle)
server {
    listen 8080;
    server_name artwo.ir www.artwo.ir;
    root /srv/artwo/moodle/public;
    index index.php index.html;

    client_max_body_size 512M;

    # Preserve client Real-IP from CDN & Reverse Proxy Bridge
    set_real_ip_from 172.18.0.0/16;
    real_ip_header X-Forwarded-For;
    real_ip_recursive on;

    location / {
        try_files $uri $uri/ /r.php$is_args$args;
    }

    # Moodle 5.x Front-Controller & Slash Arguments Support
    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_index index.php;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_read_timeout 300;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}
MariaDB 11.4 Docker Compose Specification (docker-compose.yml)
services:
  mariadb:
    image: mariadb:11.4
    container_name: artwo-mariadb-1
    restart: always
    ports:
      - "127.0.0.1:3306:3306"
    environment:
      MARIADB_ROOT_PASSWORD: "${MARIADB_ROOT_PASSWORD}"
      MARIADB_DATABASE: "${LMS_DB_NAME}"
      MARIADB_USER: "${LMS_DB_USER}"
      MARIADB_PASSWORD: "${LMS_DB_PASSWORD}"
    volumes:
      - ./mariadb:/var/lib/mysql
      - /srv/secrets/.my.cnf:/root/.my.cnf:ro
    command: >
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_unicode_ci
      --max-allowed-packet=256M
      --innodb-buffer-pool-size=1G
Single-Pass Full VPS Disaster Recovery Script (create_dr_kit.sh)
#!/bin/bash
set -eo pipefail

TIMESTAMP=$(date +"%Y-%m-%d_%H-%M")
DR_DIR="/srv/dr_staging"
FINAL_ARCHIVE="/srv/artwo_full_vps_kit_$TIMESTAMP.tar.gz"

echo "[1/4] Preparing clean staging folder..."
sudo rm -rf "$DR_DIR"
mkdir -p "$DR_DIR/databases" "$DR_DIR/system_configs/etc"

echo "[2/4] Exporting live MariaDB databases..."
docker exec -i artwo-mariadb-1 mariadb-dump --defaults-extra-file=/root/.my.cnf \
    --single-transaction --routines --triggers "${LMS_DB_NAME}" | gzip > "$DR_DIR/databases/lms_db.sql.gz"

if [ "$(docker ps -q -f name=ecommerce_db)" ]; then
    docker exec -i ecommerce_db mariadb-dump --defaults-extra-file=/root/.my.cnf \
        --single-transaction "${ECOMMERCE_DB_NAME}" | gzip > "$DR_DIR/databases/ecommerce_db.sql.gz"
fi

echo "[3/4] Copying Ubuntu host configs (Nginx, PHP, Cron, Systemd, SSL)..."
for item in /etc/nginx /etc/php /etc/netplan /etc/ufw /etc/letsencrypt /etc/systemd/system /etc/crontab /var/spool/cron/crontabs; do
    if [ -e "$item" ]; then
        sudo cp -a "$item" "$DR_DIR/system_configs/etc/" 2>/dev/null || true
    fi
done

dpkg --get-selections > "$DR_DIR/system_configs/installed_packages.txt"
docker ps -a > "$DR_DIR/system_configs/docker_containers.txt"
docker network ls > "$DR_DIR/system_configs/docker_networks.txt"

echo "[4/4] Packaging stacks + configs into a single archive..."
sudo tar -czf "$FINAL_ARCHIVE" \
    --warning=no-file-changed \
    --anchored \
    --checkpoint=500 \
    --checkpoint-action=dot \
    --exclude="/srv/media" \
    --exclude="/srv/backups" \
    --exclude="/srv/artwo/mariadb" \
    --exclude="/srv/artwo/moodledata/cache" \
    --exclude="/srv/artwo/moodledata/localcache" \
    --exclude="/srv/artwo/moodledata/temp" \
    --exclude="/srv/artwo/moodledata/sessions" \
    --exclude="/srv/ecommerce/db_data" \
    --exclude="/srv/*.tar.gz" \
    --exclude="/srv/*.zip" \
    /srv || [ $? -eq 1 ]

sudo rm -rf "$DR_DIR"

echo "Complete! Final archive created:"
ls -lh "$FINAL_ARCHIVE"
df -h /

5. Chronological Evolution & Engineering Log

For a complete, chronological breakdown of every architectural decision, cross-border network tunnel implementation (global.artwo.ir), UI/CSS customization, and incident root-cause analysis from initial deployment to present, proceed to the Engineering & Progress Log →.