# Local Setup

This guide walks you through running Turista on your local machine.

## Prerequisites

- PHP 8.4+
- Composer 2.9+
- MySQL 8.0+
- Node.js 20+
- NPM 10+

## Step-by-step

1. **Install PHP dependencies**

   ```bash
   composer install
   ```

2. **Install JavaScript dependencies**

   ```bash
   npm install
   ```

3. **Create environment file**

   ```bash
   cp .env.example .env
   ```

   Update `.env` with your database credentials and any required third-party API keys (CoreVerde WhatsApp, mail, etc.).

4. **Generate application key**

   ```bash
   php artisan key:generate
   ```

5. **Create the storage link**

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

6. **Run migrations and seeders**

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

   This creates roles, permissions, and the default location data (Libya by default).

7. **Build frontend assets**

   ```bash
   npm run build
   ```

## Running the development stack

```bash
composer run dev
```

This starts the Laravel development server, a queue worker, and the Vite dev server concurrently.

## Creating the first super admin

After seeding, create a super admin via CLI:

```bash
php artisan admin:create-super admin@example.com
```

You will be prompted for a secure password.

## Downloading location data

If you need to seed additional countries:

1. Update `SEED_COUNTRIES` in `.env`.
2. Run:

   ```bash
   php artisan locations:download
   php artisan db:seed --class=LocationSeeder
   ```

## Verifying the setup

Run the verification commands from the top-level README:

```bash
php artisan test
vendor/bin/pint --test
npm run build
php artisan route:cache
php artisan optimize
```

All tests should pass and the build should complete without errors.
