# AGENTS.md — QFreeMart Admin Portal

Guide for AI agents working in this repository. Prefer indexed paths under `app/Http/Controllers/Admin/V2/`, `app/Repositories/`, `routes/web_v2.php`, and `resources/views/admin-v2/`.

## Project summary

Laravel 9 **admin portal** (QFreeMart): session-auth Blade panel (DataTables) for facilities, orders, mall catalog, billing, settings. Shared marketplace database, file storage (AWS S3), optional OpenSearch. PHP ^8.0.2.

Root URL should open the admin login page (`/` and `/login`).

## Active routes

`RouteServiceProvider` loads only:

| File | Prefix / middleware | Purpose |
|------|---------------------|---------|
| `routes/web_v2.php` | `web` at site root | Admin panel (login, dashboard, CRUD) |

No API, legacy admin, facility portal, or Swagger routes are registered.

### URL layout

| Path | Name | Purpose |
|------|------|---------|
| `/` and `/login` | `admin.v2.login` | Login |
| `POST /login` | `v2.login` | Authenticate |
| `POST /logout` | `logout` | Logout |
| `/dashboard` | `v2.dashboard` | Dashboard |

Legacy `/v2/...` URLs permanently redirect to the same path at root.

List routes: `php artisan route:list`

## Where to change what

| Task | Start here |
|------|------------|
| Admin pages / endpoints | `routes/web_v2.php` → `app/Http/Controllers/Admin/V2/` |
| DB access | `app/Repositories/` + bindings in `app/Providers/RepositoryServiceProvider.php` |
| Eloquent models | `app/Models/` |
| Blade UI | `resources/views/admin-v2/` |
| Auth | session `web` guard; admin role `1`; `user.auth` middleware |
| Permissions | Spatie — `config/permission.php` |
| Migrations | `database/migrations/` |
| Shared helpers | `app/Helpers/` (autoloaded via `helpers.php`) |
| Env / AWS / OpenSearch | `.env` (see `.env.example`), `config/filesystems.php`, `config/opensearch.php` |

## Architecture conventions

1. **Layering:** Controller → Service / Repository → Model. Register new repository bindings in `RepositoryServiceProvider`.
2. **Admin UI:** Blade + Yajra DataTables under `admin-v2/`.
3. **Keep repositories** even when unused by the current screen — they are the data-access layer for this codebase.

## Commands

```bash
composer install
php artisan migrate
php artisan test
php artisan route:list
php artisan optimize:clear
```

## Pitfalls

- Do not reintroduce mobile API (`routes/api.php`) or the legacy admin (`routes/web.php`) unless explicitly requested.
- Pretty URLs need `public/.htaccess` (Apache `mod_rewrite` + `AllowOverride All`) or nginx `try_files`.
- Do not commit `.env` or credentials.
- Large static trees under `public/assets/` are excluded from Cursor indexing via `.cursorindexingignore`.

## Indexing

Cursor semantic index ignores vendor, assets, uploads, and logs per `.cursorindexingignore`. After large structural changes, resync codebase index in Cursor settings if `@codebase` search misses new files.
