# Project Architecture — `/sync`

## Overview
Workspace `/sync` contains the cPanel Data Sync staging node (`data_sync.php` and its modular gate includes) and deployed site files for `https://syn.sripathwayservices.in/`.

## File Inventory

| File | Purpose |
| :--- | :--- |
| `data_sync.php` | Primary I/O orchestration node for staging writes (`action=write` with `path` and `content_b64`), sync settings (`get_sync_settings`, `set_sync_settings`), portable hosting/code settings (`get_hosting_settings`, `detect_hosting_settings`, `save_hosting_settings`), authentication, batch auto-approval on multi-file upload, and browser approval UI. |
| `includes/data_sync_config.php` | Portable PHP configuration file storing active Site Name, Domain URL, Sync Subpath, Root Folder Label, Strip Path Prefixes, Timezone, CORS Origin, Staging Directory, Max Restore Points, and DB Connect Path; automatically rewritten by Settings. |
| `includes/data_sync_settings_manager.php` | Hosting auto-detection & safe code self-updater engine that writes `includes/data_sync_config.php`, directly patches `data_sync.php` and `includes/data_sync_*.php` (plus optional `project_architecture.md` and `db_custom_config.json`), creates pre-update backups, and invalidates OPcache. |
| `includes/data_sync_approval_gate.php` | Staging queue engine (`.data_sync_staging/`), Auto-Approval setting persistence (`sync_settings.json`), selective/bulk/auto approval execution, preview diff support, Auto Approved vs Manual Approval history tracking, and HTML Approval Center dashboard with Auto-Approval toggle and `⚙ Settings` button. |
| `includes/data_sync_auth_gate.php` | Session and password gate protecting `data_sync.php` dashboard and approval/restore/settings actions, dynamically branded via `data_sync_config.php`. |
| `includes/data_sync_dashboard_modals.php` | Partial rendering Restore Points table, inspector modal, change password modal, confirmation modal, and Hosting & Code Self-Update Settings modal. |
| `includes/data_sync_restore_points.php` | Timestamped pre-update backup snapshots (capturing Auto Approved vs Manual Approval mode) and sequential LIFO rollback / re-apply engine with configurable retention limit. |
| `version.php` | Outputs `Meet saini`. |
| `Studio/index.php` | Build Studio workspace UI (auth gate, Google OAuth 2.0 link modal, named New Project & Delete Project modals, Cloud Sync indicator, auto-stage to `data_sync.php` toggle, chat & Hindi/English voice console, model selector, file explorer, code viewer, live preview, staging push). |
| `Studio/studio_api.php` | Server-side PHP backend handling Studio auth, strict OAuth session clearing on logout/account switch, forced `cloud-platform` OAuth 2.0 scope, automatic Google Cloud project discovery/provisioning (`v3/projects` + Service Usage API), OAuth-to-APIKeys AI Studio fallback key retrieval, named project CRUD, automatic free-tier Gemini model fallback, and automatic/manual staging to `data_sync.php` (guarded by `STUDIO_AS_LIB`). |
| `Studio/studio_config.php` | Protected server configuration holding optional `gemini_api_key`, `google_client_id`, and default model setting. |
| `Studio/studio.css` | Responsive stylesheet for the Build Studio split-pane workspace, wrapping topbar controls, composer auto-stage toggle, chat staging banners, and OAuth/project modals. |
| `Studio/studio.js` | Client-side controller for strict Google Sign-Out / account switching, forced `cloud-platform` OAuth linking, named New Project & Delete Project modals, Google Cloud sync triggers, automatic free-tier model switching, auto-staging generated files into `data_sync.php`, Web Speech API voice input, file explorer, live preview, and ZIP download. |
| `experience/index.php` | Public Experience Desk portal generating professional Experience Letters, purpose-specific NOCs, and multi-month INR Salary Slips with randomized company/letterhead details and A4 PDF export. |
| `experience/admin.php` | Password-protected Admin Console listing all generated experience records alongside a Company & Sample Letterhead Studio. |
| `experience/api.php` | Server-side PHP API powering random company/address/HR email/CIN generation, document packet synthesis, JSON persistence (`.data/`), and Admin authentication/CRUD (guarded by `EXP_AS_LIB`). |
| `experience/renderer.js` | Shared client-side A4 document renderer (5 corporate letterhead themes, SVG logos/stamps/signatures, Experience Letter, NOC, Payslips) and multi-page jsPDF/html2canvas PDF exporter. |
| `experience/experience.css` | Corporate HR SaaS portal stylesheet with tabular numerals and `@media print` A4 page rules. |
| `experience/experience.js` | Client controller for the public document generator form, Till Now toggle, saved company presets, randomizer, and live document preview. |
| `experience/admin.js` | Client controller for Admin login, experience records search/filter, packet inspector modal, and Company Letterhead Studio CRUD. |
| `dummy/index.php` | Public Dummy Travel Desk portal for generating Dummy Flight E-Tickets & Hotel Confirmation Vouchers (One-Way, Round-Trip, Multi-City, Multi-Traveler) with compact viewport-fit split-pane layout and single-row format controls. |
| `dummy/admin.php` | Password-protected Dummy Travel Desk Admin Panel featuring a History tab (all generated bookings, live search, A4 PDF inspector modal, delete) and a General tab (Admin password change and portal overview). |
| `dummy/api.php` | Server-side PHP backend resolving 60+ global airports, fetching live flight codes/timings/hotels via Google/DuckDuckGo/OpenStreetMap with real corridor fallbacks, managing Admin authentication, and storing packets in `.data/` (guarded by `DUMMY_AS_LIB`). |
| `dummy/renderer.js` | Print-ready A4 Flight Ticket & Hotel Voucher renderer with responsive viewport auto-scaling (`.a4-scale-frame`), 3 flight layouts, 3 hotel voucher layouts, 5 font families, SVG barcodes, and multi-page PDF export. |
| `dummy/dummy.css` | Travel SaaS split-pane & Admin Console stylesheet with zero-horizontal-scroll mobile/tablet responsiveness, independent pane scrolling, freeze toggles, and `@media print` A4 formatting. |
| `dummy/dummy.js` | Client controller managing dynamic multi-traveler rows, multi-city flight legs, date-matched hotel stays, live pool shuffling, responsive A4 fit-to-viewport scaling, and `?record=` deep-link loading. |
| `dummy/admin.js` | Client controller for Dummy Admin sign-in, History search/filtering, A4 packet inspector modal with PDF export, inline booking delete, and General tab password updates. |
| `project_architecture.md` | Living architectural index of files in `/sync`. |
