How sitegui-platform/litegui works
Project Type & Overall Purpose
• This is a CMS system that can function either as a complete content management solution or as a headless API backend. Its design supports both rendering a full-stack web application (through a user portal and an administrative/staff portal) and serving APIs.
• The README emphasizes key features (user/staff management, RBAC, visual editors, widget/layout management, etc.) that suggest a modular, extensible architecture.
Analyzing the File Structure
• Top-Level Directories & Files:
• “mysite” is the core folder. Inside, you have:
▪ “resources” – divided into “public” (templates, assets, uploads) and “protected” (app and client_uploads files) – clearly separating files that are accessible from the web and those that aren’t.
▪ “src” – the backend PHP source code. This is structured into subdirectories:
• “App” (likely application-specific logic, e.g. Blog.php)
• “Core” (domain components such as User, Staff, Page, Site, etc.) with Traits and Helper modules (e.g., Upgrade.php)
• “Notification” – handles email via PHPMail and SMTP.
• “Widget” – core widget components (e.g., Editor and Text)
• Entry point scripts like index.php, siteadmin.php, and siteuser.php which serve as the front controller for different portals.
• Other files like “config.php”, “cron.php”, and “setup.sh” indicate setup and scheduled task management.
• Public assets like the HTML templates under “mysite/resources/public/templates” and the vast number of CSS/JS assets provided for the admin themes suggest a heavy reliance on front-end templating and styling.
Key System Components
a. Presentation Layer:
– Webpages served to end users (siteuser.php) and to staff (siteadmin.php).
– Static assets served from “resources/public” (templates, images, CSS/JS).
– Separate themes and templates for user and admin interfaces.
b. Backend / Business Logic:
– PHP Application Layer in “src”:
• Core business logic (handled in “Core” modules such as User, Role, Page, etc.)
• Application-specific logic and controllers in “App” and “Widget”.
• Notification systems under “Notification”.
– Entry point scripts for different roles (index.php for general visitors, siteadmin.php for admin, siteuser.php for user accounts).
c. Data Persistence:
– MySQL/MariaDB is used for the database (sitegui_mysite.sql provides schema and data).
– Connections and configurations are made via “config.php” (or config.local.php).
– Optionally, Redis is mentioned for caching.
d. Infrastructure & External Dependencies:
– PHP 8 running via PHP-FPM (seen in Nginx configuration with fastcgi_pass).
– Nginx web server serving both the application’s dynamic PHP content and static files (see Nginx configuration files in the README).
– Optional external services like OAuth providers for social login and Redis for caching.
– Setup scripts (setup.sh) and cron jobs (cron.php) for background processes and maintenance.
Architectural Relationships and Data Flow
• Client requests (from browsers or mobile apps) first reach the Nginx server.
• Nginx routes the traffic to the proper PHP script based on the URL:
– General traffic to “index.php”
– Staff interactions to “siteadmin.php”
– User interactions to “siteuser.php”
• PHP-FPM handles the dynamic processing where the “src” layer coordinates business logic by invoking components in “Core”, “App”, and “Widget”.
• The PHP backend communicates with the database using credentials set in “config.php” and optionally to Redis for caching sessions or data.
• For static assets (CSS, JS, images, templates), Nginx is configured to directly serve files from “mysite/resources/public”.