# themefic-team/tourfic architecture

> Architecture diagram of the GitHub repository themefic-team/tourfic, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/themefic-team/tourfic
- Repository: https://github.com/themefic-team/tourfic

## Overview

1. Tourfic is a WordPress plugin, so the runtime boundary is WordPress/PHP first, with browser-side CSS/JS shipped as plugin assets. The main entrypoints are `tourfic.php`, `autoloader.php`, and the classes under `inc/`.

2. The core domain is built around multiple travel product types: hotel, tour, apartment, car rental, and room. Each type has its own CPT, pricing, availability, and taxonomies in `inc/Classes/*` and `inc/Admin/TF_Options/taxonomies/*`.

3. Content editing and site setup live in the admin layer. `inc/Admin/TF_Options` provides the plugin’s metabox/settings framework, while `tf-*-metabox.php`, setup wizard, demo importer, notices, dashboard widgets, and menu/icon settings define how travel inventory is configured in wp-admin.

4. Frontend rendering is template-driven. The `templates/` tree contains archive/single/search/wishlist pages, and `inc/App/Templates/Components/*` breaks those pages into reusable UI sections such as gallery, booking form, map, reviews, amenities, itinerary, and related content.

5. Data flow on the frontend is mostly: WordPress content + custom fields + availability/pricing logic -> template component -> rendered archive/single/search page. The repository keeps the presentation layer separate from the domain logic, so template files stay thin and domain classes compute the bookable state.

6. Search and discovery are a major subsystem. Shortcodes in `inc/App/Shortcodes` and widgets in `inc/App/Widgets` expose listings, filters, destination/brand/location blocks, review sliders, wishlist, and search forms to both native WordPress pages and page builders.

7. Booking, enquiry, and email handling form the transactional layer. Availability/pricing classes for each product type feed booking forms and backend booking screens, while `inc/Admin/Booking_Details`, `inc/Admin/Backend_Booking`, `inc/Admin/Enquiry`, and `inc/Admin/Emails` manage booking records, admin-side details, enquiry capture, and booking notifications/confirmation/cancellation emails.

8. There is a dedicated REST API boundary in `inc/Classes/REST_API`. Routes for bookings, enquiries, users, and each product type suggest the plugin supports JavaScript-driven interactions and external integrations beyond normal page requests.

9. WooCommerce is an optional commerce integration layer. `inc/Classes/Woocommerce` and `inc/functions/woocommerce/*` adapt hotel/car/tour/apartment bookings into WooCommerce products/orders and handle tax/VAT concerns.

10. Page-builder and template-builder support is a distinct extension layer. Elementor widgets live under `inc/App/Widgets/Elementor`, and Bricks/Elementor demo template JSON files under `assets/demo/` show that listing and single-page layouts can be imported or composed outside the core PHP templates.

11. Static assets are split by admin vs app vs product type. The source styles live in `sass/`, compiled CSS/JS is under `assets/`, and frontend dependencies include libraries such as Leaflet, Flatpickr, Select2, Slick, Chart.js, Fancybox, and validation/notification utilities.

12. The repository also includes security regression tests in `tests/security`, indicating the plugin has been hardened around booking counts, REST authorization, SQL injection, and review/enquiry surfaces. Internationalization is supported via `lang/` and `wpml-config.xml`.

13. From an architecture diagram perspective, the key boundaries are: WordPress admin configuration, domain/CPT and availability logic, frontend templates/widgets/shortcodes, transactional booking/enquiry/email flows, REST API integrations, and optional WooCommerce/page-builder integrations.

