Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SourceLens API

Overview

A high-performance backend architecture analyzer built with PHP and JavaScript. It utilizes the cURL library to fetch remote source code and implements a custom SEO diagnostic engine using PHP DOMDocument.

Features

  • PHP cURL: Handles remote resource retrieval with custom headers and timeout management.
  • DOMDocument Analysis: Implements technical SEO auditing for meta tags, content structure, and social graphs.
  • JSON Serialization: Provides structured data output for frontend consumption and local storage.
  • Stack Detection: Rule-based signature matching for identifying frameworks like React, Next.js, and WordPress.

Getting Started

Installation

  1. Clone the repository into your local server environment (e.g., XAMPP htdocs).
  2. Ensure the PHP cURL and OpenSSL extensions are enabled in your php.ini.
  3. Start your Apache server.
  4. Access the project via http://localhost/source-lens.

Environment Variables

The system operates on a standard PHP configuration. Ensure the following server settings are optimized:

  • max_execution_time: 0 (Managed dynamically in fetch.php)
  • allow_url_fopen: On
  • memory_limit: 256M (Recommended for large DOM parsing)

API Documentation

Base URL

/fetch.php

Endpoints

POST /fetch.php

Request:

{
  "url": "https://example.com"
}

Response:

{
    "source": "<!DOCTYPE html>...",
    "url": "https://example.com",
    "meta": {
        "ip": "93.184.216.34",
        "host": "example.com",
        "status": 200,
        "stack": ["Nginx", "PHP"],
        "title": "Example Domain",
        "server": "ECS (nyb/1D13)",
        "load_time": 0.45,
        "page_size": 1256,
        "seo": {
            "score": 85,
            "categories": {
                "technical": {"score": 30, "total": 40, "percent": 75},
                "content": {"score": 40, "total": 50, "percent": 80}
            },
            "details": [
                {
                    "category": "performance",
                    "label": "Load Speed",
                    "value": "0.45s",
                    "passed": true,
                    "score": 20,
                    "message": "Page loads quickly (under 2.5s)."
                }
            ],
            "summary": {
                "passed": 8,
                "failed": 2
            }
        }
    }
}

Errors:

  • 200 (JSON Error): {"error": "URL is required"} - Occurs when the payload is missing the target address.
  • 200 (JSON Error): {"error": "Access to facebook.com is restricted."} - Occurs when targeting domains listed in the restricted array.
  • 200 (JSON Error): {"error": "Network Error (Code 28): Timeout reached"} - Occurs when the target server fails to respond within 30 seconds.
  • 200 (JSON Error): {"error": "Access denied (HTTP 403)"} - Occurs when the target website blocks the server's IP address.

Technologies Used

Technology Purpose Link
PHP 8.x Server-side logic and cURL operations php.net
Vanilla JavaScript DOM manipulation and API orchestration developer.mozilla.org
ApexCharts Data visualization for SEO metrics apexcharts.com
Highlight.js Code syntax highlighting highlightjs.org
Microlink API Website screenshot generation microlink.io

Usage

To use SourceLens, navigate to the web interface and enter a valid URL in the search bar. The system will:

  1. Dispatch a POST request to the PHP backend.
  2. Fetch the raw HTML and server headers.
  3. Parse the DOM to calculate an SEO health score based on 10+ metrics.
  4. Render the source code with syntax highlighting and generate a live preview.
  5. Provide options to download the raw HTML or a structured JSON report.

Contributing

  • Fork the repository and create your feature branch. 🏗️
  • Ensure your code adheres to standard PSR-12 formatting for PHP. 🧹
  • Submit a pull request with a detailed description of your changes. 🚀

Author Info

Developed by Precious Adedokun. 👨‍🎓

Build Status Version License

Readme was generated by Dokugen

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages