# gyanendra-baghel/gyan-searchengine architecture

> Architecture diagram of the GitHub repository gyanendra-baghel/gyan-searchengine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gyanendra-baghel/gyan-searchengine
- Repository: https://github.com/gyanendra-baghel/gyan-searchengine

## Overview

#### Purpose and Runtime

Gyan is a server-rendered PHP/MySQL search engine. It serves keyword searches over content previously collected by the separate Gyan-Bot crawler, rather than crawling or indexing within this repository. It is deployed behind a PHP-capable web server with `public/` as the web root.

Key artifacts: `public/index.php`, `composer.json`, `gyan.sql`.

#### HTTP Entry and Request Dispatch

`public/index.php` is the single HTTP entry point. It loads application code/dependencies and routes requests into controller actions. Controllers represent the application boundary between HTTP input and rendering:

- Search and result handling: `app/controllers/SiteController.php`
- Authentication-related endpoints: `app/controllers/AuthController.php`
- Front-controller entry: `public/index.php`

#### Search Flow

A user submits a query from the search UI. The site controller validates/interprets request parameters, queries MySQL-backed indexed content, and selects a result view based on the request/result type. Result pages cover standard web, image, and video results, with explicit empty-result handling.

Relevant views:

- Query input: `app/views/search.php`
- Web results: `app/views/home.php`
- Image/video results: `app/views/imgResult.php`, `app/views/vidResult.php`
- No-match state: `app/views/no-result.php`

#### Presentation Boundary

Views are PHP-rendered templates, wrapped by a shared layout. This keeps page composition separate from controller-side request and database logic. The UI is conventional server HTML with static CSS and icon assets; there is no indicated client-side application runtime.

Paths: `app/views/_layout.php`, `app/views/_404.php`, `public/css/style.css`.

#### Persistence and Index Boundary

MySQL is the core external service and source of searchable data. `gyan.sql` provisions the required `gyan` database schema/data. Search depends on this preexisting corpus; crawler ingestion is an external system owned by the linked Gyan-Bot repository.

Paths: `gyan.sql`, `.env.example`, `app/controllers/SiteController.php`.

#### Operational Notes

Environment-specific database settings are expected through local environment configuration, with `.env.example` serving as the setup contract. PHP dependencies are managed by Composer and locked for reproducible installs. Basic crawler-facing behavior is exposed through `public/robots.txt`.

Paths: `.env.example`, `composer.lock`, `public/robots.txt`.

Main entry points: [`app/controllers/SiteController.php`](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/controllers/SiteController.php) (Site controller), [`app/views/_layout.php`](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/views/_layout.php) (Shared layout), [`public/index.php`](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/public/index.php) (Front controller), [`app/views/search.php`](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/views/search.php) (Search form)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["PHP Runtime"]
  node_web_server{{"PHP web server<br/>hosting runtime"}}
  node_front_controller["Front controller<br/>HTTP entry<br/>[index.php]"]
  node_site_controller["Site controller<br/>search controller<br/>[SiteController.php]"]
  node_auth_controller["Auth controller<br/>authentication controller<br/>[AuthController.php]"]
  node_composer["Composer dependencies<br/>PHP dependencies<br/>[composer.lock]"]
  node_robots["Crawler policy<br/>robots policy<br/>[robots.txt]"]
end

subgraph group_presentation["Presentation"]
  node_search_view["Search form<br/>PHP view<br/>[search.php]"]
  node_web_results["Web results<br/>PHP view<br/>[home.php]"]
  node_media_results["Image and video results<br/>PHP views<br/>[imgResult.php]"]
  node_no_results["No-results view<br/>PHP view<br/>[no-result.php]"]
  node_layout["Shared layout<br/>PHP layout<br/>[_layout.php]"]
  node_static_css["Site CSS<br/>static asset<br/>[style.css]"]
end

subgraph group_data["Search Data"]
  node_mysql[("MySQL searchable corpus<br/>external database")]
  node_schema["Gyan schema and seed<br/>database provisioning<br/>[gyan.sql]"]
  node_crawler{{"Gyan-Bot crawler<br/>external ingestion system"}}
  node_environment["Database environment contract<br/>environment template<br/>[.env.example]"]
end

node_user(("Search user<br/>external actor"))

