How gyanendra-baghel/gyan-searchengine works
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: SiteController.php Site controller · _layout.php Shared layout · index.php Front controller · search.php Search form
Components 17
PHP Runtime
Server-rendered application behind the web server.
- PHP web server · Serves public/ as the web root.
- Front controller · Single request entry and dispatcher.
public/index.php - Site controller · Validates searches, queries indexed content, and chooses result views.
app/controllers/SiteController.php - Auth controller
app/controllers/AuthController.php - Composer dependencies · Application dependencies are installed reproducibly from the lockfile.
composer.lock - Crawler policy
public/robots.txt
Presentation
PHP templates and static browser assets.
- Search form
app/views/search.php - Web results
app/views/home.php - Image and video results
app/views/imgResult.php - No-results view
app/views/no-result.php - Shared layout · Wraps rendered page templates.
app/views/_layout.php - Site CSS
public/css/style.css
Search Data
Prebuilt MySQL corpus consumed by search.
- MySQL searchable corpus · Core source of indexed search content.
- Gyan schema and seed · Provisions the required gyan database schema and data.
gyan.sql - Gyan-Bot crawler · Collects and indexes content outside this repository.
- Database environment contract · Defines expected local database settings.
.env.example
Other components
- Search user
Connections 19
- 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