# BW AI Schema Pro — Architecture

**Version:** 2.1.3 | **Last Updated:** 2026-05-06

## Overview

(Stub — pre-existing plugin imported on 2026-05-06. High-level: AI-optimized schema markup with admin UI, blocks, author/team detection, and template-based rendering. Detailed architecture write-up pending — fill in by reading the code.)

## File Layout

```
bw-ai-schema-pro/
├── bw-ai-schema-pro.php       Main plugin file, bootstrap (~1k lines incl. activation/deactivation hooks)
├── includes/                   Core classes (see "Core Classes" below)
│   ├── class-bw-schema-*.php  All class files use legacy `bw-schema-` prefix (see CLAUDE.md)
│   └── schemas/                Schema definitions
├── admin/                      Admin UI
├── assets/                     Frontend CSS/JS
├── blocks/                     Gutenberg blocks
├── vendor/plugin-update-checker  YahnisElsts plugin update checker v5.6
└── docs/                       Dev docs (not shipped in releases)
```

## Core Classes

| Class | File | Responsibility |
|---|---|---|
| `BW_AI_Schema_Pro` | `bw-ai-schema-pro.php` | Main bootstrap |
| `BW_Schema_Core` | `includes/class-bw-schema-core.php` | (TBD — read code) |
| `BW_Schema_Renderer` | `includes/class-bw-schema-renderer.php` | (TBD) |
| `BW_Schema_Cache` | `includes/class-bw-schema-cache.php` | (TBD) |
| `BW_Schema_Security` | `includes/class-bw-schema-security.php` | (TBD) |
| `BW_Schema_Blocks` | `includes/class-bw-schema-blocks.php` | (TBD) |
| `BW_Schema_Hooks` | `includes/class-bw-schema-hooks.php` | (TBD) |
| `BW_Schema_Helpers` | `includes/class-bw-schema-helpers.php` | (TBD) |
| `BW_Schema_Templates` | `includes/class-bw-schema-templates.php` | (TBD) |
| `BW_Schema_Admin` | `includes/class-bw-schema-admin.php` | (TBD) |
| `BW_Schema_Author_Box` | `includes/class-bw-schema-author-box.php` | (TBD) |
| `BW_Schema_Author_Override` | `includes/class-bw-schema-author-override.php` | (TBD) |
| `BW_Schema_Team_Detector` | `includes/class-bw-schema-team-detector.php` | (TBD) |
| `BW_Schema_Team_Member` | `includes/class-bw-schema-team-member.php` | (TBD) |
| `BW_Schema_Room` | `includes/class-bw-schema-room.php` | Accommodations module (2.4.0) — room CPT meta box, save handler, and the single `get_room_schema_data()` provider feeding the room page node and `Organization.containsPlace[]`. See `docs/SPEC-accommodations.md`. |

## Hooks

### Actions
(TBD — grep `do_action` in source.)

### Filters
(TBD — grep `apply_filters` in source.)

## Data Storage

(TBD — grep `get_option`, `update_option`, `get_post_meta`, `set_transient`, `$wpdb` in source. **This inventory is a prerequisite for the 3.0.0 prefix-rename data migration in ROADMAP.md.**)

### Accommodations module (2.4.0) — inventoried

Recorded here as it was written, so the 3.0.0 migration doesn't have to rediscover it.

**Options:** `bw_schema_room_post_type` (string), `bw_schema_accommodation`
(array: `currency`, `rate_unit`, `rate_stale_days`). Also mirrored into
`bw_schema_settings['content']['room_post_type']`.

**Post meta** (all on the configured room CPT, namespaced `_bw_schema_room_*` to
avoid colliding with `_bw_schema_amenities` on the LocalBusiness path and the
Person module's keys): `_bw_schema_room_type`, `_bw_schema_room_exclude`,
`_bw_schema_room_override_name`, `_bw_schema_room_override_description`,
`_bw_schema_room_override_image`, `_bw_schema_room_override_url`,
`_bw_schema_room_occupancy`, `_bw_schema_room_beds`, `_bw_schema_room_layout`,
`_bw_schema_room_amenities`, `_bw_schema_room_policies`, `_bw_schema_room_offer`,
`_bw_schema_room_floorplan_image`, `_bw_schema_room_tour_booking_page`,
`_bw_schema_room_video`.

**Transients:** none of its own — room nodes ride the existing
`BW_Schema_Cache` post cache, which the save handler clears.

### Locations module (2.5.0) — inventoried

**Options:** `bw_schema_locations` (array of location rows, each with an
immutable `id` plus `name`, `type`, `street`, `city`, `region`, `postal`,
`country`, `lat`, `lng`, `telephone`, `email`, `url`, `use_main_hours`,
`areas[]`), and `bw_schema_service_areas` (company-wide service-area rows).

**Post meta:** none. **Transients:** none.

**Legacy read-only fallback:** `bw_schema_organization['areaServed']` (array of
strings) is still *read* when `bw_schema_service_areas` is empty, and migrates on
the first save of the Locations tab. The 3.0.0 migration must carry it.

### Config export/import (2.6.0) — inventoried

**Options:** `bw_schema_config_backup` (single undo slot: `taken_at`, `reason`,
and a full `payload` export).

**Post meta / transients:** none.

`BW_Schema_Config_IO::get_tier_map()` is the authoritative classification of
every plugin option into config / site_specific / authors / never — it is the
closest thing this plugin has to a full option inventory, and the 3.0.0 rename
migration should be driven from it rather than a hand-written list.

## External Dependencies

- `vendor/plugin-update-checker` — YahnisElsts plugin update checker v5.6

## Security Notes

(TBD — review `class-bw-schema-security.php` and document.)
