# AARJAY GDP Portal — Technical Inventory & Folder Blueprint

**Generated:** 2026-07-18  
**Root:** `/Users/sagar/Downloads/AARJAY_GDP_Portal/mvc`  
**Purpose:** Complete platform / language / folder / module / document map.

> **Important:** The full source code lives in this folder tree (thousands of files). This document is the index. Open files by path — do not expect every line of every module pasted into chat.

---

## 1. Platform & language versions (runtime)

| Layer | Technology | Version / notes |
|-------|------------|-----------------|
| Application pattern | Custom PHP MVC (no Laravel/Symfony) | Controllers / Models / Views |
| Language | PHP | **8.4.23** (local CLI); Docker image `php:8.2-apache` also supported |
| Database | MySQL | **9.5.0** local runtime; Docker `mysql:8.0` |
| DB access | PDO | `app/Core/Database.php` |
| Web server | PHP built-in via `start-portal.sh` / Apache in Docker | Port **8080** |
| CSS framework | Bootstrap | **5.3.3** (CDN) |
| Icons | Bootstrap Icons | **1.11.3** (CDN) |
| Design system | Custom | `assets/css/pharma.css` + `assets/js/pharma.js` |
| Font | Inter | Google Fonts (in pharma.css) |
| OS (dev) | macOS | darwin |
| Timezone | Europe/London | config |
| Installer seed | `install.sql` | Regenerated from live DB (settlement) |
| Migrations | SQL files | `migrations/` (~267 files); floor **282+** |
| Release tag file | `VERSION.txt` | v15.8 (label; settlement supersedes) |

**Local URL:** http://127.0.0.1:8080  
**Logins:** `admin@pharma.com` / `Admin@1234` · `rp@pharma.com` / `Staff@1234`

---

## 2. Folder & subfolder blueprint

```
AARJAY_GDP_Portal/mvc/
├── index.php                 # Front controller entry
├── dev-router.php            # Pretty URL router for PHP built-in server
├── install.sql               # Fresh-install schema + seed
├── install.lock              # Blocks re-install when present
├── start-portal.sh / stop-portal.sh / START_PORTAL.command
├── docker-compose.yml        # Optional MySQL 8 + PHP 8.2 Apache
├── VERSION.txt / MANIFEST.sha256
├── *.md                      # Project documentation (see §4)
│
├── .cursor/rules/            # Cursor AI rules (master-spec, conventions)
│
├── app/
│   ├── config.php            # DB + app URL + feature flags (local)
│   ├── routes.php            # Route → Controller@action map
│   ├── routeMap.php          # Pretty path aliases
│   ├── Core/                 # Framework kernel
│   │   ├── Controller.php
│   │   ├── Model.php
│   │   ├── Database.php
│   │   ├── Router.php
│   │   ├── Session.php
│   │   ├── Config.php
│   │   └── Url.php
│   ├── Controllers/          # ~95 *Controller.php (HTTP)
│   │   └── Concerns/         # Shared controller traits
│   ├── Models/               # ~96 domain models + SoftLifecycle callers
│   ├── Views/                # ~94 module UI folders + layout/partials
│   │   ├── layout/           # header.php, footer.php
│   │   ├── partials/         # void_button, verification, etc.
│   │   ├── errors/
│   │   └── <module>/         # index, form, view, add, edit…
│   ├── Services/             # SoftLifecycle, EsignService, TradeGate…
│   └── Helpers/              # Auth, UploadHelper, functions.php…
│
├── assets/
│   ├── css/pharma.css        # Design system (Dashboard look)
│   ├── js/pharma.js
│   └── img/
│
├── migrations/               # Sequential SQL (012…282+)
├── uploads/                  # Per-module evidence files
│   ├── sops/ company_documents/ site_documents/
│   ├── party_verification/ technical_agreements/ …
│   └── …
├── scripts/                  # Lint, smoke, install audit, backup
│   └── tests/
└── logs/
```

### MVC coding pattern (every module)

```
Request → index.php → Router → Controller::action
                → Model (SQL / SoftLifecycle / TRANSITIONS)
                → View (PHP templates + Bootstrap + pharma.css)
```

| Layer | Responsibility |
|-------|----------------|
| **Controller** | Auth/ACL, validate POST, call model, render view, redirects |
| **Model** | Queries, workflows (`TRANSITIONS`), void, site_id, business rules |
| **View** | HTML UI/UX only — no business SQL |
| **Service** | Cross-cutting: e-sign, SoftLifecycle, trade gate, SMTP |

