# Technology Stack

## Runtime

| Layer | Technology | Version | Notes |
|-------|-----------|---------|-------|
| PHP | PHP | ^8.4 | `declare(strict_types=1)` in all files |
| Web server | Apache | XAMPP (local) | `public/.htaccess` handles routing |
| Database | MySQL | InnoDB | utf8mb4_unicode_ci |
| Node.js | npm | dev only | Sass build tool only, no runtime JS bundler |

## PHP Dependencies (`composer.json`)

| Package | Version | Purpose |
|---------|---------|---------|
| `dompdf/dompdf` | ^3.1 | PDF generation (receipts, labels) |
| `phpoffice/phpspreadsheet` | ^5.5 | Excel/XLSX export (accounting) |
| `phpmailer/phpmailer` | ^7.0 | SMTP email sending |
| `phpunit/phpunit` | ^11.5 (dev) | Unit testing |
| `dg/bypass-finals` | ^1.9 (dev) | Mock final classes in tests |

## Framework

**Custom lightweight framework** — no Laravel/Symfony.

| Component | File |
|-----------|------|
| Application bootstrap | `src/Core/Application.php` |
| Router | `src/Core/Routing/Router.php` |
| Request / Response | `src/Core/Http/Request.php`, `Response.php` |
| Template engine | `src/Core/View/Template.php` (PHP-native, `$e()` + `$t()` helpers) |
| Session | `src/Core/Support/Session.php` |
| Logger | `src/Core/Support/Logger.php` → `storage/logs/app.log` |
| CSRF | `src/Core/Security/Csrf.php` |
| i18n | `src/Core/I18n/Translator.php` (Polish primary: `resources/lang/pl/`) |
| DB connection | `src/Core/Database/ConnectionFactory.php` (PDO, no ORM, no medoo) |
| Migrator | `src/Core/Database/Migrator.php` (custom SQL runner, `migrations` table) |
| SSL resolver | `src/Core/Http/SslCertificateResolver.php` (env: `CURL_CA_BUNDLE_PATH`) |

## Frontend

- **No CSS framework** — custom SCSS design tokens
- **jQuery** — used only for `jquery-alerts` module (`resources/modules/jquery-alerts/`)
- **No JS bundler** — files served directly from `public/assets/js/`
- **Build**: `npm run build:assets` (Sass → compressed CSS + JS copy)

## Build Scripts

```json
"build:css"    → sass --style=compressed resources/scss/app.scss → public/assets/css/app.css
"build:modules"→ sass jquery-alerts.scss + copy jquery-alerts.js
"build:assets" → build:css && build:modules
"watch:css"    → sass --watch (development)
```

```json
"serve"   → php -S localhost:8000 -t public public/index.php
"migrate" → php bin/migrate.php
"cron"    → php bin/cron.php
"test"    → vendor/bin/phpunit -c phpunit.xml --testdox
```

## Environment Variables (`.env.example`)

| Variable | Purpose |
|----------|---------|
| `DB_HOST`, `DB_PORT`, `DB_DATABASE` | MySQL connection |
| `DB_HOST_REMOTE` | Agent-only manual DB ops (NOT used by app runtime) |
| `CURL_CA_BUNDLE_PATH` | SSL cert path (XAMPP: `C:/xampp/php/extras/ssl/cacert.pem`) |
| `ALLEGRO_USER_AGENT_URL` | Required by Allegro REST API from 01.07.2026 |
| `CRON_RUN_ON_WEB`, `CRON_WEB_LIMIT`, `CRON_PUBLIC_TOKEN` | Cron configuration |
