# Quick Start Guide

This guide will help you set up the **Laravel Domain Foundation** project locally.

## Prerequisites

- PHP 8.2+
- Composer
- Docker (optional, for containerized environment)
- Node.js & NPM

---

## 🐳 Option 1: Docker Setup (Recommended)

1. **Clone the repository**
   ```bash
   git clone https://github.com/AL-WRIFI/laravel-domain-foundation.git
   cd laravel-domain-foundation
   ```

2. **Setup Environment**
   ```bash
   cp .env.example .env
   # No need to edit DB credentials if using Docker default config
   ```

3. **Start Containers**
   ```bash
   docker compose up -d
   ```

4. **Initialize Application**
   ```bash
   docker compose exec app composer install
   docker compose exec app php artisan key:generate
   docker compose exec app php artisan migrate --seed
   ```

5. **Access**
   - API: `http://localhost:8000`
   - Database: `localhost:5432`

---

## 💻 Option 2: Local Setup

1. **Clone and Install**
   ```bash
   git clone https://github.com/AL-WRIFI/laravel-domain-foundation.git
   cd laravel-domain-foundation
   composer install
   npm install
   ```

2. **Configure Environment**
   ```bash
   cp .env.example .env
   php artisan key:generate
   ```
   *Update `.env` with your local database credentials.*

3. **Migrate and Seed**
   ```bash
   php artisan migrate --seed
   ```

4. **Serve**
   ```bash
   php artisan serve
   ```

---

## 🚀 Creating New Domains

This project uses custom Artisan commands to manage DDD modules.

### 1. Create a New Module
To create a new bounded context (Domain):
```bash
php artisan module:make Invoicing
```
*This will create a full directory structure in `modules/Invoicing`.*

### 2. Scaffold Components
Once your module is created, use these commands to generate components:

| Command | Usage | Description |
|---------|-------|-------------|
| `module:entity` | `php artisan module:entity Invoicing Invoice` | Creates a Domain Entity |
| `module:command` | `php artisan module:command Invoicing CreateInvoice` | Creates an Application Command |
| `module:controller` | `php artisan module:controller Invoicing InvoiceController` | Creates a HTTP Controller |
| `module:dto` | `php artisan module:dto Invoicing InvoiceData` | Creates a DTO |
| `module:model` | `php artisan module:model Invoicing Invoice` | Creates an Eloquent Model |
| `module:repository` | `php artisan module:repository Invoicing InvoiceRepository` | Creates a Repository |

### Example Workflow
```bash
# 1. Create the module
php artisan module:make Store

# 2. Create an Entity
php artisan module:entity Store Product

# 3. Create a DTO for input data
php artisan module:dto Store CreateProductData

# 4. Create an Action to handle logic
php artisan module:command Store CreateProduct

# 5. Create a Controller to expose API
php artisan module:controller Store ProductController
```

---

## 🔍 Verifying the Setup

To ensure everything is working correctly, you can run the test suite:

```bash
php artisan test
```
