# anika-khandoker/project-simulator-04 architecture

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

- Interactive diagram: https://gitdiagram.com/anika-khandoker/project-simulator-04
- Repository: https://github.com/anika-khandoker/project-simulator-04

## Overview

1. **Overall shape**
   - This is a small **PHP MVC-style monolith**: requests enter PHP controllers, controllers call models, and views render HTML.
   - There is no evidence of a separate frontend app, queue worker, or background job system.

2. **Main application boundary**
   - The code is split into the classic three layers:
     - **controllers/** for request handling and orchestration
     - **models/** for data access and domain queries
     - **views/** for server-rendered pages
   - That makes the repo easy to diagram as a single web application with clear server-side boundaries.

3. **User-facing pages**
   - `controllers/HomeController.php` serves the public landing areas.
   - Related views live in `views/home/`:
     - `home.php`
     - `categories.php`
     - `medicines.php`
   - These pages likely form the primary browse/search experience for medicine and category content.

4. **Authentication and account flows**
   - `controllers/AuthController.php` drives login and registration.
   - `views/auth/login.php` and `views/auth/register.php` are the corresponding forms.
   - `controllers/ProfileController.php` and `views/auth/profile.php` handle the authenticated user profile area.

5. **Domain/data models**
   - `models/MedicineModel.php` is the core data model for medicine records.
   - `models/CategoryModel.php` supports category browsing/filtering.
   - `models/UserModel.php` supports authentication and profile/user lookup.
   - These models are the main data boundary between controllers and persistence.

6. **Async interaction layer**
   - `controllers/AjaxController.php` is a separate server entry point for asynchronous requests.
   - This suggests some UI actions do not require full page reloads, especially search/filter behavior.

7. **Dedicated API endpoint**
   - `api/medicine_search.php` is an explicit standalone endpoint for medicine lookup.
   - Its presence alongside `AjaxController.php` implies search is exposed both through a controller path and a lightweight API script, probably to support client-side querying.

8. **Client-side behavior**
   - `assets/js/search.js` likely issues async search requests and updates results dynamically.
   - `assets/js/validation.js` handles form validation for login/register or profile forms before submission.
   - JavaScript is supportive, not a separate application layer.

9. **Request/data flow**
   - Typical flow is: **browser → controller or API endpoint → model → view/JSON response → browser**.
   - For page loads, controllers return rendered views.
   - For search actions, the browser likely calls the AJAX/API layer and receives partial data for display.

10. **Functional boundaries**
   - The repo is organized around two primary domains:
     - **catalog browsing/search**: medicines and categories
     - **user management**: authentication and profile
   - `MedicineModel` and `CategoryModel` are the catalog side; `UserModel` is the account side.

11. **What is not present**
   - No evidence of a framework directory structure, template engine, database migrations, build pipeline, or dependency manager.
   - That suggests a lightweight custom PHP implementation rather than a large framework-based system.

12. **Architecture diagram takeaway**
   - A good diagram would show:
     - **Browser/UI** on the left
     - **PHP controllers + API endpoint** in the middle
     - **Models / data store** below or behind them
     - **Views + JS** on the client side
   - The only clearly separated interaction channel is the **AJAX/search path** from `search.js` to `AjaxController.php` or `api/medicine_search.php`.

Main entry points: [`controllers/HomeController.php`](https://github.com/anika-khandoker/project-simulator-04/blob/main/controllers/HomeController.php) (Home Ctrl), [`controllers/AuthController.php`](https://github.com/anika-khandoker/project-simulator-04/blob/main/controllers/AuthController.php) (Auth Ctrl), [`models/MedicineModel.php`](https://github.com/anika-khandoker/project-simulator-04/blob/main/models/MedicineModel.php) (Medicine Model), [`assets/js/search.js`](https://github.com/anika-khandoker/project-simulator-04/blob/main/assets/js/search.js) (Search JS)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client/UI"]
  node_browser(("Browser<br/>client"))
  node_search_js["Search JS<br/>script<br/>[search.js]"]
  node_validation_js["Validation JS<br/>script<br/>[validation.js]"]
end

subgraph group_server["PHP App"]
  node_home_ctrl["Home Ctrl<br/>controller<br/>[HomeController.php]"]
  node_auth_ctrl["Auth Ctrl<br/>controller<br/>[AuthController.php]"]
  node_profile_ctrl["Profile Ctrl<br/>controller"]
  node_ajax_ctrl["Ajax Ctrl<br/>controller<br/>[AjaxController.php]"]
  node_medicine_api["Medicine API<br/>endpoint"]
end

subgraph group_data["Domain/Data"]
  node_medicine_model[("Medicine Model<br/>[MedicineModel.php]")]
  node_category_model[("Category Model<br/>[CategoryModel.php]")]
  node_user_model[("User Model<br/>[UserModel.php]")]
  node_home_views["Home Views<br/>[home.php]"]
  node_categories_view["Categories View<br/>[categories.php]"]
  node_medicines_view["Medicines View<br/>[medicines.php]"]
  node_login_view["Login View<br/>[login.php]"]
  node_register_view["Register View<br/>[register.php]"]
  node_profile_view["Profile View<br/>[profile.php]"]
end

node_browser -->|"page load"| node_home_ctrl
node_browser -->|"auth forms"| node_auth_ctrl
node_browser -->|"profile"| node_profile_ctrl
node_browser -->|"interactive search"| node_search_js
node_browser -->|"form checks"| node_validation_js
node_search_js -->|"ajax"| node_ajax_ctrl
node_search_js -->|"search api"| node_medicine_api
node_home_ctrl -->|"render"| node_home_views
node_home_ctrl -->|"browse data"| node_medicine_model
node_home_ctrl -->|"browse data"| node_category_model
node_auth_ctrl -->|"render"| node_login_view
node_auth_ctrl -->|"render"| node_register_view
node_auth_ctrl -->|"account data"| node_user_model
node_profile_ctrl -->|"render"| node_profile_view
node_profile_ctrl -->|"profile data"| node_user_model
node_ajax_ctrl -->|"query"| node_medicine_model
node_medicine_api -->|"lookup"| node_medicine_model
node_categories_view -.->|"display"| node_category_model
node_medicines_view -.->|"display"| node_medicine_model

click node_search_js "https://github.com/anika-khandoker/project-simulator-04/blob/main/assets/js/search.js"
click node_validation_js "https://github.com/anika-khandoker/project-simulator-04/blob/main/assets/js/validation.js"
click node_home_ctrl "https://github.com/anika-khandoker/project-simulator-04/blob/main/controllers/HomeController.php"
click node_auth_ctrl "https://github.com/anika-khandoker/project-simulator-04/blob/main/controllers/AuthController.php"
click node_profile_ctrl "https://github.com/anika-khandoker/project-simulator-04/blob/main/controllers/ProfileController.php"
click node_ajax_ctrl "https://github.com/anika-khandoker/project-simulator-04/blob/main/controllers/AjaxController.php"
click node_medicine_api "https://github.com/anika-khandoker/project-simulator-04/blob/main/api/medicine_search.php"
click node_medicine_model "https://github.com/anika-khandoker/project-simulator-04/blob/main/models/MedicineModel.php"
click node_category_model "https://github.com/anika-khandoker/project-simulator-04/blob/main/models/CategoryModel.php"
click node_user_model "https://github.com/anika-khandoker/project-simulator-04/blob/main/models/UserModel.php"
click node_home_views "https://github.com/anika-khandoker/project-simulator-04/blob/main/views/home/home.php"
click node_categories_view "https://github.com/anika-khandoker/project-simulator-04/blob/main/views/home/categories.php"
click node_medicines_view "https://github.com/anika-khandoker/project-simulator-04/blob/main/views/home/medicines.php"
click node_login_view "https://github.com/anika-khandoker/project-simulator-04/blob/main/views/auth/login.php"
click node_register_view "https://github.com/anika-khandoker/project-simulator-04/blob/main/views/auth/register.php"
click node_profile_view "https://github.com/anika-khandoker/project-simulator-04/blob/main/views/auth/profile.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_browser,node_search_js,node_validation_js toneBlue
class node_home_ctrl,node_auth_ctrl,node_profile_ctrl,node_ajax_ctrl,node_medicine_api toneAmber
class node_medicine_model,node_category_model,node_user_model,node_home_views,node_categories_view,node_medicines_view,node_login_view,node_register_view,node_profile_view toneMint
```

## Components

### Client/UI

Browser-facing pages and scripts

- **Browser**: client · User interaction and page requests
- [Search JS](https://github.com/anika-khandoker/project-simulator-04/blob/main/assets/js/search.js): script · Async search and result updates · `assets/js/search.js`
- [Validation JS](https://github.com/anika-khandoker/project-simulator-04/blob/main/assets/js/validation.js): script · Client-side form checks · `assets/js/validation.js`

### PHP App

Controllers and API entry points

- [Home Ctrl](https://github.com/anika-khandoker/project-simulator-04/blob/main/controllers/HomeController.php): controller · Public browse and landing flows · `controllers/HomeController.php`
- [Auth Ctrl](https://github.com/anika-khandoker/project-simulator-04/blob/main/controllers/AuthController.php): controller · Login and registration flows · `controllers/AuthController.php`
- [Profile Ctrl](https://github.com/anika-khandoker/project-simulator-04/blob/main/controllers/ProfileController.php): controller · Authenticated profile handling · `controllers/ProfileController.php`
- [Ajax Ctrl](https://github.com/anika-khandoker/project-simulator-04/blob/main/controllers/AjaxController.php): controller · Async request handling · `controllers/AjaxController.php`
- [Medicine API](https://github.com/anika-khandoker/project-simulator-04/blob/main/api/medicine_search.php): endpoint · Standalone medicine search endpoint · `api/medicine_search.php`

### Domain/Data

Models and server-rendered views

- [Medicine Model](https://github.com/anika-khandoker/project-simulator-04/blob/main/models/MedicineModel.php): model · Medicine records and queries · `models/MedicineModel.php`
- [Category Model](https://github.com/anika-khandoker/project-simulator-04/blob/main/models/CategoryModel.php): model · Category browse and filtering · `models/CategoryModel.php`
- [User Model](https://github.com/anika-khandoker/project-simulator-04/blob/main/models/UserModel.php): model · Authentication and profile data · `models/UserModel.php`
- [Home Views](https://github.com/anika-khandoker/project-simulator-04/blob/main/views/home/home.php): views · Landing, categories, and medicines pages · `views/home/home.php`
- [Categories View](https://github.com/anika-khandoker/project-simulator-04/blob/main/views/home/categories.php): view · Category listing page · `views/home/categories.php`
- [Medicines View](https://github.com/anika-khandoker/project-simulator-04/blob/main/views/home/medicines.php): view · Medicine listing page · `views/home/medicines.php`
- [Login View](https://github.com/anika-khandoker/project-simulator-04/blob/main/views/auth/login.php): view · Sign-in form · `views/auth/login.php`
- [Register View](https://github.com/anika-khandoker/project-simulator-04/blob/main/views/auth/register.php): view · Account creation form · `views/auth/register.php`
- [Profile View](https://github.com/anika-khandoker/project-simulator-04/blob/main/views/auth/profile.php): view · User profile page · `views/auth/profile.php`

## Connections

- Browser → Home Ctrl: page load · Browser requests public pages
- Browser → Auth Ctrl: auth forms · Browser submits login and registration forms
- Browser → Profile Ctrl: profile · Browser accesses authenticated profile pages
- Browser → Search JS: interactive search · Client-side search and filtering interactions
- Browser → Validation JS: form checks · Client-side validation on forms
- Search JS → Ajax Ctrl: ajax · Async UI requests hit the AJAX controller
- Search JS → Medicine API: search api · Async search can also call the dedicated endpoint
- Home Ctrl → Home Views: render · Home controller renders the main browsing views
- Home Ctrl → Medicine Model: browse data · Fetches medicine content for public pages
- Home Ctrl → Category Model: browse data · Fetches category content for public pages
- Auth Ctrl → Login View: render · Renders login form
- Auth Ctrl → Register View: render · Renders registration form
- Auth Ctrl → User Model: account data · Uses user records for authentication
- Profile Ctrl → Profile View: render · Renders profile page
- Profile Ctrl → User Model: profile data · Loads and updates user information
- Ajax Ctrl → Medicine Model: query · Handles asynchronous medicine lookup
- Medicine API → Medicine Model: lookup · Dedicated endpoint queries medicine data
- Categories View → Category Model: display · Category page reflects category data
- Medicines View → Medicine Model: display · Medicine page reflects medicine data