---

## 3. UI / UX design stack

| Element | Implementation |
|---------|----------------|
| Layout shell | Sidebar + topbar (`Views/layout/header.php`) |
| Navigation | Permission-gated groups (Partners, Orders, QMS, Premises…) |
| Global UX | Back + Home buttons; breadcrumbs |
| Cards / KPIs | `.stat-card`, soft icon tints, gradient `.btn-primary` (Dashboard style) |
| Hub tiles | `.hub-tile` (Reports) matching Dashboard shades |
| Forms | Bootstrap form-control / form-select; site pickers |
| Tables | `.table-card` + sortable tables |
| Status | Badges; SoftLifecycle void UI partial |
| Theme tokens | CSS variables in `pharma.css` (`--primary` navy, `--accent` teal) |
| Dark mode | `[data-theme=dark]` variables present |

---

## 4. Portal-related documents (all in project root)

| Document | What it covers |
|----------|----------------|
| `START_HERE.md` / `RUN_ME.md` / `STAGING_QUICKSTART.md` | How to start locally |
| `MASTER_SPEC.md` | Authoritative GDP functional/technical spec |
| `GAP_ANALYSIS_MASTER_SPEC.md` | Gap vs Master Spec |
| `MODULE_REGISTRY.md` | Module registry |
| `SESSION_HANDOFF.md` | Current session state / floor |
| `CONVENTIONS.md` | Coding conventions |
| `UPLOAD_STANDARD.md` | File upload rules |
| `PERMISSIONS_MATRIX_CHECKLIST.md` | ACL checklist |
| `ROUTE_COVERAGE.md` | Routes |
| `USER_TRAINING_GUIDE.md` | End-user training |
| `CPANEL_DEPLOYMENT.md` / `GO_LIVE_RUNBOOK.md` / `RELEASE_CHECKLIST.md` | Deploy / go-live |
| `SECURITY_HARDENING.md` | Security |
| `DATA_MIGRATION_GUIDE.md` | Data migration |
| `TROUBLESHOOTING.md` / `KNOWN_LIMITATIONS.md` | Ops issues |
| `FINAL_*` / `PROGRESS.md` / `CHANGELOG.md` | Release history |
| `.cursor/rules/master-spec.mdc` | AI session non-negotiables |
| This file `PORTAL_TECHNICAL_INVENTORY.md` | Full technical index |

Interactive blueprint canvas (Cursor): `gdp-portal-blueprint.canvas.tsx`

---

## 5. Shared services & helpers (cross-module)

| Path | Role |
|------|------|
| `app/Services/SoftLifecycle.php` | Void with reason; no hard delete |
| `app/Services/EsignService.php` | Electronic signature gates |
| `app/Services/TradeGateService.php` | Trading eligibility / qualification gate |
| `app/Services/WorkflowTaskEmitter.php` | Emit My Tasks / workflow tasks |
| `app/Services/FeatureFlags.php` | experimental_* flags |
| `app/Helpers/Auth.php` | Login, ACL, siteScopeSql |
| `app/Helpers/UploadHelper.php` | Safe uploads |
| `app/Helpers/LineItemHelper.php` | Soft-void line items pattern |

---

## 6. Module → code map (Controller / Model / Views)

Counts: **95** controllers · **96** models · **94** view folders

