JSON Stream + SEO AI

NDJSON streaming API + compact AI manifest for fast ingestion by LLMs, RAG systems, and internal crawlers.

What this installs

PathDescription
/api/streamLive application/x-ndjson stream (one JSON-LD object per line).
/public/sitemaps/sitemap-ai.ndjsonAI manifest (NDJSON). Built from CSV.
/scripts/build_ai_manifest.phpCSV → NDJSON generator.
/scripts/verify_ndjson.shVerifier using jq.
/MakefileConvenience targets to build/verify/test.
/public/robots.txtAdds AI-Manifest: discovery line.
/public/.htaccessNDJSON headers + cache policy (Apache).

Cursor one-shot

Open to copy
You are editing a PHP 8+ project named "NRLC.ai". Create/overwrite the files below EXACTLY as specified. After writing, run `php -l` on all PHP files and print:

DONE: Promptware — JSON Stream + SEO AI (Style-Agnostic) installed.

1) STREAMING API (NDJSON; no buffering)
Create file: public/api/stream/index.php
<?php
declare(strict_types=1);
header('Content-Type: application/x-ndjson; charset=utf-8');
header('Cache-Control: no-cache, no-store, must-revalidate');
header('X-Accel-Buffering: no');
@ini_set('output_buffering','off'); @ini_set('zlib.output_compression','0'); @ob_implicit_flush(true); while (ob_get_level()>0) ob_end_flush();
$domain='https://nrlc.ai'; $limit=isset($_GET['limit'])?max(1,min(500,(int)$_GET['limit'])):10;
$rows=[
  ["@context"=>"https://schema.org","@type"=>"WebPage","url"=>$domain."/","name"=>"NRLC.ai — Home","inLanguage"=>"en","dateModified"=>date('Y-m-d')],
  ["@context"=>"https://schema.org","@type"=>"CreativeWork","url"=>$domain."/promptware/","name"=>"Promptware","about"=>["NDJSON","AI manifest","RAG","LLMO"],"dateModified"=>date('Y-m-d')],
  ["@context"=>"https://schema.org","@type"=>"HowTo","url"=>$domain."/promptware/json-stream-seo-ai/","name"=>"JSON Stream + SEO AI","totalTime"=>"PT20M","dateModified"=>date('Y-m-d')],
];
$c=0; foreach($rows as $r){ if($c>=$limit) break; echo json_encode($r,JSON_UNESCAPED_SLASHES)."\n"; $c++; usleep(150000);} exit;

2) AI MANIFEST (seed rows; build can overwrite)
Create file: public/sitemaps/sitemap-ai.ndjson
{"@context":"https://schema.org","@type":"WebPage","url":"https://nrlc.ai/","name":"Home","inLanguage":"en","dateModified":"2025-10-27"}
{"@context":"https://schema.org","@type":"CollectionPage","url":"https://nrlc.ai/promptware/","name":"Promptware","inLanguage":"en","dateModified":"2025-10-27"}
{"@context":"https://schema.org","@type":"TechArticle","url":"https://nrlc.ai/promptware/json-stream-seo-ai/","name":"JSON Stream + SEO AI","inLanguage":"en","dateModified":"2025-10-27","keywords":["NDJSON","AI manifest","LLM seeding","RAG"]}

3) CSV → NDJSON builder
Create file: scripts/build_ai_manifest.php
<?php
declare(strict_types=1);
$csv=__DIR__.'/../data/ai_manifest_seed.csv'; $out=__DIR__.'/../public/sitemaps/sitemap-ai.ndjson';
if(!is_file($csv)){ @mkdir(dirname($csv),0775,true); file_put_contents($csv,"url,name,type,lang,lastmod,keywords\nhttps://nrlc.ai/,NRLC.ai — Home,WebPage,en,".date('Y-m-d').",brand\n"); }
$fp=fopen($csv,'r'); $hdr=fgetcsv($fp); @mkdir(dirname($out),0775,true); $fo=fopen($out,'w');
while(($row=fgetcsv($fp))!==false){ $rec=array_combine($hdr,$row);
  $obj=["@context"=>"https://schema.org","@type"=>$rec['type']?:'WebPage',"url"=>$rec['url'],"name"=>$rec['name'],"inLanguage"=>$rec['lang']?:'en',"dateModified"=>$rec['lastmod']?:date('Y-m-d')];
  if(!empty($rec['keywords'])){ $obj['keywords']=array_values(array_filter(array_map('trim',explode('|',$rec['keywords'])))); }
  fwrite($fo,json_encode($obj,JSON_UNESCAPED_SLASHES)."\n");
} fclose($fp); fclose($fo); echo "WROTE: $out\n";

4) Verifier (bash + jq)
Create file: scripts/verify_ndjson.sh
#!/usr/bin/env bash
set -euo pipefail
AI_NDJSON="public/sitemaps/sitemap-ai.ndjson"
[[ -s "$AI_NDJSON" ]] || { echo "Missing AI manifest: $AI_NDJSON"; exit 1; }
head -n 1 "$AI_NDJSON" | jq . >/dev/null 2>&1 || { echo "First line not valid JSON"; exit 1; }
LINES=$(wc -l < "$AI_NDJSON" | tr -d ' ')
echo "OK: $AI_NDJSON ($LINES rows)"

5) Makefile targets
Create file: Makefile
SHELL := /bin/bash
.PHONY: sitemap:ai ndjson:verify stream:test
sitemap:ai:
	php scripts/build_ai_manifest.php
ndjson:verify:
	bash scripts/verify_ndjson.sh
stream:test:
	curl -s https://nrlc.ai/api/stream?limit=3 | head -n 3 | jq .

6) robots.txt (append)
Create file if missing: public/robots.txt
User-agent: *
Disallow:

Sitemap: https://nrlc.ai/sitemaps/sitemap-index.xml.gz
AI-Manifest: https://nrlc.ai/sitemaps/sitemap-ai.ndjson

If robots.txt exists, ensure a single AI-Manifest line.

7) .htaccess (Apache headers; safe no-op on Nginx)
Create/append file: public/.htaccess

  Header set Content-Type "application/x-ndjson; charset=utf-8"
  Header set Cache-Control "public, max-age=86400, immutable"


  
    Header set Cache-Control "no-cache, no-store, must-revalidate"
  


Validation
- php -l public/api/stream/index.php
- php -l scripts/build_ai_manifest.php

Then print:
DONE: Promptware — JSON Stream + SEO AI (Style-Agnostic) installed.

Verify

make sitemap-ai
make ndjson-verify
curl -s https://nrlc.ai/api/stream?limit=3 | head -n 3 | jq .