# 📘 Erode Automobiles ERP — Complete Installation & Deployment Manual

Welcome to **Erode Automobiles ERP** (Automobile Dealership, Garage Workshop & 36-Submenu Automobile Manufacturing ERP System).

---

## ⚡ Quick 1-Step Installation

### Method A: Linux / macOS 1-Click Script
```bash
cd erode_automobiles
chmod +x install.sh
./install.sh
```

### Method B: Windows 1-Click Script
Double-click `install.bat` or open Command Prompt:
```cmd
cd erode_automobiles
install.bat
```

### Method C: Web Installation Wizard
1. Start the PHP server:
   ```bash
   php -S 0.0.0.0:8050 server.php
   ```
2. Open your browser and navigate to:
   ```
   http://localhost:8050/install.php
   ```
3. Click **"Run Automated Installation & Seed Data"**.

---

## 📋 System Prerequisites

| Component | Minimum Requirement | Recommended |
| :--- | :--- | :--- |
| **PHP** | `8.0.0` or higher | `8.1` / `8.2` / `8.3` |
| **Database** | SQLite 3 or MySQL 5.7+ / MariaDB 10.3+ | SQLite for Zero-Config, MySQL for High Volume |
| **PHP Extensions** | `pdo`, `pdo_sqlite` or `pdo_mysql`, `mbstring`, `json`, `session` | `curl`, `gd`, `zip` |
| **Web Server** | PHP Built-in Server, Apache, Nginx, or OpenLiteSpeed | Apache / Nginx |

---

## 🔑 Default Seeded Demo Credentials

| Role | Portal Mode | Username | Password |
| :--- | :--- | :--- | :--- |
| **Super Admin / Owner** | All Modules / Enterprise | `admin` | `admin123` |
| **Manufacturing Plant Head** | Manufacturing Only | `admin` | `admin123` |
| **Service Manager** | Sales & Service Only | `service_mgr` | `admin123` |
| **Sales Manager** | Sales & Service Only | `sales_mgr` | `admin123` |
| **Store Manager (Spares & Materials)**| Both Portals | `store_mgr` | `admin123` |
| **Master Technician** | Sales & Service Only | `tech_hari` | `admin123` |
| **Chief Accountant** | Both Portals | `accountant` | `admin123` |

---

## 🗄️ Database Configuration

Configuration file located at `app/Config/database.php`.

### 1. SQLite (Default Zero-Configuration)
No database server setup required. The database file is automatically created at:
`storage/database.sqlite`

### 2. MySQL / MariaDB (Enterprise Mode)
Set environment variables or edit `.env` / `app/Config/database.php`:
```env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=erode_automobiles
DB_USERNAME=root
DB_PASSWORD=your_password
```

---

## 🌐 Web Server Production Deployment

### 1. Apache Configuration (`.htaccess`)
Ensure `mod_rewrite` is enabled. A `.htaccess` file is included in `public/`:
```apache
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
```
Point Apache DocumentRoot to the `public/` directory (or use root `server.php` for built-in server).

### 2. Nginx Configuration
```nginx
server {
    listen 80;
    server_name erp.erodeautomobiles.com;
    root /var/www/erode_automobiles/public;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}
```

---

## 📁 Directory Permissions
Ensure the web server has write permissions to `storage/`:
```bash
chmod -R 775 storage/
chown -R www-data:www-data storage/
```

---

## 🎯 Verification
Once installed, verify the system by checking:
1. **Dealership Portal**: `http://localhost:8050/dashboard`
2. **Manufacturing Portal**: `http://localhost:8050/manufacturing/dashboard`
3. **User Documentation Guide**: `http://localhost:8050/guide`
