AI Website Audit Powered by DeepSeek
TL;DR
I added an "AI Website Audit" tool powered by DeepSeek to my SEO tools service (a continuation of the catalog case study). The key idea was not to "bolt on a chat" but to build a pipeline: a custom analyzer performs ~10 website checks and compiles facts, and the neural network doesn't work blindly — it uses these facts to deliver personalized recommendations. A separate challenge was securing the paid API: server-side cache, a quota of 3 requests/day, an SSRF filter, and a key the frontend never sees.
Technology Stack
| Technology | Role |
|---|---|
| PHP 8.3 | Microservice, analyzer, security, no frameworks |
| Joomla 6 | CMS, tool page article |
| SQLite | URL cache, quota, rate-limit |
| DeepSeek API | DeepSeek::chat() wrapper, deepseek-chat model |
| Javascript (ES6) | Frontend: form, spinner, Markdown report rendering |
Context and Task
The SEO tools service needed an "AI Audit" feature: a user enters any website URL, the tool analyzes technical and content parameters, and via the neural network provides personalized improvement recommendations.
The task was not to "bolt on an AI chat" but to build a full-fledged service that:
- doesn't drain the budget on paid API hosting;
- can't be bypassed by a random visitor using a VPN;
- delivers actionable results, not generic advice from a free chat.
Why This Isn't a "Bare Chat" (Key Architectural Idea)
The free DeepSeek web chat answers everything "in general terms." Our tool is fundamentally different:
-
First, we gather facts. A custom analyzer performs ~10 website checks (HTTPS, meta tags, title, description, H1, canonical, robots.txt, sitemap, indexing, links, content) and produces a numeric score across four categories: technical SEO, content, indexing, links.
-
Then the neural network works not blindly, but on these facts. The prompt includes specifics: "score 74/100, missing canonical, meta description 80 characters, 5 images without alt." Only then does DeepSeek write recommendations.
-
The result is actionable steps for a specific site, not generic advice. No free chat offers this because it lacks the context of "your site."
Technically, this is a pipeline: URL → parser/analyzer → facts → prompt → LLM → report.
flowchart LR
A["Website URL"] --> B["Analyzer: ~10 checks"]
B --> C["Facts + score /100<br>(4 metrics)"]
C --> D["Prompt with specifics"]
D --> E["DeepSeek API"]
E --> F["Markdown report"]
Architecture
flowchart TB
F["Frontend (vanilla JS)<br>fetch POST {url}"]
F --> A["Orchestrator endpoint<br>(PHP on server)"]
A --> S["SSRF protection<br>(rejectPrivateHost)"]
A --> Q["AiQuota quota<br>(3/day)"]
A --> C["Cache<br>(by URL hash)"]
A --> N["Analyzer::run($url)"]
N --> D["DeepSeek::chat()"]
C --> D
A --> R["JSON response"]
All modules reside in the shared lib/ folder of the microservice:
lib/
├── bootstrap.php # autoloading, CORS, JSON responses
├── HttpClient.php # curl wrapper (redirects, UA, timeout, TLS)
├── Analyzer.php # orchestrator: score + issues + recommendations
├── Checks.php # HTML parsing + technical/link checks
├── Scorer.php # 4 metrics → final score /100
├── Cache.php # SQLite cache + rate-limit
├── DeepSeek.php # DeepSeek API wrapper (key on server)
└── AiQuota.php # free AI request limit
Securing the Paid API (Main Engineering Value)
The DeepSeek API is paid, so security was a top priority. Three layers plus a key invisible to the client.
1. Server-Side Cache (Zero Tokens on Repeats)
Cache.php stores the result by sha1(url) in SQLite. A repeat request for the same URL is served from the cache — the neural network is never called. This blocks the simplest budget-drain scenario: the same request sent 1000 times by a bot.
2. Quota of 3 Requests/Day
AiQuota.php — a ai_quota(key, day, count) table in SQLite. The client key is computed via a cascade:
user_id (if logged in) → cookie fingerprint → IP
The cascade's logic: a VPN changes the IP but not the cookie. Registration provides a user_id that a VPN cannot bypass. Verified: on the fourth request, the endpoint returns HTTP 429 "Free limit reached (3 per day)."
flowchart LR
A["Request"] --> B{"Client cascade owner"}
B -->|"logged in"| C["user_id"]
B -->|"no"| D["cookie fingerprint"]
D -->|"no cookie"| E["IP"]
C --> F{"count >= 3?"}
E --> F
F -->|"yes"| G["HTTP 429"]
F -->|"no"| H["Analyzer + DeepSeek"]
3. SSRF Protection
Before any outbound request, rejectPrivateHost() blocks:
127.0.0.1,0.0.0.0,::1;169.254.169.254(cloud metadata);- subnets
10.x,192.168.x,172.16–31.x.
This prevents an attacker from making the server reach into the internal network.
4. Key Invisible to the Client
The sk-... key is defined as a constant in DeepSeek.php on the server. It never reaches the browser: the frontend sends a request to its own PHP, and PHP itself calls DeepSeek. Stealing the key via DevTools is impossible.
How the Neural Network Call Works
DeepSeek.php is a minimal wrapper:
private const MODEL = 'deepseek-chat';
private const MAX_TOKENS = 1200; // hard cost limit
private const TIMEOUT = 60;
$payload = [
'model' => 'deepseek-chat',
'messages' => [
['role' => 'system', 'content' => $system],
['role' => 'user', 'content' => $user],
],
'max_tokens' => 1200,
'temperature' => 0.4, // predictability, not creativity
'stream' => false,
];
The system prompt is strict:
"You are an SEO expert with 15 years of experience. Answer briefly, specifically, and to the point, in Russian. The response format must be strictly in Markdown: first a summary (2–3 sentences), then a list of prioritized recommendations with specific wording... Do not give generic phrases, only actionable advice."
temperature 0.4 + max_tokens 1200 is intentional: we need predictability and controlled spending, not a "creative" 10,000-token response.
Facts the Analyzer Collects
The full list of checks in Checks.php:
| Group | What it checks |
|---|---|
| Technical | HTTPS, redirect chain, HTTP status, response time, robots.txt, sitemap.xml, canonical |
| Content | title (presence/length), meta description (presence/length), H1 (presence/uniqueness), meta robots noindex, OpenGraph (og:title/description/image), JSON-LD (Schema.org), text volume (words), image alt, keywords from title |
| Indexing | robots.txt, meta noindex, canonical |
| Links | internal/external, broken (HEAD requests), nofollow |
All of this is consolidated in Scorer → 4 metrics (technical/content/indexing/links) → overall score /100.
User Experience
- Enter URL → spinner "Analyzing site…" (up to 60 seconds, as a real audit plus an LLM request is running).
- The score and the neural network's Markdown report are displayed, rendered by our JS.
Example of a real response:
Summary: the site has a good link profile, but critical technical issues (missing canonical) and weak content. Priority is to fix technical errors, then strengthen content.
Critical: — Add canonical to all pages… — Create and upload robots.txt…
Outcome
The finished tool is not an "embedded chatbot" but an AI service with its own data pipeline:
| Property | How achieved |
|---|---|
| Key cannot be stolen | Constant on the server, frontend never sees it |
| Budget under control | Cache + quota + token limit (max_tokens 1200) |
| Zero external libraries | Self-contained solution in pure PHP 8.3 |
| Abuse protection | SSRF + rate-limit + cascading client identification |
| Personalized result | Pipeline "facts → prompt → LLM → report" |
Conclusions
- An LLM feature cannot be built as a "bare chat." The value lies in your own fact pipeline: the analyzer gathers context, the neural network interprets it. Without facts, it would be generic advice from a free chat.
- Securing a paid API is a task for the start, not "later." The cache blocks repeats (0 tokens), the quota blocks abuse, and SSRF blocks internal network access.
- The
user_id → cookie → IPcascade fixes the VPN problem. A VPN changes the IP but not the cookie or registration. Testing on the 4th request (HTTP 429) confirmed the limit works. - LLM parameters define economics, not taste.
max_tokens 1200andtemperature 0.4are about cost control and response predictability, not aesthetics. - The API key must be unreachable via DevTools. The frontend never calls the provider directly — only through its own PHP.
- Self-containment in pure PHP is achievable. Zero external libraries with a full feature set: HTTP client, cache, quota, SSRF, LLM wrapper.
