How zerodream-cn/zdocs works
Project type and purpose
• This is “ZDocs,” a lightweight PHP-based documentation system with no separate backend UI—every operation (CRUD on docs, category management, user login, theme switching, etc.) happens via the front end.
• It supports Markdown/HTML rendering (front-end), multi-user collaboration (BCRYPT-hashed passwords), categories/subcategories, sorting, and theme toggles.
File structure
Top-level files
– config.php: global configuration (DB or file paths, auth settings)
– index.php: front controller; routes all HTTP requests into the ZDocs engine
– README.md, LICENSE
Public assets (static content served directly by the web server)
– public/css/*.css (Materialize, custom styles, theme files)
– public/js/*.js (Markdown renderer, syntax highlighter, app scripts)
– public/webfonts/*
Main application code under zdocs/
– zdocs/zdocs.php: core bootstrap and request dispatcher
– zdocs/includes/
• header.php, footer.php – shared layout templates
• functions.php – business logic and data-access primitives
• actions.php – handlers for create/read/update/delete operations
• render.php – Markdown-to-HTML and view rendering routines
README for tech stack and architecture hints
– PHP 7+ runtime on the server
– Static file serving (CSS, JS) by the web server
– Front-end Markdown rendering via Cherry Markdown + Highlight.js
– UI built on Materialize CSS, jQuery, SortableJS, SweetAlert2, plus ECharts for charts
– Data persisted as flat files or small DB (config.php hints at storage config)
a. Main components (containers)
• Browser (Client UI)
• Web Server + PHP Runtime (Apache/Nginx + PHP-FPM)
• File Storage / Data Layer (flat files or small DB)
• External JS/CSS Libraries (Cherry Markdown, Highlight.js, ECharts, Materialize, etc.)
b. Component relationships & data flow
1. Browser requests a page (HTTP GET) → Web Server → index.php (front controller)
2. index.php loads config.php, invokes zdocs/zdocs.php (router)
3. zdocs.php calls includes/actions.php or render.php as per route
4. Business logic in functions.php reads/writes documents & user data from File Storage
5. render.php produces HTML (injects header/footer), returns to Browser
6. Browser fetches CSS/JS from public/ to style UI, handle MD rendering, sorting, dialogs
c. Architectural patterns & principles
• Front-Controller pattern (all requests pass through index.php)
• Modular “includes” for separation of concerns: routing, actions, rendering, business logic, templates
• Single-page-style interactivity using AJAX and JS libraries—no back-end admin pages
• Flat-file or micro-DB persistence (minimal footprint)
• PHP + Apache/Nginx (server)
• Cherry Markdown, Highlight.js (client-side MD rendering)
• Materialize CSS, jQuery, SortableJS, SweetAlert2, ECharts
• BCRYPT (password hashing in PHP)
• File system (or SQLite) as storage
Final advice
• Be precise but don’t over-complicate—this system is small and modular
• Where front-end libraries plug into the HTML output for markdown rendering, theme switching, and UI interactions
• Aim for a one-page overview that can be expanded into smaller views if needed for detailed discussions