# Popina Order: C\&C Solution (2.0.0)

**Popina Order** is a Click & Collect solution that allows consumers to order products online and pick them up in-store within a few minutes to a few hours.

---

## Prerequisites

* **Docker**: Minimum version `24.0.6`
* **PHP**: `8.1.14` (without Docker)
* **MySQL**: `8.0.31` (without Docker)

---

## Architecture

The complete project architecture is available [here: Documentation Architecture](#).

---

## Frameworks and Libraries

Check the frameworks and libraries used here: [Architectural Drivers](#).

---

## Integrations

* Pragma (Popina / Jalia)
* Kézia
* C\&C Site
* Kiosk (terminals)

---

## Installation

1. **Clone the repository:**

    ```bash
    git clone git@github.com:popina/popina-order.git
    cd popina-order
    ```

2. **Setting up the environment:**

    Before running `make up` command for the first time:

    * Create a `.env.local` file and configure the required environment variables, especially `GHCR_USERNAME` and `GHCR_TOKEN`.
    * Copy the database dump (should be named `foxorders.sql`) into `docker/db/init/`.
    * Configure your hosts file by adding the required local domains:
    ```text
    127.0.0.1 foxorders.development
    127.0.0.1 phpmyadmin.foxorders.development
    ```

3. **Start Docker containers:**

    ```bash
    make up
    ```

---

## Usage

* HTTPS: BO, API, and Documentation
* HTTP: BO, API, and Documentation

---

## Configuration & Useful Commands

### Display Help

```bash
make help
```

This will output all available Docker and project commands.

![Help Command Output](./docker/images/help.png)

---

### Available Docker Commands

#### **Build Images**

```bash
make build-base    # Builds base Docker image
make build-local   # Builds local image
make build-dev     # Builds development image
make build-staging # Builds staging image
make build-prod    # Builds production image
```

#### **Push Images**

```bash
make push-base
make push-local
make push-dev
make push-staging
make push-prod
```

---

### **Container Management**

```bash
make up       # Starts Docker in detached mode (SSL authority approval may be requested)
make start    # Starts stopped containers
make stop     # Stops containers
make restart  # Restarts containers
make down     # Stops and removes containers
```

### Test Coverage

Coverage can be generated without changing the existing `composer unit`, `composer functional`, `composer application`, or `composer tests` workflows.

Local coverage command inside the PHP container:

```bash
docker exec php-container composer coverage
```

The GitHub CI workflow uses `docker exec php-container composer coverage-ci`, which skips HTML generation to keep memory usage down while still producing the XML and text reports consumed by the workflow.

Generated reports:

* Machine-readable coverage: `build/coverage/clover.xml`, `build/coverage/cobertura.xml`
* Machine-readable test results: `build/coverage/junit.xml`
* Human-readable coverage: `build/coverage/html/index.html`
* Text summary: `build/coverage/summary.txt`
* GitHub Actions step summary: a markdown dashboard rendered from `clover.xml`, `junit.xml`, and `summary.txt`

If you want to mirror the CI environment locally, start the CI stack and then run coverage:

```bash
docker compose -f compose.ci.yml up -d --build
docker exec php-container composer coverage
docker cp php-container:/var/www/html/build/coverage/. ./build/coverage/
```

The GitHub CI workflow runs the lighter `composer coverage-ci` command, prints the text summary in job logs, renders a markdown coverage dashboard in the workflow summary, and uploads the XML and text coverage reports as workflow artifacts. HTML coverage remains available through the local `composer coverage` command.

---

### **SSL Management**

```bash
make ssl      # Configures and approves SSL authority (PC password required)
```

---

### **Database Management**

```bash
make dump-db  # Dumps staging DB to ./docker/db/init
make sync-db  # Sync Azure DB locally
```

---

### **Cleanup**

```bash
make clean    # Stops containers and removes unused containers, images, and volumes
```

---

### **Shell Access**

```bash
make sh       # Opens a shell in the PHP container
make bash     # Opens bash in the PHP container
```

---

## Documentation

* API: Swagger, ReDoc
* Full project documentation: [Documentation](#)

---

## License

This project is licensed under **JDC**
