# Mystic Art Tattoo

Full website + internal shop hub + admin panel for Mystic Art Tattoo.

Built in plain **PHP 8.1+** with **JSON file storage**, designed to run on shared hosting (Namecheap and similar) with zero daemons, no Node build step, and no database server in the MVP. Everything uses a Repository pattern so the storage layer can be swapped for MySQL in phase 2 without touching controllers.

## Stack

- **PHP 8.1+** (front-controller routed)
- **Apache + .htaccess** for URL rewrites
- **JSON files** under `data/` (locked with `flock`, atomic writes)
- **Tailwind CSS** via CDN (Play), plus a small `site.css` for custom tokens/components
- **Alpine.js** + **htmx** for sprinkles of interactivity
- **PHPMailer** for transactional email (optional — falls back to `mail()`)
- **Bilingual EN/ES** via flat PHP lang files (`src/i18n/en.php`, `es.php`)

## Folder layout

```
MysticArtTattoo/
  config.php                application config (env-overridable)
  composer.json             PHPMailer dep
  public/                   ← document root on Namecheap
    index.php               front controller
    .htaccess               URL rewrites + security headers
    assets/                 css / js
  data/                     ← JSON database (NOT web-reachable)
    .htaccess               deny all
    *.json                  users, artists, appointments, intake_forms, etc.
    uploads/                signatures, references, gallery
    logs/                   error.log
  src/
    autoload.php            PSR-4 fallback when Composer isn't installed
    Router.php / Routes.php
    Controllers/            public, booking, hub, admin, api
    Repositories/           interfaces + JSON implementations
    Services/               Availability, Booking, Email
    Middleware/             RequireRole
    Views/                  layouts, partials, pages (native PHP)
    i18n/                   en.php, es.php
    bin/                    seed.php, seed_admin.php
```

## Local run

```bash
cd MysticArtTattoo
php src/bin/seed.php            # demo artists, schedules, shop settings
php src/bin/seed_admin.php admin changeme123 Admin
php -S localhost:8000 -t public
# open http://localhost:8000
```

## Three surfaces

1. **Public site** — `/`, `/about`, `/artists`, `/portfolio`, `/aftercare`, `/contact`, `/faq`, `/book` (6-step wizard with save-progress + email resume link).
2. **Shop hub** — `/hub/login` → dashboard, appointments, customers, intake forms, walk-ins. First login forces PIN setup; PIN is required to approve bookings, complete appointments, or sign intake forms. All PIN-gated actions are recorded in the audit log.
3. **Admin panel** — `/admin` → overview, users, staff management (create/disable/reset PIN), artist CRUD + weekly schedules + exceptions, gallery upload, audit log, shop settings (hours, contact, taglines in EN/ES, map embed).

## Deploying to Namecheap

1. Upload the whole `MysticArtTattoo/` folder via SFTP, **above** `public_html`.
2. In cPanel → Domains → set the document root to `MysticArtTattoo/public/`.
3. cPanel → MultiPHP Manager → set PHP to **8.1+**.
4. Run `composer install` locally and upload the resulting `vendor/` folder (shared hosts usually lack CLI Composer). Only dep is PHPMailer; the app also runs without it via `mail()` fallback.
5. `chmod 700 data/` and `chmod 600 data/*.json`.
6. Run `php src/bin/seed.php` once via cPanel → Terminal (or temporarily via a web route, then remove it).
7. Run `php src/bin/seed_admin.php youradminuser strongPass123 YourName`.
8. **Delete `src/bin/seed_admin.php`** from the server.
9. Configure SMTP in `config.php` (or via env vars `MAT_SMTP_HOST`, `MAT_SMTP_USER`, `MAT_SMTP_PASS`, `MAT_SMTP_PORT`, `MAT_MAIL_FROM`).
10. Confirm HTTPS (Namecheap AutoSSL), then uncomment the HTTPS redirect block at the top of `public/.htaccess`.

## Phase 2 — migrating to MySQL

Every controller talks to an interface in `src/Repositories/`. To swap storage:

1. Add `MysqlUserRepository implements UserRepository` (and the same for each other repo).
2. Update `src/Repositories/Container.php` to return the `Mysql*` implementations when `config('data_driver') === 'mysql'`.
3. Set `MAT_DATA_DRIVER=mysql` in env.

No controller, view, or service touches JSON directly — the swap is drop-in.

## Paper form → digital mapping

The intake form view digitizes the paper forms from Lorenzo Diaz Ink / Mystic Art:
- General info (name, DOB, contact, address, emergency contact, referral)
- Medical checklist (15 conditions from the paper form)
- Waiver with initials per clause (8 clauses, EN + ES copy)
- Body diagram (4 figures, click to mark placement)
- Pigments field
- Canvas signature → saved as PNG under `data/uploads/signatures/`
- Aftercare acknowledgement checkbox

## Tests

Manual end-to-end smoke test:
1. Customer books from `/book` end-to-end → confirmation email received → resume link works.
2. Admin logs in → creates a staff account → logs out.
3. Staff logs in with temp password → forced to set PIN → approves the pending appointment with PIN.
4. Staff creates a walk-in → searches by phone → finds existing customer → signs form with PIN.
5. Admin opens the audit log → sees both PIN actions.
6. Toggle EN → ES on every public page → all copy translates.
