# Numerology Platform — Step 8B

## Purpose

Step 8B connects the confirmed Step 8A calculator interface to the existing, verified `book-v1` numerology calculation API.

## What changed

- `public/calculator.html` now uses the authenticated user's session.
- `public/assets/app.js` now calls `auth/me` and `numerology/profile` through the existing same-origin `public/api.php` proxy.
- The calculator submits first name, optional middle name, last name, birth date, and the authenticated user ID.
- The verified calculation service remains the calculation engine; the database schema is unchanged.
- Results are displayed on the calculator page after a successful API response.
- `api/controllers/NumerologyProfileController.php` now requires an authenticated session and prevents calculating for a different user ID.
- No database credentials are included in this package.

## Clean upload/test procedure

1. Download this Step 8B ZIP.
2. Extract it.
3. Upload/merge the `numerology-platform` folder over the current confirmed Step 8A project.
4. Do NOT upload or replace your server's `config/database.php` credentials if that file is already configured on your server.
5. Do NOT import SQL or change the database structure.
6. Log in with an existing account.
7. Open `public/calculator.html`.
8. Confirm the form is pre-filled with the account name. Middle name should appear when it is saved.
9. Enter a valid birth date and click **Calculate my profile**.
10. Confirm a successful message appears and the profile results appear below the form.
11. Check phpMyAdmin to confirm a new `numerology_profiles` row and `calculation_runs` row were created for the authenticated user.
12. Confirm the optional middle name remains in `birth_names.middle_names`.

## Expected result

A successful response should display:

- Life Path Method A
- Life Path Method B
- Day of Birth
- Destiny / Expression
- Soul Urge
- Personality
- Present / Missing Numbers
- Personal Year
- Personal Month
- Personal Day
- Calculation run ID
- Methodology version `book-v1`

## Important

This package does not change the existing schema and does not include database credentials.

## Step 8B fix: automatic Y-role handling

The standard calculator form does not expose a manual Y-role field. The name calculator therefore now accepts explicit Y roles when supplied by an advanced caller, but automatically determines the role when they are omitted. This prevents normal names containing Y from failing with `Every Y requires a vowel/consonant role.`

Names such as `Folawiyo` and `Ajayi` can now be calculated through the normal calculator UI without additional Y-role input.


## Step 8B repeat-calculation fix

If the same authenticated user returns from the home page and calculates again, the existing `numerology_profiles` row is updated instead of attempting a second insert. The calculation history remains in `calculation_runs`, so repeat calculations are supported without changing the database schema.

The calculator JavaScript cache version was also incremented so the browser loads the corrected code after upload.
