version: 0.5.1
source_of_truth:
  router: app/Lib/App.php
  controller_dir: app/Controllers
  notes:
    - "Opis dotyczy poziomu HTTP i odpowiedzialności metod."
    - "Pole route_registered oznacza, czy metoda ma aktywną trasę w routerze."
    - "Pole access oznacza aktualny poziom dostępu według App.routeAccess."

controllers:
  - class: App\Controllers\AuthController
    file: app/Controllers/AuthController.php
    purpose: "Logowanie i wylogowanie użytkownika modułu."
    routes:
      - method: GET
        path: /login
        action: login
        access: public
      - method: POST
        path: /login
        action: login
        access: public
      - method: GET
        path: /logout
        action: logout
        access: public

  - class: App\Controllers\OrdersController
    file: app/Controllers/OrdersController.php
    purpose: "Przegląd zamówień, eksporty CSV i karta zamówienia."
    routes:
      - method: GET
        path: /
        action: index
        access: admin|manager|chief|wareman
      - method: GET
        path: /orders
        action: index
        access: admin|manager|chief|wareman
      - method: GET
        path: /orders/{id}
        action: view
        access: admin|manager|chief|wareman
      - method: GET
        path: /orders/export
        action: exportOrdersCsv
        access: admin|manager|chief|wareman
      - method: GET
        path: /orders/items/export
        action: exportItemsCsv
        access: admin|manager|chief|wareman

  - class: App\Controllers\StatsController
    file: app/Controllers/StatsController.php
    purpose: "Agregacje sprzedaży i widoki statystyczne."
    routes:
      - method: GET
        path: /stats
        action: index
        access: admin|manager|chief|wareman

  - class: App\Controllers\DemandController
    file: app/Controllers/DemandController.php
    purpose: "Widoki rozchodów, forecastów i propozycji zapotrzebowania."
    routes:
      - method: GET
        path: /demand
        action: index
        access: admin|manager|chief|wareman
      - method: GET
        path: /demand/breakdown
        action: breakdown
        access: admin|manager|chief|wareman
      - method: GET
        path: /demand/export
        action: export
        access: admin|manager|chief|wareman

  - class: App\Controllers\ReportsController
    file: app/Controllers/ReportsController.php
    purpose: "Raporty okresowe i podglądy zakresów."
    routes:
      - method: GET
        path: /reports
        action: index
        access: admin|manager|chief|wareman
      - method: GET
        path: /reports/view
        action: view
        access: admin|manager|chief|wareman
  - class: App\Controllers\ReportsCostController
    file: app/Controllers/ReportsCostController.php
    purpose: "Raport kosztow, edycja rekordow zrodlowych i korekty bulk z przeliczeniem sladu zaleznosci."
    routes:
      - method: GET
        path: /reports-cost
        action: index
        access: admin|manager|chief|lead
      - method: GET|POST
        path: /reports-cost/product/{id}
        action: editProduct
        access: admin
      - method: GET|POST
        path: /reports-cost/buy-ref/{id}
        action: editBuyRef
        access: admin
      - method: POST
        path: /reports-cost/bulk
        action: bulk
        access: admin

  - class: App\Controllers\AdminController
    file: app/Controllers/AdminController.php
    purpose: "Punkt wejścia do panelu administracyjnego modułu."
    routes:
      - method: GET
        path: /admin
        action: index
        access: admin|manager
      - method: GET|POST
        path: /admin/sales-assignments
        action: salesAssignments
        access: admin|manager

  - class: App\Controllers\ImportController
    file: app/Controllers/ImportController.php
    purpose: "Importy danych kosztowych, walutowych i mapowań oraz pobieranie błędów importu."
    routes:
      - method: GET|POST
        path: /import/costs
        action: costs
        access: admin|manager
      - method: GET|POST
        path: /import/fx
        action: fx
        access: admin|manager
      - method: GET|POST
        path: /import/sellers
        action: sellers
        access: admin|manager
      - method: GET|POST
        path: /import/invoices
        action: invoices
        access: admin|manager
      - method: GET|POST
        path: /import/offers-mapping
        action: offersMapping
        access: admin|manager
      - method: GET|POST
        path: /import/towar-params
        action: towarParams
        access: admin|manager
      - method: GET|POST
        path: /import/recalc-fx
        action: recalcFx
        access: admin|manager
      - method: GET
        path: /import/errors
        action: downloadErrors
        access: admin|manager

  - class: App\Controllers\CostToolsController
    file: app/Controllers/CostToolsController.php
    purpose: "Narzędzia przebudowy kosztów, rejestrów i dokumentów pomocniczych."
    routes:
      - method: GET
        path: /admin/cost
        action: index
        access: admin|manager
      - method: GET
        path: /admin/cost/rebuild-registry
        action: rebuildRegistry
        access: admin|manager
      - method: GET
        path: /admin/cost/fill-pz-month
        action: fillPzMonthly
        access: admin|manager
      - method: GET
        path: /admin/cost/calc-bom
        action: calcBomMonthly
        access: admin|manager
      - method: GET
        path: /admin/cost/rebuild-calc
        action: rebuildCalcOnly
        access: admin|manager
      - method: GET
        path: /admin/cost/export-missing
        action: exportMissingCsv
        access: admin|manager
      - method: GET
        path: /admin/cost/generate-wz
        action: generateWzFromStats
        access: admin|manager
      - method: GET
        path: /admin/cost/rebuild-daily-issues
        action: rebuildDailyIssueRegisters
        access: admin|manager
      - method: GET
        path: /admin/cost/rebuild-period-issues
        action: rebuildPeriodIssueRegisters
        access: admin|manager

  - class: App\Controllers\DataChecksController
    file: app/Controllers/DataChecksController.php
    purpose: "Kontrole jakości danych i eksporty wyników checków."
    routes:
      - method: GET
        path: /admin/checks
        action: index
        access: admin|manager
      - method: GET
        path: /admin/checks/export
        action: export
        access: admin|manager

  - class: App\Controllers\SchemaAuditController
    file: app/Controllers/SchemaAuditController.php
    purpose: "Audyt użycia tabel i kolumn w projekcie."
    routes:
      - method: GET
        path: /admin/schema-audit
        action: index
        access: admin|manager
      - method: GET|POST
        path: /admin/schema-audit/start
        action: start
        access: admin|manager
      - method: GET|POST
        path: /admin/schema-audit/process
        action: process
        access: admin|manager
      - method: GET
        path: /admin/schema-audit/export
        action: export
        access: admin|manager

  - class: App\Controllers\HealthController
    file: app/Controllers/HealthController.php
    purpose: "Endpoint kontrolny aplikacji i bazy."
    routes:
      - method: GET
        path: /health
        action: index
        access: public

notes:
  structure:
    - "Kontrolery pracują już w modelu zgodnym ze szkieletem package: router -> kontroler instancyjny -> repository/service -> widok."
    - "Warstwa app/Core i app/Models pozostała tylko jako historyczna kompatybilność; bieżący runtime używa app/Lib, app/Repositories i app/Services."
