# codeforpakistan/pharma-license architecture

> Architecture diagram of the GitHub repository codeforpakistan/pharma-license, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codeforpakistan/pharma-license
- Repository: https://github.com/codeforpakistan/pharma-license

## Overview

This repository combines the CodeIgniter PHP framework with a pharmacy and drug-control application built on it. The main workflow is a browser request routed to an application controller, which handles authentication and domain operations through models, persists data, and renders a view. The tree documents license forms, inspections, reference data, reporting, and REST endpoints. The sampled excerpts confirm framework routing and database-query behavior, but do not show most application controller/model call sites, so those links are kept at supported architectural boundaries.

Main entry points: [`application/core/MY_Controller.php`](https://github.com/codeforpakistan/pharma-license/blob/master/application/core/MY_Controller.php) (Application controller), [`system/core/Router.php`](https://github.com/codeforpakistan/pharma-license/blob/master/system/core/Router.php) (Request router), [`application/libraries/REST_Controller.php`](https://github.com/codeforpakistan/pharma-license/blob/master/application/libraries/REST_Controller.php) (REST controller), [`index.php`](https://github.com/codeforpakistan/pharma-license/blob/master/index.php) (Front controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Framework runtime"]
  node_front["Front controller<br/>[index.php]"]
  node_bootstrap["Framework bootstrap<br/>[CodeIgniter.php]"]
  node_router["Request router<br/>[Router.php]"]
  node_routes["Application routes<br/>[routes.php]"]
end

subgraph group_domain["Application workflows"]
  node_controller["Application controller<br/>[MY_Controller.php]"]
  node_auth["Authentication<br/>[Auth.php]"]
  node_forms["License forms<br/>[Form_8a.php]"]
  node_inspection["Inspections<br/>[Inspection.php]"]
  node_reference["Registry data<br/>[Institute.php]"]
  node_reports["Reports<br/>[Common.php]"]
  node_views["Application views"]
end

subgraph group_services["Persistence and output"]
  node_models["Domain models"]
  node_query["Query builder"]
  node_database[("Application database<br/>[database.php]")]
  node_session["Database sessions"]
  node_email["SMTP email<br/>[MY_Controller.php]"]
end

subgraph group_api["REST API"]
  node_api["REST endpoints<br/>[Api.php]"]
  node_rest["REST controller"]
  node_restconfig["REST settings<br/>[rest.php]"]
end

node_visitor(("Web user"))
node_mailservice(("SMTP service"))
node_apiuser(("API client"))

node_visitor -->|"sends request"| node_front
node_front -->|"loads runtime"| node_bootstrap
node_bootstrap -->|"dispatches routing"| node_router
node_router -->|"loads mappings"| node_routes
node_router -->|"selects controller"| node_controller
node_controller -->|"handles auth"| node_auth
node_controller -->|"handles applications"| node_forms
node_controller -->|"handles inspections"| node_inspection
node_controller -->|"maintains registry"| node_reference
node_controller -->|"serves reports"| node_reports
node_controller -->|"uses models"| node_models
node_controller -->|"renders pages"| node_views
node_models -->|"builds queries"| node_query
node_query -->|"reads and writes"| node_database
node_controller -->|"uses session"| node_session
node_controller -->|"sends mail"| node_email
node_email -.->|"delivers email"| node_mailservice
node_apiuser -->|"sends request"| node_front
node_router -->|"routes API"| node_api
node_api -->|"extends handling"| node_rest
node_rest -->|"reads settings"| node_restconfig
node_rest -->|"checks API keys"| node_database

click node_front "https://github.com/codeforpakistan/pharma-license/blob/master/index.php"
click node_bootstrap "https://github.com/codeforpakistan/pharma-license/blob/master/system/core/CodeIgniter.php"
click node_router "https://github.com/codeforpakistan/pharma-license/blob/master/system/core/Router.php"
click node_routes "https://github.com/codeforpakistan/pharma-license/blob/master/application/config/routes.php"
click node_controller "https://github.com/codeforpakistan/pharma-license/blob/master/application/core/MY_Controller.php"
click node_auth "https://github.com/codeforpakistan/pharma-license/blob/master/application/controllers/Auth.php"
click node_forms "https://github.com/codeforpakistan/pharma-license/blob/master/application/controllers/Form_8a.php"
click node_inspection "https://github.com/codeforpakistan/pharma-license/blob/master/application/controllers/Inspection.php"
click node_reference "https://github.com/codeforpakistan/pharma-license/blob/master/application/controllers/Institute.php"
click node_reports "https://github.com/codeforpakistan/pharma-license/blob/master/application/controllers/Common.php"
click node_views "https://github.com/codeforpakistan/pharma-license/tree/master/application/views"
click node_models "https://github.com/codeforpakistan/pharma-license/tree/master/application/models"
click node_query "https://github.com/codeforpakistan/pharma-license/blob/master/system/database/DB_query_builder.php"
click node_database "https://github.com/codeforpakistan/pharma-license/blob/master/application/config/database.php"
click node_session "https://github.com/codeforpakistan/pharma-license/blob/master/system/libraries/Session/drivers/Session_database_driver.php"
click node_email "https://github.com/codeforpakistan/pharma-license/blob/master/application/core/MY_Controller.php"
click node_api "https://github.com/codeforpakistan/pharma-license/blob/master/application/controllers/Api.php"
click node_rest "https://github.com/codeforpakistan/pharma-license/blob/master/application/libraries/REST_Controller.php"
click node_restconfig "https://github.com/codeforpakistan/pharma-license/blob/master/application/config/rest.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_front,node_bootstrap,node_router,node_routes,node_visitor,node_apiuser toneBlue
class node_controller,node_auth,node_forms,node_inspection,node_reference,node_reports,node_views toneAmber
class node_models,node_query,node_database,node_session,node_email toneMint
class node_api,node_rest,node_restconfig toneRose
class node_mailservice toneIndigo
```

## Components

### Framework runtime

- [Front controller](https://github.com/codeforpakistan/pharma-license/blob/master/index.php): `index.php`
- [Framework bootstrap](https://github.com/codeforpakistan/pharma-license/blob/master/system/core/CodeIgniter.php): `system/core/CodeIgniter.php`
- [Request router](https://github.com/codeforpakistan/pharma-license/blob/master/system/core/Router.php): `system/core/Router.php`
- [Application routes](https://github.com/codeforpakistan/pharma-license/blob/master/application/config/routes.php): `application/config/routes.php`

### Application workflows

- [Application controller](https://github.com/codeforpakistan/pharma-license/blob/master/application/core/MY_Controller.php): `application/core/MY_Controller.php`
- [Authentication](https://github.com/codeforpakistan/pharma-license/blob/master/application/controllers/Auth.php): `application/controllers/Auth.php`
- [License forms](https://github.com/codeforpakistan/pharma-license/blob/master/application/controllers/Form_8a.php): `application/controllers/Form_8a.php`
- [Inspections](https://github.com/codeforpakistan/pharma-license/blob/master/application/controllers/Inspection.php): `application/controllers/Inspection.php`
- [Registry data](https://github.com/codeforpakistan/pharma-license/blob/master/application/controllers/Institute.php): `application/controllers/Institute.php`
- [Reports](https://github.com/codeforpakistan/pharma-license/blob/master/application/controllers/Common.php): `application/controllers/Common.php`
- [Application views](https://github.com/codeforpakistan/pharma-license/tree/master/application/views): `application/views`

### Persistence and output

- [Domain models](https://github.com/codeforpakistan/pharma-license/tree/master/application/models): `application/models`
- [Query builder](https://github.com/codeforpakistan/pharma-license/blob/master/system/database/DB_query_builder.php): `system/database/DB_query_builder.php`
- [Application database](https://github.com/codeforpakistan/pharma-license/blob/master/application/config/database.php): `application/config/database.php`
- [Database sessions](https://github.com/codeforpakistan/pharma-license/blob/master/system/libraries/Session/drivers/Session_database_driver.php): `system/libraries/Session/drivers/Session_database_driver.php`
- [SMTP email](https://github.com/codeforpakistan/pharma-license/blob/master/application/core/MY_Controller.php): `application/core/MY_Controller.php`

### REST API

- [REST endpoints](https://github.com/codeforpakistan/pharma-license/blob/master/application/controllers/Api.php): `application/controllers/Api.php`
- [REST controller](https://github.com/codeforpakistan/pharma-license/blob/master/application/libraries/REST_Controller.php): `application/libraries/REST_Controller.php`
- [REST settings](https://github.com/codeforpakistan/pharma-license/blob/master/application/config/rest.php): `application/config/rest.php`

### Other components

- **Web user**
- **SMTP service**
- **API client**

## Connections

- Web user → Front controller: sends request
- Front controller → Framework bootstrap: loads runtime
- Framework bootstrap → Request router: dispatches routing
- Request router → Application routes: loads mappings
- Request router → Application controller: selects controller
- Application controller → Authentication: handles auth
- Application controller → License forms: handles applications
- Application controller → Inspections: handles inspections
- Application controller → Registry data: maintains registry
- Application controller → Reports: serves reports
- Application controller → Domain models: uses models
- Application controller → Application views: renders pages
- Domain models → Query builder: builds queries
- Query builder → Application database: reads and writes
- Application controller → Database sessions: uses session
- Application controller → SMTP email: sends mail
- SMTP email → SMTP service: delivers email
- API client → Front controller: sends request
- Request router → REST endpoints: routes API
- REST endpoints → REST controller: extends handling
- REST controller → REST settings: reads settings
- REST controller → Application database: checks API keys
