# My Book – installation (cPanel)

My Book is a separate app with its own folder, database, logins and code. It does not touch three60.lk.

## 1. Make the subdomain
1. cPanel → **Domains** → **Create a New Domain** → `book.three60.lk`.
2. Untick "Share document root" and set the document root to **`book.three60.lk/public`**.
   Only `public/` can be reached from the web. The code (`app/`), settings and stored files (`storage/`) sit next to it and can't be opened in a browser.
3. If the domain is on Cloudflare, add a DNS record `book` pointing to the same server as three60.lk, with the orange cloud (proxied).
4. cPanel → **SSL/TLS Status** → **Run AutoSSL**, so the subdomain gets a certificate.

## 2. Upload the files
1. cPanel → **File Manager** → open `/home/YOUR-CPANEL-USER/book.three60.lk/`.
2. Upload `mybook-v1.zip` there, then **Extract**. You should see `app/`, `public/` and `storage/`.

## 3. Database
cPanel → **MySQL Databases**:
1. Create a database, e.g. `YOURUSER_mybook`.
2. Create a user with a strong password.
3. Add the user to the database with **All privileges**.

Use a **new** database and user, not the three60.lk ones. That way neither site can read the other's data.

## 4. Run the installer
1. Open **https://book.three60.lk**.
2. Enter the database details and **your** name, email and a password (10+ characters) → **Install**.
   You become the IT admin.
3. The installer writes `app/config.php`. **Download a copy of that file and keep it somewhere safe** (for example a password manager or USB stick).
   It holds `app_key`. Without it, nobody's data can be decrypted, not even from a backup.

## 5. Background job
cPanel → **Cron Jobs** → once an hour:
```
/usr/local/bin/php /home/YOUR-CPANEL-USER/book.three60.lk/app/cron.php >/dev/null 2>&1
```

## 6. Your data
1. Sign in at https://book.three60.lk.
2. Choose **Import from Account Book**, then choose the Excel export (Transactions → Export → Excel, whole period).
3. In the preview:
   - Check each account's **type**.
   - Type its **balance today** as Account Book shows it (minus for cards and money you owe).
   - Add the accounts that had no entries in the file (e.g. AIA insurance, Investment on Udaya, BOC Bank, Three60.lk) with **+ Add an account**.
4. Click **Import**. The totals then match Account Book.

Importing the same file again never creates duplicates.

## 7. People
Open **https://book.three60.lk/admin** → **Add a person**.
- They get a temporary password, shown once, and choose their own when they first sign in.
- You see usage only (number of records, storage used, last sign-in, devices, two-step on or off). You can never see anyone's accounts or transactions.

## 8. On the phone (until the Android app is ready)
Open https://book.three60.lk in Chrome → ⋮ → **Add to Home screen** (or **Install app**). It opens like an app and works offline.
Long-pressing the icon offers **Add expense**, **Add income** and **Transfer**.

## Backups
Back up these three things together:
- the database
- the `storage/files` folder (encrypted receipts)
- `app/config.php`

The data is encrypted, so a backup is useless to anyone without `config.php`, and useless to you if you lose it.

## Security summary
- Only `public/` is on the web. Code, settings and files are outside it.
- Each user has their own encryption key, stored encrypted with the master key in `config.php`. Names, descriptions, notes, account numbers and receipt photos are stored encrypted.
- Phones and browsers sign in with their own token, which can be signed out remotely. Two-step sign-in is available.
- After 5 wrong passwords, sign-in pauses for 15 minutes for that email on that connection.
- The admin console uses its own short session and has no page that shows finance records.
