Update CLAUDE.md with session learnings and project architecture

- Mark version 0.0.1 tasks as completed
- Add version 0.0.2 roadmap items
- Document project directory structure
- Document database tables and REST API endpoints
- Document key classes and their responsibilities
- Fix version location reference (wc-licensed-product.php, not wp-artists.php)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-21 18:56:55 +01:00
parent 404083f023
commit e3d9776b64

View File

@@ -36,11 +36,23 @@ This project is proudly **"vibe-coded"** using Claude.AI - the entire codebase w
**Note for AI Assistants:** Clean this section after the specific features are done or new releases are made. Effective changes are tracked in `CHANGELOG.md` **Note for AI Assistants:** Clean this section after the specific features are done or new releases are made. Effective changes are tracked in `CHANGELOG.md`
### Version 0.0.1 ### Version 0.0.2 (Next)
- Create the basic structure for a Wordpress/WooCommerce plugin, define `woocommerce` as required dependency - Add product version management UI in admin
- Find a reasonable solution to implement a rather safe license management using a client-server-model, bound to single domains. The license server hooks into the existing Wordpress REST API - Implement download URL handling for licensed products
- Start to implement an initial version with the features defined and figured out so far - Add email notification with license key after order completion
- Consider rate limiting for REST API endpoints
### Version 0.0.1 (Completed)
- ✅ Created basic WordPress/WooCommerce plugin structure
- ✅ Implemented domain-bound license management via REST API
- ✅ Added "Licensed Product" WooCommerce product type
- ✅ License generation on order completion (XXXX-XXXX-XXXX-XXXX format)
- ✅ Customer account page for viewing licenses
- ✅ Admin CRUD interface for license management
- ✅ Checkout domain field for licensed products
- ✅ German (de_CH) translation
## Technical Stack ## Technical Stack
@@ -115,8 +127,8 @@ for po in languages/*.po; do msgfmt -o "${po%.po}.mo" "$po"; done
- Track release changes in a single `CHANGELOG.md` file - Track release changes in a single `CHANGELOG.md` file
- Bump the version number to either bugfix release versions or on new features minor release versions - Bump the version number to either bugfix release versions or on new features minor release versions
- **CRITICAL**: WordPress reads version from TWO places - BOTH must be updated: - **CRITICAL**: WordPress reads version from TWO places - BOTH must be updated:
1. Plugin header comment `Version: x.x.x` (line ~6 in wp-artists.php) - WordPress uses THIS for admin display 1. Plugin header comment `Version: x.x.x` (line ~6 in wc-licensed-product.php) - WordPress uses THIS for admin display
2. PHP constant `WC_LICENSED_PRODUCT_VERSION` (line ~25) - Used internally by the plugin 2. PHP constant `WC_LICENSED_PRODUCT_VERSION` (line ~28) - Used internally by the plugin
- If only the constant is updated, WordPress will show the old version in Plugins list - If only the constant is updated, WordPress will show the old version in Plugins list
**Important Git Notes:** **Important Git Notes:**
@@ -190,3 +202,53 @@ When editing CLAUDE.md or other markdown files, follow these rules to avoid lint
7. **MD034 - Bare URLs**: Wrap URLs in angle brackets (e.g., `<https://example.com>`) or use markdown link syntax `[text](url)`. 7. **MD034 - Bare URLs**: Wrap URLs in angle brackets (e.g., `<https://example.com>`) or use markdown link syntax `[text](url)`.
8. **Author section formatting**: Use a heading (`### Name`) instead of bold (`**Name**`) for the author name to maintain consistent document structure. 8. **Author section formatting**: Use a heading (`### Name`) instead of bold (`**Name**`) for the author name to maintain consistent document structure.
## Project Architecture
### Directory Structure
```txt
wc-licensed-product/
├── assets/
│ └── css/ # Frontend and admin stylesheets
├── languages/ # Translation files (.pot, .po, .mo)
├── releases/ # Release packages (version 0.1.0+)
├── src/
│ ├── Admin/ # AdminController - license management UI
│ ├── Api/ # RestApiController - license validation endpoints
│ ├── Checkout/ # CheckoutController - domain field at checkout
│ ├── Frontend/ # AccountController - customer licenses page
│ ├── License/ # License model and LicenseManager
│ └── Product/ # LicensedProduct type and LicensedProductType
├── templates/
│ ├── admin/ # Twig templates for admin views
│ └── frontend/ # Twig templates for customer views
└── vendor/ # Composer dependencies (Twig)
```
### Database Tables
Created on plugin activation via `Installer::createTables()`:
- `{prefix}_wc_licensed_product_licenses` - License keys with domain binding
- `{prefix}_wc_licensed_product_versions` - Product version tracking
### REST API Endpoints
Base: `/wp-json/wc-licensed-product/v1/`
| Endpoint | Method | Description |
| -------------- | ------ | -------------------------------- |
| `/validate` | POST | Validate license key for domain |
| `/status` | POST | Get license status |
| `/activate` | POST | Activate license on domain |
| `/deactivate` | POST | Deactivate license |
### Key Classes
- `Plugin` (singleton) - Main controller, initializes all components
- `Installer` - Database setup, activation/deactivation hooks
- `LicenseManager` - License CRUD, validation, key generation
- `License` - Entity model with status constants
- `LicensedProduct` - Extends WC_Product for licensed products
- `LicensedProductType` - Registers product type with WooCommerce