|
| 1 | +# Project Structure & Organization |
| 2 | + |
| 3 | +## Root Directory Layout |
| 4 | +``` |
| 5 | +static-deploy/ |
| 6 | +├── src/ # Main plugin source code (PSR-4: StaticDeploy\) |
| 7 | +├── views/ # WordPress admin interface templates |
| 8 | +├── tests/ # Test suites (unit, integration, phpstan) |
| 9 | +├── dev/ # Development environment (Nix-based) |
| 10 | +├── vendor/ # Composer dependencies |
| 11 | +├── bin/ # Executable scripts |
| 12 | +├── static-deploy.php # Main plugin file |
| 13 | +└── composer.json # Dependencies and scripts |
| 14 | +``` |
| 15 | + |
| 16 | +## Source Code Organization (`src/`) |
| 17 | + |
| 18 | +### Core Components |
| 19 | +- **Controller.php**: Main plugin controller (singleton pattern) |
| 20 | +- **CLI.php**: WP-CLI command interface |
| 21 | +- **WordPressAdmin.php**: WordPress admin integration |
| 22 | + |
| 23 | +### URL Detection & Processing |
| 24 | +- **URLDetector.php**: Main URL discovery orchestrator |
| 25 | +- **Detect*.php**: Specialized URL detectors (Pages, Posts, Categories, etc.) |
| 26 | +- **URLHelper.php**, **URLParser.php**: URL manipulation utilities |
| 27 | +- **SitemapParser.php**: XML sitemap processing |
| 28 | + |
| 29 | +### Crawling & File Processing |
| 30 | +- **Crawler.php**: Multi-threaded site crawling engine |
| 31 | +- **FileProcessor.php**: Static file processing and optimization |
| 32 | +- **PostProcessor.php**: Content post-processing and URL rewriting |
| 33 | +- **SimpleRewriter.php**: URL rewriting for static hosting |
| 34 | + |
| 35 | +### Data Management |
| 36 | +- **DetectedFiles.php**, **CrawledFiles.php**: File tracking |
| 37 | +- **DeployCache.php**: Deployment caching system |
| 38 | +- **JobQueue.php**: Background job management |
| 39 | +- **CoreOptions.php**: Plugin configuration management |
| 40 | + |
| 41 | +### Utilities |
| 42 | +- **Utils.php**: General utility functions |
| 43 | +- **FilesHelper.php**: File system operations |
| 44 | +- **WsLog.php**: Logging system |
| 45 | +- **SiteInfo.php**: WordPress site information |
| 46 | + |
| 47 | +## Views Directory (`views/`) |
| 48 | +WordPress admin interface templates: |
| 49 | +- **options-page.php**: Main settings interface |
| 50 | +- **run-page.php**: Crawling execution interface |
| 51 | +- **logs-page.php**: Log viewing interface |
| 52 | +- ***-page.php**: Various admin pages for different features |
| 53 | + |
| 54 | +## Testing Structure (`tests/`) |
| 55 | +``` |
| 56 | +tests/ |
| 57 | +├── unit/ # Unit tests (PHPUnit) |
| 58 | +├── integration/ # End-to-end tests |
| 59 | +├── phpstan/ # PHPStan configuration |
| 60 | +└── bootstrap.php # Test bootstrap |
| 61 | +``` |
| 62 | + |
| 63 | +## Development Environment (`dev/`) |
| 64 | +- **flake.nix**: Nix development environment |
| 65 | +- **data/**: Development data (MySQL, WordPress, Nginx configs) |
| 66 | + |
| 67 | +## Naming Conventions |
| 68 | +- **Classes**: PascalCase (e.g., `URLDetector`, `FileProcessor`) |
| 69 | +- **Files**: Match class names (e.g., `URLDetector.php`) |
| 70 | +- **Methods**: camelCase with descriptive names |
| 71 | +- **Constants**: UPPER_SNAKE_CASE (e.g., `STATIC_DEPLOY_VERSION`) |
| 72 | +- **Namespaces**: PSR-4 compliant (`StaticDeploy\`) |
0 commit comments