# Installation Guide

## Prerequisites

Ensure your environment has:
- PHP 8.2 or higher with these extensions: `pdo_mysql`, `mbstring`, `openssl`, `gd`, `xml`, `ctype`, `json`, `tokenizer`, `fileinfo`
- Composer 2.x
- MySQL 8.0+ (or MariaDB 10.4+)
- Apache with mod_rewrite enabled (for production) or PHP's built-in server (for development)

## Step-by-Step Installation

### 1. Install PHP Dependencies

```bash
composer install
```

### 2. Configure Environment

```bash
cp .env.example .env
php artisan key:generate
```

Edit `.env`:
```env
APP_NAME="SecureBank"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost:8000

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=online_banking
DB_USERNAME=root
DB_PASSWORD=

MAIL_MAILER=smtp
MAIL_HOST=mail.example.com
MAIL_PORT=587
MAIL_USERNAME=no-reply@securebank.com
MAIL_PASSWORD=your_password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=no-reply@securebank.com
MAIL_FROM_NAME="SecureBank"
```

### 3. Create the Database

Create a MySQL database named `online_banking`:

```sql
CREATE DATABASE online_banking CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
```

Or use phpMyAdmin to create the database and import `database/sql/banking_schema.sql`.

### 4. Run Migrations and Seeders

```bash
php artisan migrate --seed
```

This creates all 24+ tables and seeds:
- Default roles and permissions
- Bank settings
- Authentication settings
- Default verification rules (COT, Tax, IMF)
- Default admin user
- Demo customer with account and balance

### 5. Generate PWA Icons

```bash
php artisan pwa:generate-icons
```

### 6. Create Storage Symlink

```bash
php artisan storage:link
```

### 7. Start the Development Server

```bash
php artisan serve
```

Visit `http://localhost:8000`.

## Default Login Credentials

### Customer Portal
- URL: `http://localhost:8000/login`
- Email: `demo@securebank.com`
- Password: `password123`
- Transfer PIN: `1234`

### Admin Portal
- URL: `http://localhost:8000/admin/login`
- Email: `admin@securebank.com`
- Password: `admin12345`

## Troubleshooting

### "No application encryption key has been specified"
Run `php artisan key:generate`.

### Database connection errors
- Verify your MySQL credentials in `.env`
- Ensure the MySQL service is running
- Check that the database `online_banking` exists

### SMTP emails not sending
- Configure SMTP in the admin dashboard under Settings > SMTP
- Or set the `MAIL_*` variables in `.env`
- Test the connection from the admin panel

### PWA icons missing
Run `php artisan pwa:generate-icons` to generate the app icons.

### Permission errors on storage
```bash
chmod -R 775 storage bootstrap/cache
```

### "Class not found" errors
Run `composer dump-autoload`.
