How honghongk/mylib works
Project type and purpose
• Full-stack utility framework and toolkit, centered on PHP.
• Provides a reusable PHP core library (API, DB abstraction, HTTP, Filesystem, Middleware, Protocols).
• Ships with frontend assets (CSS, JS), CLI tools, Python scripts, shell/Windows scripts.
• Includes Dockerfile definitions and Kubernetes manifests for containerized deployment.
• Use cases: build and deploy PHP-based web applications, automate ops tasks, integrate with external services (Mattermost, Slack).
File structure
• Top-level directories:
– css, js: frontend styling and behavior modules
– php: core backend library organized by subsystem (API, DB, HTTP, Filesystem, Middleware, etc.)
– python: auxiliary daemons and scripts for socket, alarm, Creon API, filesystem tasks
– shell, window: OS-level scripts for install, monitoring, backup, certs, port-forwarding
– docker: multi-flavor container recipes (Apache, PHP-FPM, MariaDB, APM, dev)
– k8s: Kubernetes manifests for cluster setup (MariaDB/Galera, Redis/Predixy, nginx+php)
– test: unit/integration examples for PHP and Python components
• Configuration and deployment files: Dockerfiles, shell pods, k8s yamls, iptables, regex.yaml
README
• (No content provided) — rely entirely on structure and naming conventions to infer architecture
Main components and their interactions
a. Presentation layer
– Browser runs HTML pages referencing css/*.css and js/*.js
– JS modules (dragdrop, excel, tree, upload, validate) call backend via HTTP/REST
b. Web/API layer
– HTTP server (Apache or nginx + php-fpm) hosts Router → Handler → Middleware → PHP controllers
– Route dispatches requests to API modules (php/API), CLI commands (php/CLI) or Script entrypoints
c. Application/core layer
– Core services in php/ (Logger, URL, Str, Time, Calc, Client, Protocol)
– DB abstraction (php/DB/MySQL) communicates with MariaDB/MySQL over TCP
– Filesystem abstraction (php/Filesystem) manages storage of JSON, Excel, images, videos, zips
– Middleware components manage CSRF, Throttle, Validation
d. Data layer
– Relational database: MariaDB/Galera (stateful set)
– Cache: Redis (stand-alone or Predixy proxy)
– File storage: local or mounted volumes
– External services: Mattermost (php/API/Mattermost), Solr or other HTTP endpoints via php/Protocol/Http
e. Auxiliary components
– CLI tools: invoked by operators or cron (php/CLI/Process)
– Python daemons and scripts for socket comms, alarms, custom tasks
– Shell scripts for installation, monitoring, backups, certificate management
– Windows scripts for local development or port-forwarding
Infrastructure and deployment
• Containers: multiple Docker images for each role (centos7-apache, php-fpm, mariadb, apm, dev)
• Orchestration: Kubernetes manifests group services into logical clusters
• Networking: iptables rules, k8s services, ingress (nginx-php.yaml), port-forwarding
• CI/CD could mount tests and run python/test_request.py, test_server.py, php tests
Architectural patterns and design principles
• Layered architecture: Presentation → Application → Domain/Core → Data
• Modularity: each subsystem in its own directory, adhering to single-responsibility
• Abstraction: filesystem and database layered behind interfaces
• Containerization: isolates each service, promotes repeatable deployments
• Infrastructure-as-code: all deploy and config scripts versioned