{
  "generatedAt": "2026-01-18T10:00:00Z",
  "techStack": {
    "backend": "CodeIgniter 4 (PHP 8.1+)",
    "frontend": "Alpine.js + TailwindCSS + daisyUI",
    "database": "MySQL/MariaDB"
  },
  "summary": {
    "controllers": 7,
    "models": 7,
    "migrations": 1,
    "apiEndpoints": 45,
    "views": 18,
    "tables": 6
  },
  "agentsMdSummary": {
    "codingConventions": [
      "Controllers extend BaseController + ResponseTrait",
      "Models extend App\\Models\\BaseModel (auto snake/camel conversion)",
      "All tables use soft deletes (deleted_at)",
      "API response format: { status, message, data }",
      "Frontend uses camelCase, DB uses snake_case"
    ],
    "namingPatterns": {
      "controllers": "PascalCase + Controller",
      "models": "PascalCase + Model",
      "tables": "snake_case, prefix master_ for master data",
      "primaryKeys": "{table_singular}_id"
    },
    "directoryStructure": {
      "app/Controllers/": "API & page controllers",
      "app/Controllers/Master/": "Master data CRUD",
      "app/Controllers/Qc/": "QC operations",
      "app/Models/": "Eloquent-style models",
      "app/Models/Master/": "Master data models",
      "app/Models/Qc/": "QC operation models",
      "app/Database/Migrations/": "Schema definitions",
      "app/Config/Routes.php": "All routes",
      "app/Helpers/": "Utility functions",
      "app/Views/": "PHP views with Alpine.js"
    },
    "apiResponseFormat": {
      "success": "{ status: 'success', message: 'fetch success', data: rows }",
      "created": "{ status: 'success', message: id }",
      "error": "failServerError or failValidationErrors"
    }
  },
  "tables": [
    {
      "name": "master_depts",
      "pk": "dept_id",
      "columns": ["dept_id", "name", "created_at", "updated_at", "deleted_at"],
      "softDeletes": true,
      "description": "Departments/laboratory sections"
    },
    {
      "name": "master_controls",
      "pk": "control_id",
      "columns": ["control_id", "dept_id", "name", "lot", "producer", "exp_date", "created_at", "updated_at", "deleted_at"],
      "softDeletes": true,
      "description": "QC control materials"
    },
    {
      "name": "master_tests",
      "pk": "test_id",
      "columns": ["test_id", "dept_id", "name", "unit", "method", "cva", "ba", "tea", "created_at", "updated_at", "deleted_at"],
      "softDeletes": true,
      "description": "Available tests/methods"
    },
    {
      "name": "control_tests",
      "pk": "control_test_id",
      "columns": ["control_test_id", "control_id", "test_id", "mean", "sd", "created_at", "updated_at", "deleted_at"],
      "softDeletes": true,
      "description": "Junction: controls linked to tests with mean/sd"
    },
    {
      "name": "results",
      "pk": "result_id",
      "columns": ["result_id", "control_id", "test_id", "res_date", "res_value", "res_comment", "created_at", "updated_at", "deleted_at"],
      "softDeletes": true,
      "description": "Individual QC test results"
    },
    {
      "name": "result_comments",
      "pk": "result_comment_id",
      "columns": ["result_comment_id", "control_id", "test_id", "comment_month", "com_text", "created_at", "updated_at", "deleted_at"],
      "softDeletes": true,
      "description": "Monthly comments per control/test"
    }
  ],
  "controllers": [
    {
      "name": "BaseController",
      "namespace": "App\\Controllers",
      "file": "app/Controllers/BaseController.php",
      "methods": ["initController"],
      "abstract": true
    },
    {
      "name": "PageController",
      "namespace": "App\\Controllers",
      "file": "app/Controllers/PageController.php",
      "methods": ["dashboard", "masterDept", "masterTest", "masterControl", "entry", "entryDaily", "report", "reportView"]
    },
    {
      "name": "MasterDeptsController",
      "namespace": "App\\Controllers\\Master",
      "file": "app/Controllers/Master/MasterDeptsController.php",
      "methods": ["index", "show", "create", "update", "delete"]
    },
    {
      "name": "MasterTestsController",
      "namespace": "App\\Controllers\\Master",
      "file": "app/Controllers/Master/MasterTestsController.php",
      "methods": ["index", "show", "create", "update", "delete"]
    },
    {
      "name": "MasterControlsController",
      "namespace": "App\\Controllers\\Master",
      "file": "app/Controllers/Master/MasterControlsController.php",
      "methods": ["index", "show", "create", "update", "delete"]
    },
    {
      "name": "ResultsController",
      "namespace": "App\\Controllers\\Qc",
      "file": "app/Controllers/Qc/ResultsController.php",
      "methods": ["index", "show", "create", "update", "delete"]
    },
    {
      "name": "ControlTestsController",
      "namespace": "App\\Controllers\\Qc",
      "file": "app/Controllers/Qc/ControlTestsController.php",
      "methods": ["index", "show", "create", "update", "delete"]
    },
    {
      "name": "TestCommentsController",
      "namespace": "App\\Controllers\\Qc",
      "file": "app/Controllers/Qc/TestCommentsController.php",
      "methods": ["index", "show", "create", "update", "delete"]
    }
  ],
  "models": [
    {
      "name": "BaseModel",
      "namespace": "App\\Models",
      "file": "app/Models/BaseModel.php",
      "table": null,
      "pk": null,
      "abstract": true,
      "features": ["auto snake/camel conversion", "soft deletes", "timestamps"]
    },
    {
      "name": "MasterDeptsModel",
      "namespace": "App\\Models\\Master",
      "file": "app/Models/Master/MasterDeptsModel.php",
      "table": "master_depts",
      "pk": "dept_id"
    },
    {
      "name": "MasterTestsModel",
      "namespace": "App\\Models\\Master",
      "file": "app/Models/Master/MasterTestsModel.php",
      "table": "master_tests",
      "pk": "test_id"
    },
    {
      "name": "MasterControlsModel",
      "namespace": "App\\Models\\Master",
      "file": "app/Models/Master/MasterControlsModel.php",
      "table": "master_controls",
      "pk": "control_id"
    },
    {
      "name": "ResultsModel",
      "namespace": "App\\Models\\Qc",
      "file": "app/Models/Qc/ResultsModel.php",
      "table": "results",
      "pk": "result_id"
    },
    {
      "name": "ControlTestsModel",
      "namespace": "App\\Models\\Qc",
      "file": "app/Models/Qc/ControlTestsModel.php",
      "table": "control_tests",
      "pk": "control_test_id"
    },
    {
      "name": "TestCommentsModel",
      "namespace": "App\\Models\\Qc",
      "file": "app/Models/Qc/TestCommentsModel.php",
      "table": "test_comments",
      "pk": "test_comment_id"
    }
  ],
  "apiEndpoints": [
    { "method": "GET", "path": "/api/master/depts", "controller": "Master\\MasterDeptsController::index" },
    { "method": "GET", "path": "/api/master/depts/(:num)", "controller": "Master\\MasterDeptsController::show/$1" },
    { "method": "POST", "path": "/api/master/depts", "controller": "Master\\MasterDeptsController::create" },
    { "method": "PATCH", "path": "/api/master/depts/(:num)", "controller": "Master\\MasterDeptsController::update/$1" },
    { "method": "DELETE", "path": "/api/master/depts/(:num)", "controller": "Master\\MasterDeptsController::delete/$1" },
    { "method": "GET", "path": "/api/master/tests", "controller": "Master\\MasterTestsController::index" },
    { "method": "GET", "path": "/api/master/tests/(:num)", "controller": "Master\\MasterTestsController::show/$1" },
    { "method": "POST", "path": "/api/master/tests", "controller": "Master\\MasterTestsController::create" },
    { "method": "PATCH", "path": "/api/master/tests/(:num)", "controller": "Master\\MasterTestsController::update/$1" },
    { "method": "DELETE", "path": "/api/master/tests/(:num)", "controller": "Master\\MasterTestsController::delete/$1" },
    { "method": "GET", "path": "/api/master/controls", "controller": "Master\\MasterControlsController::index" },
    { "method": "GET", "path": "/api/master/controls/(:num)", "controller": "Master\\MasterControlsController::show/$1" },
    { "method": "POST", "path": "/api/master/controls", "controller": "Master\\MasterControlsController::create" },
    { "method": "PATCH", "path": "/api/master/controls/(:num)", "controller": "Master\\MasterControlsController::update/$1" },
    { "method": "DELETE", "path": "/api/master/controls/(:num)", "controller": "Master\\MasterControlsController::delete/$1" },
    { "method": "GET", "path": "/api/qc/control-tests", "controller": "Qc\\ControlTestsController::index" },
    { "method": "GET", "path": "/api/qc/control-tests/(:num)", "controller": "Qc\\ControlTestsController::show/$1" },
    { "method": "POST", "path": "/api/qc/control-tests", "controller": "Qc\\ControlTestsController::create" },
    { "method": "PATCH", "path": "/api/qc/control-tests/(:num)", "controller": "Qc\\ControlTestsController::update/$1" },
    { "method": "DELETE", "path": "/api/qc/control-tests/(:num)", "controller": "Qc\\ControlTestsController::delete/$1" },
    { "method": "GET", "path": "/api/qc/results", "controller": "Qc\\ResultsController::index" },
    { "method": "GET", "path": "/api/qc/results/(:num)", "controller": "Qc\\ResultsController::show/$1" },
    { "method": "POST", "path": "/api/qc/results", "controller": "Qc\\ResultsController::create" },
    { "method": "PATCH", "path": "/api/qc/results/(:num)", "controller": "Qc\\ResultsController::update/$1" },
    { "method": "DELETE", "path": "/api/qc/results/(:num)", "controller": "Qc\\ResultsController::delete/$1" },
    { "method": "GET", "path": "/api/qc/test-comments", "controller": "Qc\\TestCommentsController::index" },
    { "method": "GET", "path": "/api/qc/test-comments/(:num)", "controller": "Qc\\TestCommentsController::show/$1" },
    { "method": "POST", "path": "/api/qc/test-comments", "controller": "Qc\\TestCommentsController::create" },
    { "method": "PATCH", "path": "/api/qc/test-comments/(:num)", "controller": "Qc\\TestCommentsController::update/$1" },
    { "method": "DELETE", "path": "/api/qc/test-comments/(:num)", "controller": "Qc\\TestCommentsController::delete/$1" }
  ],
  "routes": [
    { "method": "GET", "path": "/", "controller": "PageController::dashboard" },
    { "method": "GET", "path": "/master/dept", "controller": "PageController::masterDept" },
    { "method": "GET", "path": "/master/test", "controller": "PageController::masterTest" },
    { "method": "GET", "path": "/master/control", "controller": "PageController::masterControl" },
    { "method": "GET", "path": "/entry", "controller": "PageController::entry" },
    { "method": "GET", "path": "/entry/daily", "controller": "PageController::entryDaily" },
    { "method": "GET", "path": "/report", "controller": "PageController::report" },
    { "method": "GET", "path": "/report/view", "controller": "PageController::reportView" }
  ]
}
