Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions NainOrder.Api/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,40 @@
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>NainOrder · Drop engine</title>
<meta name="description" content="Sell a limited drop to a crowd: exact units, expiring holds, nothing sold twice. .NET API with Clean Architecture and an installable panel.">
<link rel="canonical" href="https://order.naindev.com/">
<link rel="author" href="https://www.naindev.com/">
<meta property="og:type" content="website">
<meta property="og:site_name" content="NainOrder">
<meta property="og:title" content="NainOrder · Drop engine">
<meta property="og:description" content="Sell a limited drop to a crowd: exact units, expiring holds, nothing sold twice. .NET API with Clean Architecture and an installable panel.">
<meta property="og:url" content="https://order.naindev.com/">
<meta property="og:image" content="https://www.naindev.com/assets/images/og-cover-v5.jpg">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="NainOrder · Drop engine">
<meta name="twitter:description" content="Sell a limited drop to a crowd: exact units, expiring holds, nothing sold twice. .NET API with Clean Architecture and an installable panel.">
<meta name="twitter:image" content="https://www.naindev.com/assets/images/og-cover-v5.jpg">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "SoftwareApplication",
"name": "NainOrder",
"url": "https://order.naindev.com/",
"description": "Sell a limited drop to a crowd: exact units, expiring holds, nothing sold twice. .NET API with Clean Architecture and an installable panel.",
"applicationCategory": "BusinessApplication",
"operatingSystem": "Web",
"isAccessibleForFree": true,
"inLanguage": ["en", "es"],
"author": {
"@type": "Person",
"@id": "https://www.naindev.com/#person",
"name": "Aitor Nain Mendoza Vallejo",
"url": "https://www.naindev.com/"
},
"sameAs": ["https://github.com/Nain9Dev/NainOrder"]
}
</script>
<meta name="color-scheme" content="dark light">
<meta name="theme-color" content="#08090d" media="(prefers-color-scheme: dark)">
<meta name="theme-color" content="#f6f7fb" media="(prefers-color-scheme: light)">
Expand Down
9 changes: 9 additions & 0 deletions NainOrder.Api/wwwroot/llms.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# NainOrder

> Order engine for limited drops: exact units, expiring holds and nothing sold twice, built as a .NET API with Clean Architecture and an installable web panel.

## Links