| Module (Controller) | Controller file | Model file | Views folder |
|---------------------|-----------------|------------|--------------|
| AccountReopening | `app/Controllers/AccountReopeningController.php` | `app/Models/AccountReopening.php` | `app/Views/account_reopenings` |
| AccountStatement | `app/Controllers/AccountStatementController.php` | `app/Models/AccountStatement.php` | `app/Views/account_statements` |
| AccountingIntegration | `app/Controllers/AccountingIntegrationController.php` | `app/Models/AccountingIntegration.php` | `app/Views/accounting_integrations` |
| AccountsFinance | `app/Controllers/AccountsFinanceController.php` | `app/Models/AccountsFinance.php` | `app/Views/accounts_finance` |
| ActivityLog | `app/Controllers/ActivityLogController.php` | `app/Models/—` | `app/Views/activity_log` |
| AdvancedTool | `app/Controllers/AdvancedToolController.php` | `app/Models/AdvancedTool.php` | `app/Views/advanced_tools` |
| AiAssistant | `app/Controllers/AiAssistantController.php` | `app/Models/AiAssistant.php` | `app/Views/ai_assistant` |
| AssetPurchase | `app/Controllers/AssetPurchaseController.php` | `app/Models/AssetPurchase.php` | `app/Views/asset_purchases` |
| Audit | `app/Controllers/AuditController.php` | `app/Models/Audit.php` | `app/Views/audits` |
| Auth | `app/Controllers/AuthController.php` | `app/Models/—` | `app/Views/auth` |
| Capa | `app/Controllers/CapaController.php` | `app/Models/Capa.php` | `app/Views/capas` |
| ChangeControl | `app/Controllers/ChangeControlController.php` | `app/Models/ChangeControl.php` | `app/Views/change_controls` |
| ColdChainImport | `app/Controllers/ColdChainImportController.php` | `app/Models/ColdChainImport.php` | `app/Views/cold_chain_imports` |
| CompanySite | `app/Controllers/CompanySiteController.php` | `app/Models/CompanySite.php` | `app/Views/company_sites` |
| Complaint | `app/Controllers/ComplaintController.php` | `app/Models/Complaint.php` | `app/Views/complaints` |
| ContactDirectory | `app/Controllers/ContactDirectoryController.php` | `app/Models/ContactDirectory.php` | `app/Views/contact_directory` |
| Contract | `app/Controllers/ContractController.php` | `app/Models/Contract.php` | `app/Views/contracts` |
| ContractorInvoice | `app/Controllers/ContractorInvoiceController.php` | `app/Models/ContractorInvoice.php` | `app/Views/contractor_invoices` |
| Customer | `app/Controllers/CustomerController.php` | `app/Models/Customer.php` | `app/Views/customers` |
| CustomerInvoice | `app/Controllers/CustomerInvoiceController.php` | `app/Models/CustomerInvoice.php` | `app/Views/customer_invoices` |
| DashboardAnalytics | `app/Controllers/DashboardAnalyticsController.php` | `app/Models/DashboardAnalytics.php` | `app/Views/dashboard_analytics` |
| Dashboard | `app/Controllers/DashboardController.php` | `app/Models/—` | `app/Views/dashboard` |
| DataImport | `app/Controllers/DataImportController.php` | `app/Models/DataImport.php` | `app/Views/data_imports` |
| DefectiveStock | `app/Controllers/DefectiveStockController.php` | `app/Models/DefectiveStock.php` | `app/Views/defective_stock` |
| Delivery | `app/Controllers/DeliveryController.php` | `app/Models/Delivery.php` | `app/Views/deliveries` |
| Deviation | `app/Controllers/DeviationController.php` | `app/Models/Deviation.php` | `app/Views/deviations` |
| Dispatch | `app/Controllers/DispatchController.php` | `app/Models/Dispatch.php` | `app/Views/dispatches` |
| DocumentControl | `app/Controllers/DocumentControlController.php` | `app/Models/DocumentControl.php` | `app/Views/document_controls` |
| ElectronicSignature | `app/Controllers/ElectronicSignatureController.php` | `app/Models/ElectronicSignature.php` | `app/Views/electronic_signatures` |
| EmailReminder | `app/Controllers/EmailReminderController.php` | `app/Models/EmailReminder.php` | `app/Views/email_reminders` |
| EmailTemplate | `app/Controllers/EmailTemplateController.php` | `app/Models/EmailTemplate.php` | `app/Views/email_templates` |
| EvidenceAttachment | `app/Controllers/EvidenceAttachmentController.php` | `app/Models/EvidenceAttachment.php` | `app/Views/evidence_attachments` |
| ExportHistory | `app/Controllers/ExportHistoryController.php` | `app/Models/ExportHistory.php` | `app/Views/export_history` |
| ExternalCertificate | `app/Controllers/ExternalCertificateController.php` | `app/Models/ExternalCertificate.php` | `app/Views/external_certificates` |
| FalsifiedMedicine | `app/Controllers/FalsifiedMedicineController.php` | `app/Models/FalsifiedMedicine.php` | `app/Views/falsified_medicines` |
| File | `app/Controllers/FileController.php` | `app/Models/—` | `app/Views/—` |
| FormTemplate | `app/Controllers/FormTemplateController.php` | `app/Models/FormTemplate.php` | `app/Views/forms_templates` |
| GdpGapAnalysis | `app/Controllers/GdpGapAnalysisController.php` | `app/Models/GdpGapAnalysis.php` | `app/Views/gdp_gap_analysis` |
| GoodsReceiving | `app/Controllers/GoodsReceivingController.php` | `app/Models/GoodsReceiving.php` | `app/Views/goods_receivings` |
| InspectionPack | `app/Controllers/InspectionPackController.php` | `app/Models/InspectionPack.php` | `app/Views/inspection_packs` |
| InspectorPortal | `app/Controllers/InspectorPortalController.php` | `app/Models/InspectorPortal.php` | `app/Views/inspector_portal` |
| Install | `app/Controllers/InstallController.php` | `app/Models/—` | `app/Views/—` |
| Invoice | `app/Controllers/InvoiceController.php` | `app/Models/Invoice.php` | `app/Views/invoices` |
| ItPortalAdmin | `app/Controllers/ItPortalAdminController.php` | `app/Models/ItPortalAdmin.php` | `app/Views/it_portal_admin` |
| Lookup | `app/Controllers/LookupController.php` | `app/Models/—` | `app/Views/—` |
| MhraInspection | `app/Controllers/MhraInspectionController.php` | `app/Models/MhraInspection.php` | `app/Views/mhra_inspections` |
| MyTask | `app/Controllers/MyTaskController.php` | `app/Models/MyTask.php` | `app/Views/my_tasks` |
| NonSaleableStock | `app/Controllers/NonSaleableStockController.php` | `app/Models/NonSaleableStock.php` | `app/Views/non_saleable_stock` |
| Notification | `app/Controllers/NotificationController.php` | `app/Models/Notification.php` | `app/Views/notifications` |
| OutboundCommunication | `app/Controllers/OutboundCommunicationController.php` | `app/Models/OutboundCommunication.php` | `app/Views/communications` |
| PartyContact | `app/Controllers/PartyContactController.php` | `app/Models/PartyContact.php` | `app/Views/—` |
| Permission | `app/Controllers/PermissionController.php` | `app/Models/Permission.php` | `app/Views/permissions` |
| PremisesEquipment | `app/Controllers/PremisesEquipmentController.php` | `app/Models/PremisesEquipment.php` | `app/Views/premises_equipment` |
| Product | `app/Controllers/ProductController.php` | `app/Models/Product.php` | `app/Views/products` |
| ProductionRelease | `app/Controllers/ProductionReleaseController.php` | `app/Models/ProductionRelease.php` | `app/Views/production_releases` |
| Profile | `app/Controllers/ProfileController.php` | `app/Models/—` | `app/Views/profile` |
| PurchaseOrder | `app/Controllers/PurchaseOrderController.php` | `app/Models/PurchaseOrder.php` | `app/Views/purchase_orders` |
| PurchaseRequest | `app/Controllers/PurchaseRequestController.php` | `app/Models/PurchaseRequest.php` | `app/Views/purchase_requests` |
| QrTrace | `app/Controllers/QrTraceController.php` | `app/Models/QrTrace.php` | `app/Views/qr_trace` |
| Qualification | `app/Controllers/QualificationController.php` | `app/Models/Qualification.php` | `app/Views/qualifications` |
| Recall | `app/Controllers/RecallController.php` | `app/Models/Recall.php` | `app/Views/recalls` |
| RecallFinder | `app/Controllers/RecallFinderController.php` | `app/Models/RecallFinder.php` | `app/Views/recall_finder` |
| Report | `app/Controllers/ReportController.php` | `app/Models/Report.php` | `app/Views/reports` |
| Return | `app/Controllers/ReturnController.php` | `app/Models/—` | `app/Views/returns` |
| RiskAssessment | `app/Controllers/RiskAssessmentController.php` | `app/Models/RiskAssessment.php` | `app/Views/risk_assessments` |
| RpPortal | `app/Controllers/RpPortalController.php` | `app/Models/RpPortal.php` | `app/Views/rp_portal` |
| SalesOrder | `app/Controllers/SalesOrderController.php` | `app/Models/SalesOrder.php` | `app/Views/sales_orders` |
| ScheduledJob | `app/Controllers/ScheduledJobController.php` | `app/Models/ScheduledJob.php` | `app/Views/scheduled_jobs` |
| Search | `app/Controllers/SearchController.php` | `app/Models/Search.php` | `app/Views/search` |
| SecureCredential | `app/Controllers/SecureCredentialController.php` | `app/Models/SecureCredential.php` | `app/Views/secure_credentials` |
| SiteCompliance | `app/Controllers/SiteComplianceController.php` | `app/Models/SiteCompliance.php` | `app/Views/site_compliance` |
| SiteContractor | `app/Controllers/SiteContractorController.php` | `app/Models/—` | `app/Views/site_contractors` |
| SiteSetting | `app/Controllers/SiteSettingController.php` | `app/Models/SiteSetting.php` | `app/Views/site_settings` |
| Sop | `app/Controllers/SopController.php` | `app/Models/Sop.php` | `app/Views/sops` |
| StockBatch | `app/Controllers/StockBatchController.php` | `app/Models/StockBatch.php` | `app/Views/—` |
| StockTransfer | `app/Controllers/StockTransferController.php` | `app/Models/StockTransfer.php` | `app/Views/stock_transfers` |
| StorageProfile | `app/Controllers/StorageProfileController.php` | `app/Models/StorageProfile.php` | `app/Views/storage_profiles` |
| SupplierAudit | `app/Controllers/SupplierAuditController.php` | `app/Models/SupplierAudit.php` | `app/Views/supplier_audits` |
| SupplierCategory | `app/Controllers/SupplierCategoryController.php` | `app/Models/SupplierCategory.php` | `app/Views/—` |
| Supplier | `app/Controllers/SupplierController.php` | `app/Models/Supplier.php` | `app/Views/suppliers` |
| SupplierInvoice | `app/Controllers/SupplierInvoiceController.php` | `app/Models/SupplierInvoice.php` | `app/Views/supplier_invoices` |
| SupplierLicence | `app/Controllers/SupplierLicenceController.php` | `app/Models/SupplierLicence.php` | `app/Views/supplier_licences` |
| SystemHealth | `app/Controllers/SystemHealthController.php` | `app/Models/SystemHealth.php` | `app/Views/system_health` |
| TaxCategory | `app/Controllers/TaxCategoryController.php` | `app/Models/TaxCategory.php` | `app/Views/—` |
| TechnicalAgreement | `app/Controllers/TechnicalAgreementController.php` | `app/Models/TechnicalAgreement.php` | `app/Views/technical_agreements` |
| TemperatureExcursion | `app/Controllers/TemperatureExcursionController.php` | `app/Models/TemperatureExcursion.php` | `app/Views/temperature_excursions` |
| TemperatureLog | `app/Controllers/TemperatureLogController.php` | `app/Models/TemperatureLog.php` | `app/Views/temperature_logs` |
| TemperatureMapping | `app/Controllers/TemperatureMappingController.php` | `app/Models/TemperatureMapping.php` | `app/Views/temperature_mappings` |
| TemperatureReview | `app/Controllers/TemperatureReviewController.php` | `app/Models/TemperatureReview.php` | `app/Views/temperature_reviews` |
| Training | `app/Controllers/TrainingController.php` | `app/Models/Training.php` | `app/Views/training` |
| TransportProvider | `app/Controllers/TransportProviderController.php` | `app/Models/TransportProvider.php` | `app/Views/transport_providers` |
| User | `app/Controllers/UserController.php` | `app/Models/User.php` | `app/Views/users` |
| ValidationPack | `app/Controllers/ValidationPackController.php` | `app/Models/ValidationPack.php` | `app/Views/validation_packs` |
| WdaLicence | `app/Controllers/WdaLicenceController.php` | `app/Models/WdaLicence.php` | `app/Views/wda_licences` |
| WorkflowTask | `app/Controllers/WorkflowTaskController.php` | `app/Models/WorkflowTask.php` | `app/Views/workflow_tasks` |

---

## 7. How to open / study any module’s full code

1. Find the module in §6.
2. Open the three paths (Controller + Model + Views).
3. Check `app/routes.php` + `app/routeMap.php` for URLs.
4. Check `migrations/` for schema history of that feature.
5. Uploads for that module live under `uploads/<area>/`.

**Package the whole codebase:** zip the `mvc/` folder, or run `scripts/package_release.sh` if present.

---

## 8. Database

| Item | Value |
|------|-------|
| Name | `aarjay_gdp` |
| Migrations ledger | `schema_migrations_applied` |
| Fresh install | Import `install.sql` |
| Runtime socket (local) | `/Users/sagar/gdp-portal-runtime/mysql.sock` |