Main entry points: [`inc/Classes`](https://github.com/themefic-team/tourfic/tree/master/inc/Classes) (Core Classes), [`templates`](https://github.com/themefic-team/tourfic/tree/master/templates) (Templates), [`inc/Classes/REST_API`](https://github.com/themefic-team/tourfic/tree/master/inc/Classes/REST_API) (REST API), [`inc/Classes/Woocommerce`](https://github.com/themefic-team/tourfic/tree/master/inc/Classes/Woocommerce) (WooCommerce)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_root["Plugin Core"]
  node_tourfic_php["tourfic.php<br/>plugin bootstrap<br/>[tourfic.php]"]
  node_autoloader_php["Autoloader<br/>autoload bootstrap<br/>[autoloader.php]"]
  node_core_classes["Core Classes<br/>runtime core"]
  node_core_helpers["Helpers<br/>shared utilities<br/>[functions.php]"]
end

subgraph group_group_admin["Admin"]
  node_admin_options["Options Framework<br/>admin config UI"]
  node_admin_setup["Setup & Import<br/>admin onboarding"]
  node_admin_bookings["Bookings<br/>admin booking mgmt"]
  node_admin_enquiry["Enquiries<br/>admin lead mgmt"]
  node_admin_emails["Emails<br/>notification layer"]
end

subgraph group_group_domain["Domain Logic"]
  node_product_hotel["Hotels<br/>hotel domain"]
  node_product_tour["Tours<br/>tour domain"]
  node_product_apartment["Apartments<br/>apartment domain"]
  node_product_car["Car Rentals<br/>rental domain"]
  node_product_room["Rooms<br/>room domain"]
  node_rest_api["REST API<br/>api boundary"]
end

subgraph group_group_frontend["Frontend"]
  node_shortcodes["Shortcodes<br/>content blocks"]
  node_widgets["Widgets"]
  node_template_components["UI Components<br/>template parts"]
  node_templates["Templates"]
  node_wishlist_review["Wishlist & Reviews<br/>user features<br/>[Wishlist.php]"]
end

subgraph group_group_integrations["Integrations"]
  node_woocommerce["WooCommerce<br/>commerce adapter"]
  node_builder_support["Builder Support<br/>page builder"]
  node_assets["Assets<br/>css/js bundles"]
  node_localization["i18n<br/>translations"]
end

node_tourfic_php -->|"boots"| node_autoloader_php
node_tourfic_php -->|"starts"| node_core_classes
node_autoloader_php -->|"loads"| node_core_classes
node_core_classes -->|"configures"| node_admin_options
node_core_classes -->|"registers"| node_admin_setup
node_core_classes -->|"manages"| node_admin_bookings
node_core_classes -->|"captures"| node_admin_enquiry
node_core_classes -->|"sends"| node_admin_emails
node_core_classes -->|"defines"| node_product_hotel
node_core_classes -->|"defines"| node_product_tour
node_core_classes -->|"defines"| node_product_apartment
node_core_classes -->|"defines"| node_product_car
node_core_classes -->|"defines"| node_product_room
node_product_hotel -->|"exposes"| node_rest_api
node_product_tour -->|"exposes"| node_rest_api
node_product_apartment -->|"exposes"| node_rest_api
node_product_car -->|"exposes"| node_rest_api
node_product_room -->|"exposes"| node_rest_api
node_product_hotel -->|"renders"| node_templates
node_product_tour -->|"renders"| node_templates
node_product_apartment -->|"renders"| node_templates
node_product_car -->|"renders"| node_templates
node_product_room -->|"renders"| node_templates
node_templates -->|"composes"| node_template_components
node_shortcodes -->|"feeds"| node_templates
node_widgets -->|"reuses"| node_shortcodes
node_widgets -->|"reuses"| node_template_components
node_wishlist_review -->|"supports"| node_shortcodes
node_woocommerce -->|"adapts"| node_product_hotel
node_woocommerce -->|"adapts"| node_product_tour
node_woocommerce -->|"adapts"| node_product_apartment
node_woocommerce -->|"adapts"| node_product_car
node_builder_support -->|"extends"| node_templates
node_builder_support -->|"ships"| node_assets
node_core_classes -->|"enqueues"| node_assets
node_localization -->|"localizes"| node_templates

click node_tourfic_php "https://github.com/themefic-team/tourfic/blob/master/tourfic.php"
click node_autoloader_php "https://github.com/themefic-team/tourfic/blob/master/autoloader.php"
click node_core_classes "https://github.com/themefic-team/tourfic/tree/master/inc/Classes"
click node_core_helpers "https://github.com/themefic-team/tourfic/blob/master/inc/functions.php"
click node_admin_options "https://github.com/themefic-team/tourfic/tree/master/inc/Admin/TF_Options"
click node_admin_setup "https://github.com/themefic-team/tourfic/blob/master/inc/Admin/TF_Setup_Wizard.php"
click node_admin_bookings "https://github.com/themefic-team/tourfic/tree/master/inc/Admin/Backend_Booking"
click node_admin_enquiry "https://github.com/themefic-team/tourfic/tree/master/inc/Admin/Enquiry"
click node_admin_emails "https://github.com/themefic-team/tourfic/blob/master/inc/Admin/Emails/TF_Handle_Emails.php"
click node_product_hotel "https://github.com/themefic-team/tourfic/tree/master/inc/Classes/Hotel"
click node_product_tour "https://github.com/themefic-team/tourfic/tree/master/inc/Classes/Tour"
click node_product_apartment "https://github.com/themefic-team/tourfic/tree/master/inc/Classes/Apartment"
click node_product_car "https://github.com/themefic-team/tourfic/tree/master/inc/Classes/Car_Rental"
click node_product_room "https://github.com/themefic-team/tourfic/tree/master/inc/Classes/Room"
click node_rest_api "https://github.com/themefic-team/tourfic/tree/master/inc/Classes/REST_API"
click node_shortcodes "https://github.com/themefic-team/tourfic/tree/master/inc/App/Shortcodes"
click node_widgets "https://github.com/themefic-team/tourfic/tree/master/inc/App/Widgets"
click node_template_components "https://github.com/themefic-team/tourfic/tree/master/inc/App/Templates/Components"
click node_templates "https://github.com/themefic-team/tourfic/tree/master/templates"
click node_wishlist_review "https://github.com/themefic-team/tourfic/blob/master/inc/App/Wishlist.php"
click node_woocommerce "https://github.com/themefic-team/tourfic/tree/master/inc/Classes/Woocommerce"
click node_builder_support "https://github.com/themefic-team/tourfic/blob/master/inc/App/Templates/Template_Builder.php"
click node_assets "https://github.com/themefic-team/tourfic/tree/master/assets"
click node_localization "https://github.com/themefic-team/tourfic/tree/master/lang"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_tourfic_php,node_autoloader_php,node_core_classes,node_core_helpers toneBlue
class node_admin_options,node_admin_setup,node_admin_bookings,node_admin_enquiry,node_admin_emails toneAmber
class node_product_hotel,node_product_tour,node_product_apartment,node_product_car,node_product_room,node_rest_api toneMint
class node_shortcodes,node_widgets,node_template_components,node_templates,node_wishlist_review toneRose
class node_woocommerce,node_builder_support,node_assets,node_localization toneIndigo
```

## Components

### Plugin Core

Plugin bootstrap, shared core classes, and runtime wiring.

- [tourfic.php](https://github.com/themefic-team/tourfic/blob/master/tourfic.php): plugin bootstrap · Main plugin entrypoint that starts the runtime. · `tourfic.php`
- [Autoloader](https://github.com/themefic-team/tourfic/blob/master/autoloader.php): autoload bootstrap · Loads plugin classes and dependencies. · `autoloader.php`
- [Core Classes](https://github.com/themefic-team/tourfic/tree/master/inc/Classes): runtime core · Shared core services and plugin lifecycle wiring. · `inc/Classes`
- [Helpers](https://github.com/themefic-team/tourfic/blob/master/inc/functions.php): shared utilities · Common helper functions and support traits. · `inc/functions.php`

### Admin

WordPress admin configuration, booking management, notices, and setup.

- [Options Framework](https://github.com/themefic-team/tourfic/tree/master/inc/Admin/TF_Options): admin config UI · Metabox, settings, shortcode, and taxonomy field framework. · `inc/Admin/TF_Options`
- [Setup & Import](https://github.com/themefic-team/tourfic/blob/master/inc/Admin/TF_Setup_Wizard.php): admin onboarding · Setup wizard, demo importer, duplicator, and notices. · `inc/Admin/TF_Setup_Wizard.php`
- [Bookings](https://github.com/themefic-team/tourfic/tree/master/inc/Admin/Backend_Booking): admin booking mgmt · Backend booking screens and booking detail views. · `inc/Admin/Backend_Booking`
- [Enquiries](https://github.com/themefic-team/tourfic/tree/master/inc/Admin/Enquiry): admin lead mgmt · Admin-side enquiry capture and handling. · `inc/Admin/Enquiry`
- [Emails](https://github.com/themefic-team/tourfic/blob/master/inc/Admin/Emails/TF_Handle_Emails.php): notification layer · Booking notification, confirmation, and cancellation email flows. · `inc/Admin/Emails/TF_Handle_Emails.php`

### Domain Logic

Product-type models, availability, pricing, and REST boundaries.

- [Hotels](https://github.com/themefic-team/tourfic/tree/master/inc/Classes/Hotel): hotel domain · Hotel CPT, pricing, and availability logic. · `inc/Classes/Hotel`
- [Tours](https://github.com/themefic-team/tourfic/tree/master/inc/Classes/Tour): tour domain · Tour CPT, pricing, and itinerary/booking logic. · `inc/Classes/Tour`
- [Apartments](https://github.com/themefic-team/tourfic/tree/master/inc/Classes/Apartment): apartment domain · Apartment CPT, pricing, and availability logic. · `inc/Classes/Apartment`
- [Car Rentals](https://github.com/themefic-team/tourfic/tree/master/inc/Classes/Car_Rental): rental domain · Car rental CPT, pricing, and availability logic. · `inc/Classes/Car_Rental`
- [Rooms](https://github.com/themefic-team/tourfic/tree/master/inc/Classes/Room): room domain · Room CPT and pricing/availability support. · `inc/Classes/Room`
- [REST API](https://github.com/themefic-team/tourfic/tree/master/inc/Classes/REST_API): api boundary · Routes for bookings, enquiries, users, and product types. · `inc/Classes/REST_API`

### Frontend

Templates, shortcodes, widgets, and reusable UI components.

- [Shortcodes](https://github.com/themefic-team/tourfic/tree/master/inc/App/Shortcodes): content blocks · Listing, search, wishlist, review, and filter shortcodes. · `inc/App/Shortcodes`
- [Widgets](https://github.com/themefic-team/tourfic/tree/master/inc/App/Widgets): ui widgets · WordPress widgets and Elementor widgets for listings and search. · `inc/App/Widgets`
- [UI Components](https://github.com/themefic-team/tourfic/tree/master/inc/App/Templates/Components): template parts · Reusable archive and single-page components for each product. · `inc/App/Templates/Components`
- [Templates](https://github.com/themefic-team/tourfic/tree/master/templates): theme templates · Archive, single, search, taxonomy, and wishlist page templates. · `templates`
- [Wishlist & Reviews](https://github.com/themefic-team/tourfic/blob/master/inc/App/Wishlist.php): user features · Wishlist and review-related frontend behavior. · `inc/App/Wishlist.php`

### Integrations

Optional commerce, builder, asset, and localization layers.

- [WooCommerce](https://github.com/themefic-team/tourfic/tree/master/inc/Classes/Woocommerce): commerce adapter · Optional product/order and tax/VAT integration. · `inc/Classes/Woocommerce`
- [Builder Support](https://github.com/themefic-team/tourfic/blob/master/inc/App/Templates/Template_Builder.php): page builder · Elementor/Bricks template-builder support and demo layouts. · `inc/App/Templates/Template_Builder.php`
- [Assets](https://github.com/themefic-team/tourfic/tree/master/assets): css/js bundles · Admin and frontend compiled CSS/JS plus vendor libraries. · `assets`
- [i18n](https://github.com/themefic-team/tourfic/tree/master/lang): translations · Language packs and WPML configuration. · `lang`

## Connections

- tourfic.php → Autoloader: boots · Main plugin file initializes loading.
- tourfic.php → Core Classes: starts · Registers the core runtime services.
- Autoloader → Core Classes: loads · Autoloads plugin classes.
- Core Classes → Options Framework: configures · Core uses the options framework for metaboxes and settings.
- Core Classes → Setup & Import: registers · Connects onboarding and admin notices.
- Core Classes → Bookings: manages · Wires backend booking management.
- Core Classes → Enquiries: captures · Connects enquiry handling.
- Core Classes → Emails: sends · Routes booking events into email notifications.
- Core Classes → Hotels: defines · Hotel subsystem domain logic.
- Core Classes → Tours: defines · Tour subsystem domain logic.
- Core Classes → Apartments: defines · Apartment subsystem domain logic.
- Core Classes → Car Rentals: defines · Car rental subsystem domain logic.
- Core Classes → Rooms: defines · Room subsystem domain logic.
- Hotels → REST API: exposes · Hotel routes are available through the API boundary.
- Tours → REST API: exposes · Tour routes are available through the API boundary.
- Apartments → REST API: exposes · Apartment routes are available through the API boundary.
- Car Rentals → REST API: exposes · Car rental routes are available through the API boundary.
- Rooms → REST API: exposes · Room routes are available through the API boundary.
- Hotels → Templates: renders · Hotel pages are rendered by template files.
- Tours → Templates: renders · Tour pages are rendered by template files.
- Apartments → Templates: renders · Apartment pages are rendered by template files.
- Car Rentals → Templates: renders · Car rental pages are rendered by template files.
- Rooms → Templates: renders · Room pages are rendered by template files.
- Templates → UI Components: composes · Top-level templates assemble reusable UI components.
- Shortcodes → Templates: feeds · Shortcodes render listing and search views.
- Widgets → Shortcodes: reuses · Widget implementations expose the same discovery surfaces.
- Widgets → UI Components: reuses · Widgets share UI building blocks.
- Wishlist & Reviews → Shortcodes: supports · Wishlist and review features are surfaced in content blocks.
- WooCommerce → Hotels: adapts · Commerce integration for hotel bookings.
- WooCommerce → Tours: adapts · Commerce integration for tour bookings.
- WooCommerce → Apartments: adapts · Commerce integration for apartment bookings.
- WooCommerce → Car Rentals: adapts · Commerce integration for car bookings.
- Builder Support → Templates: extends · Page-builder layouts can override or supplement templates.
- Builder Support → Assets: ships · Builder-related scripts and styles are bundled as assets.
- Core Classes → Assets: enqueues · Core runtime enqueues admin and app assets.
- i18n → Templates: localizes · Template strings and UI text are translated.