- [Live demo](https://order.naindev.com/): the interactive panel
- [Source code](https://github.com/Nain9Dev/NainOrder): repository, architecture notes and documentation
- [Author site](https://www.naindev.com/): Aitor Nain Mendoza Vallejo (NainDev)
4 changes: 4 additions & 0 deletions NainOrder.Api/wwwroot/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
User-agent: *
Allow: /

Sitemap: https://order.naindev.com/sitemap.xml
6 changes: 6 additions & 0 deletions NainOrder.Api/wwwroot/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://order.naindev.com/</loc>
</url>
</urlset>
139 changes: 139 additions & 0 deletions NainOrder.Tests/Api/SeoDiscoverabilityTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Xml.Linq;

namespace NainOrder.Tests.Api;

/// <summary>
/// REQ-064: the public page declares what search engines and AI crawlers need (one canonical URL,
/// a description of sensible length, Open Graph, Twitter card and JSON-LD) and the three
/// discovery files are served from the site root, not swallowed by the SPA fallback.
/// </summary>
public class SeoDiscoverabilityTests : IClassFixture<NainOrderApiFactory>
{
private const string Canonical = "https://order.naindev.com/";
private const string AuthorId = "https://www.naindev.com/#person";
private const string Repository = "https://github.com/Nain9Dev/NainOrder";

private static readonly string Root = Path.GetFullPath(Path.Combine(
AppContext.BaseDirectory, "../../../../NainOrder.Api/wwwroot"));

private static readonly TimeSpan RegexTimeout = TimeSpan.FromSeconds(1);

private readonly HttpClient _client;

public SeoDiscoverabilityTests(NainOrderApiFactory factory) => _client = factory.CreateClient();

private static string Html() => File.ReadAllText(Path.Combine(Root, "index.html"));

private static List<string> MetaContents(string html, string attribute, string key) =>
Regex.Matches(html, "<meta\\s+[^>]*>", RegexOptions.IgnoreCase, RegexTimeout)
.Select(m => m.Value)
.Where(tag => Regex.IsMatch(tag, $"{attribute}=\"{Regex.Escape(key)}\"", RegexOptions.IgnoreCase, RegexTimeout))
.Select(tag => Regex.Match(tag, "content=\"([^\"]*)\"", RegexOptions.IgnoreCase, RegexTimeout).Groups[1].Value)
.ToList();

private static string Meta(string html, string attribute, string key)
{
var values = MetaContents(html, attribute, key);
Assert.True(values.Count == 1, $"Expected exactly one <meta {attribute}=\"{key}\">, found {values.Count}.");
return values[0];
}

[Fact]
public void The_page_declares_exactly_one_canonical_link_equal_to_the_host_root()
{
var links = Regex.Matches(Html(), "<link\\s+[^>]*rel=\"canonical\"[^>]*>", RegexOptions.IgnoreCase, RegexTimeout);

Assert.Single(links);
Assert.Contains($"href=\"{Canonical}\"", links[0].Value, StringComparison.Ordinal);
}

[Fact]
public void The_description_is_a_single_tag_of_70_to_160_characters()
{
var description = Meta(Html(), "name", "description");

Assert.InRange(description.Length, 70, 160);
}

[Fact]
public void Open_Graph_and_Twitter_cards_describe_the_page_and_agree_with_the_canonical_url()
{
var html = Html();

Assert.Equal("website", Meta(html, "property", "og:type"));
Assert.Equal("NainOrder", Meta(html, "property", "og:site_name"));
Assert.False(string.IsNullOrWhiteSpace(Meta(html, "property", "og:title")));
Assert.False(string.IsNullOrWhiteSpace(Meta(html, "property", "og:description")));
Assert.Equal(Canonical, Meta(html, "property", "og:url"));
Assert.StartsWith("https://", Meta(html, "property", "og:image"), StringComparison.Ordinal);
Assert.Equal("1200", Meta(html, "property", "og:image:width"));
Assert.Equal("630", Meta(html, "property", "og:image:height"));

Assert.Equal("summary_large_image", Meta(html, "name", "twitter:card"));
Assert.False(string.IsNullOrWhiteSpace(Meta(html, "name", "twitter:title")));
Assert.False(string.IsNullOrWhiteSpace(Meta(html, "name", "twitter:description")));
Assert.Equal(Meta(html, "property", "og:image"), Meta(html, "name", "twitter:image"));
}

[Fact]
public void The_page_links_its_author()
{
Assert.Matches("<link\\s+rel=\"author\"\\s+href=\"https://www.naindev.com/\"", Html());
}

[Fact]
public void The_JSON_LD_describes_the_application_and_names_the_author_by_id()
{
var blocks = Regex.Matches(Html(), "<script type=\"application/ld\\+json\">(.*?)</script>",
RegexOptions.Singleline, RegexTimeout);
Assert.Single(blocks);

var data = JsonDocument.Parse(blocks[0].Groups[1].Value).RootElement;

Assert.Equal("SoftwareApplication", data.GetProperty("@type").GetString());
Assert.Equal("NainOrder", data.GetProperty("name").GetString());
Assert.Equal(Canonical, data.GetProperty("url").GetString());
Assert.Equal("Web", data.GetProperty("operatingSystem").GetString());
Assert.True(data.GetProperty("isAccessibleForFree").GetBoolean());
Assert.Equal(Meta(Html(), "name", "description"), data.GetProperty("description").GetString());
Assert.Equal(AuthorId, data.GetProperty("author").GetProperty("@id").GetString());
Assert.Contains(Repository, data.GetProperty("sameAs").EnumerateArray().Select(e => e.GetString()));
}

[Fact]
public void The_discovery_files_are_served_from_the_root_and_not_by_the_spa_fallback()
{
foreach (var file in new[] { "robots.txt", "sitemap.xml", "llms.txt" })
Assert.True(File.Exists(Path.Combine(Root, file)), $"{file} is missing from wwwroot.");

var robots = File.ReadAllText(Path.Combine(Root, "robots.txt"));
Assert.Contains("User-agent: *", robots, StringComparison.Ordinal);
Assert.Contains("Allow: /", robots, StringComparison.Ordinal);
Assert.DoesNotContain("Disallow: /", robots, StringComparison.Ordinal);
Assert.Contains($"Sitemap: {Canonical}sitemap.xml", robots, StringComparison.Ordinal);

var sitemap = XDocument.Parse(File.ReadAllText(Path.Combine(Root, "sitemap.xml")));
var loc = sitemap.Descendants().Single(e => e.Name.LocalName == "loc").Value;
Assert.Equal(Canonical, loc);

var llms = File.ReadAllText(Path.Combine(Root, "llms.txt"));
Assert.StartsWith("# NainOrder", llms, StringComparison.Ordinal);
Assert.Contains(Repository, llms, StringComparison.Ordinal);
Assert.Contains("https://www.naindev.com/", llms, StringComparison.Ordinal);
}

[Theory]
[InlineData("/robots.txt", "text/plain")]
[InlineData("/sitemap.xml", "xml")]
[InlineData("/llms.txt", "text/plain")]
public async Task The_application_serves_each_discovery_file_with_its_own_content_type(string path, string mediaType)
{
var response = await _client.GetAsync(path);

response.EnsureSuccessStatusCode();
Assert.Contains(mediaType, response.Content.Headers.ContentType!.MediaType, StringComparison.Ordinal);
Assert.DoesNotContain("<html", await response.Content.ReadAsStringAsync(), StringComparison.OrdinalIgnoreCase);
}
}
1 change: 1 addition & 0 deletions docs/10-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,4 @@ step. The entry route itself (`#/drop`) is unchanged: Q-008.
| REQ-061 | When a client-panel route is requested directly, the system shall return the panel so its own router can resolve it. |
| REQ-062 | On start-up the system shall apply pending migrations and seed demonstration data idempotently, requiring no manual step. |
| REQ-063 | The container image shall run the application as a non-root user. |
| REQ-064 | The public page shall declare one canonical URL, a 70 to 160 character description, Open Graph and Twitter card metadata and `SoftwareApplication` JSON-LD naming its author, and the application shall serve `/robots.txt`, `/sitemap.xml` and `/llms.txt` as real files from the site root. |
1 change: 1 addition & 0 deletions docs/50-traceability.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Test suites:
| REQ-061 | `OrderFlowTests.Deep_links_of_the_client_application_fall_back_to_the_spa` |
| REQ-062 | `NainOrderApiFactory` boots the real application per test run; every integration test depends on migrations and seeding having succeeded. CI repeats it against the container. |
| REQ-063 | CI job `container` asserts `id -u` is not `0` inside the running image. |
| REQ-064 | `SeoDiscoverabilityTests` (page metadata, JSON-LD, discovery files, and the three files served by the real application). |

## Gaps

Expand Down
3 changes: 3 additions & 0 deletions docs/90-changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Notable changes. Format loosely follows Keep a Changelog; dates come from git.

### Added

- Search and AI-engine discoverability (`specs/next-seo-discoverability`): the public page now
declares a canonical URL, Open Graph and Twitter card metadata and `SoftwareApplication` JSON-LD,
and the site root serves `robots.txt`, `sitemap.xml` and `llms.txt`. REQ-064.
- A populated first screen (`specs/next-demo-first-screen`): a fresh instance seeds six sample
orders, one per state of the machine plus a second shipped one, dated across the last twelve
days and built through the domain, so the dashboard opens with revenue, a distribution, a
Expand Down
9 changes: 9 additions & 0 deletions specs/next-seo-discoverability/plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# next-seo-discoverability — Plan

1. `SeoDiscoverabilityTests` reads `wwwroot/index.html` and the three discovery files and asserts
REQ-064; a `WebApplicationFactory` check proves the real application serves each file with its
own content type instead of the SPA fallback (`UseStaticFiles` runs before `MapFallbackToFile`).
2. Add the metadata and JSON-LD to the `<head>` of `wwwroot/index.html`.
3. Add `robots.txt`, `sitemap.xml` and `llms.txt` to `wwwroot`.

No change in Domain, Application, Infrastructure or the controllers.
26 changes: 26 additions & 0 deletions specs/next-seo-discoverability/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# next-seo-discoverability — Search and AI-engine discoverability

**Status:** Draft — requested by the owner (2026-11-09) as a baseline for all public demo sites.

## Goal

A crawler or an AI engine that fetches `https://order.naindev.com/` learns what the product is,
who made it and where the source lives, without executing the panel's JavaScript.

## Requirements (EARS)

- **REQ-064** — The public page shall declare one canonical URL, a 70 to 160 character description, Open Graph and Twitter card metadata and `SoftwareApplication` JSON-LD naming its author, and the application shall serve `/robots.txt`, `/sitemap.xml` and `/llms.txt` as real files from the site root.

## Notes

- The static HTML has no `<h1>` outside `<noscript>`: the panel is rendered by JavaScript. The
markup is not restructured by this change (the visual design is out of scope).
- The production site is published from `NainOrder.Api/wwwroot` to GitHub Pages and fronted by a
CDN that may prepend its own content-signal block to `robots.txt`. The repository file stays the
source of truth.
- The service worker precaches only `assets/*`; the discovery files are deliberately not cached.

## Non-goals

- Changing the panel's design, copy or routing.
- Per-route metadata: the panel has a single public entry URL.
12 changes: 12 additions & 0 deletions specs/next-seo-discoverability/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# next-seo-discoverability — Tasks

| ID | Task | Label | Done when |
| :--- | :--- | :--- | :--- |
| T-SEO-1 | `SeoDiscoverabilityTests` first | `[A]` | Done: red on the unmodified page (8 failures), then green |
| T-SEO-2 | Head metadata, JSON-LD, `robots.txt`, `sitemap.xml`, `llms.txt` | `[A]` | Done: focused suite green in Release |
| T-SEO-3 | Submit the sitemap in Search Console and Bing Webmaster Tools | `[H]` | Owner action after merge; needs the owner's accounts |

## Handoff

Verified: focused tests green (32/32 including the PWA and order-flow suites). Not verified: the
live host, which only changes after the owner merges and the Pages deploy runs.
Loading