node_user -->|"HTTP search request"| node_web_server
node_web_server -->|"routes request"| node_front_controller
node_front_controller -->|"loads dependencies"| node_composer
node_front_controller -->|"dispatches search"| node_site_controller
node_front_controller -->|"dispatches auth"| node_auth_controller
node_site_controller -->|"searches indexed content"| node_mysql
node_site_controller -->|"renders query UI"| node_search_view
node_site_controller -->|"renders web results"| node_web_results
node_site_controller -->|"renders image/video results"| node_media_results
node_site_controller -->|"renders empty state"| node_no_results
node_search_view -->|"wrapped by"| node_layout
node_web_results -->|"wrapped by"| node_layout
node_media_results -->|"wrapped by"| node_layout
node_no_results -->|"wrapped by"| node_layout
node_layout -->|"uses"| node_static_css
node_schema -->|"provisions"| node_mysql
node_crawler -.->|"supplies corpus externally"| node_mysql
node_environment -.->|"configures connection"| node_mysql
node_robots -.->|"crawler-facing policy"| node_crawler

click node_front_controller "https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/public/index.php"
click node_site_controller "https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/controllers/SiteController.php"
click node_auth_controller "https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/controllers/AuthController.php"
click node_composer "https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/composer.lock"
click node_search_view "https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/views/search.php"
click node_web_results "https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/views/home.php"
click node_media_results "https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/views/imgResult.php"
click node_no_results "https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/views/no-result.php"
click node_layout "https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/views/_layout.php"
click node_static_css "https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/public/css/style.css"
click node_schema "https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/gyan.sql"
click node_environment "https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/.env.example"
click node_robots "https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/public/robots.txt"

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_web_server,node_front_controller,node_site_controller,node_auth_controller,node_composer,node_robots toneBlue
class node_search_view,node_web_results,node_media_results,node_no_results,node_layout,node_static_css toneAmber
class node_mysql,node_schema,node_crawler,node_environment toneMint
class node_user toneNeutral
```

## Components

### PHP Runtime

Server-rendered application behind the web server.

- **PHP web server**: hosting runtime · Serves public/ as the web root.
- [Front controller](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/public/index.php): HTTP entry · Single request entry and dispatcher. · `public/index.php`
- [Site controller](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/controllers/SiteController.php): search controller · Validates searches, queries indexed content, and chooses result views. · `app/controllers/SiteController.php`
- [Auth controller](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/controllers/AuthController.php): authentication controller · `app/controllers/AuthController.php`
- [Composer dependencies](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/composer.lock): PHP dependencies · Application dependencies are installed reproducibly from the lockfile. · `composer.lock`
- [Crawler policy](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/public/robots.txt): robots policy · `public/robots.txt`

### Presentation

PHP templates and static browser assets.

- [Search form](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/views/search.php): PHP view · `app/views/search.php`
- [Web results](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/views/home.php): PHP view · `app/views/home.php`
- [Image and video results](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/views/imgResult.php): PHP views · `app/views/imgResult.php`
- [No-results view](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/views/no-result.php): PHP view · `app/views/no-result.php`
- [Shared layout](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/app/views/_layout.php): PHP layout · Wraps rendered page templates. · `app/views/_layout.php`
- [Site CSS](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/public/css/style.css): static asset · `public/css/style.css`

### Search Data

Prebuilt MySQL corpus consumed by search.

- **MySQL searchable corpus**: external database · Core source of indexed search content.
- [Gyan schema and seed](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/gyan.sql): database provisioning · Provisions the required gyan database schema and data. · `gyan.sql`
- **Gyan-Bot crawler**: external ingestion system · Collects and indexes content outside this repository.
- [Database environment contract](https://github.com/gyanendra-baghel/gyan-searchengine/blob/main/.env.example): environment template · Defines expected local database settings. · `.env.example`

### Other components

- **Search user**: external actor

## Connections

- Search user → PHP web server: HTTP search request
- PHP web server → Front controller: routes request
- Front controller → Composer dependencies: loads dependencies
- Front controller → Site controller: dispatches search
- Front controller → Auth controller: dispatches auth
- Site controller → MySQL searchable corpus: searches indexed content
- Site controller → Search form: renders query UI
- Site controller → Web results: renders web results
- Site controller → Image and video results: renders image/video results
- Site controller → No-results view: renders empty state
- Search form → Shared layout: wrapped by
- Web results → Shared layout: wrapped by
- Image and video results → Shared layout: wrapped by
- No-results view → Shared layout: wrapped by
- Shared layout → Site CSS: uses
- Gyan schema and seed → MySQL searchable corpus: provisions
- Gyan-Bot crawler → MySQL searchable corpus: supplies corpus externally
- Database environment contract → MySQL searchable corpus: configures connection
- Crawler policy → Gyan-Bot crawler: crawler-facing policy
