## Development Recommendations

-   Use [Herd](https://herd.laravel.com/) to serve the app
-   Use [DBngin](https://dbngin.com/) for MySQL and Redis

### Running S3 in localstack

1. Make sure [Docker](https://www.docker.com/) is installed and running
1. Start localstack using `docker compose up`

#### Bucket creation

1. Make sure localstack is running (see instructions above)
1. Make sure [mise](https://mise.jdx.dev/) is installed
1. Run `mise install` to ensure needed dependencies are available
1. Run `cd terraform-local`
1. Run `terraform init`
1. Run `terraform apply -auto-approve`
1. If you have the aws cli installed and configured with test credentials you can run `aws s3 ls` to confirm that the bucket exists.
1. Now that the bucket exists you can give laravel access to the bucket using the following env vars:

    ```sh
    AWS_ACCESS_KEY_ID=test
    AWS_SECRET_ACCESS_KEY=test
    AWS_DEFAULT_REGION=us-east-2
    AWS_BUCKET=mqmanager
    AWS_USE_PATH_STYLE_ENDPOINT=true
    AWS_ENDPOINT_URL="http://localhost:4566"
    ```

#### Testing that Laravel can access the bucket

1. Run `php artisan tinker`
1. Run the following commands

    ```php
    use Illuminate\Support\Facades\Storage;
    $client = Storage::disk('s3')->getClient();
    echo $client->listBuckets();
    ```

## Code linting

### PHP

The project uses [PHPStan](https://phpstan.org/) for linting and [PHP-CS-Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) for formatting

-   Lint: `composer run-script lint`
-   Format: `composer run-script format`
-   Both: `composer run-script check`

### JavaScript

The project uses [Biome](https://biomejs.dev/) for linting and formatting JavaScript files

-   Lint: `npm run lint`
-   Lint fix: `npm run lint:fix`
-   Format: `npm run format`

## Web client

Uses [Inertia](https://inertiajs.com/) and [Vite](https://vite.dev/)

### Install dependencies

1. Run `npm install`

### Run the Vite dev server

1. Run `npm run dev`

## Web client development

### Reusable Components: Tremor

The project uses [Tremor](https://www.tremor.so/) for shared componenets. See resources/js/TremoreComponents for components that have already been imported into the project.

When importing new components, instead of the standard location for Tremor utils, `@/lib/utils`, the utils file can be found in `@/tremor-lib/utils`.

## Misc Utils

### Create new users

1. Run `php artisan tinker`
1. Run the following code

    ```
    use App\Models\User;
    $user = User::create([
        'name' => '<Replace with name>',
        'email' => '<Replace with email address>',
        'password' => Hash::make('<Replace with password>'),
    ]);
    event(new Registered($user));
    ```

## [In Progress] Scripts to Rule Them All (STRTA)

[Scripts To Rule Them All](https://github.com/github/scripts-to-rule-them-all)

Scripts implemented so far:

1. `./scripts/server.sh`
   Expects you to be have docker and terraform installed
