Skip to content

Commit 64a817e

Browse files
committed
[ADR] Web URL Structure Design as an Architectural Decision
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
1 parent 6f648a7 commit 64a817e

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

src/adrs/1760817947/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
id: '1760817947'
3+
title: Prefer Structured URLs Over Flat URLs
4+
state: Draft
5+
created: 2025-10-18
6+
tags: [url-design, architecture, performance, seo]
7+
category: Platform
8+
---
9+
10+
# Prefer Structured URLs Over Flat URLs
11+
12+
## Context
13+
14+
URL design is often treated as a purely aesthetic or SEO decision. Teams favor
15+
"clean" flat URLs like `/nike-air-zoom` over structured URLs like
16+
`/product/nike-air-zoom`. However, flat URLs have significant architectural
17+
costs that are often overlooked.
18+
19+
With flat URLs, applications cannot determine the entity type from the path
20+
alone, requiring resolution queries:
21+
22+
```javascript
23+
// Flat URL - requires resolution
24+
const slug = path.split('/')[1];
25+
26+
const product = await getProduct(slug);
27+
if (product) return renderProduct(product);
28+
29+
const category = await getCategory(slug);
30+
if (category) return renderCategory(category);
31+
32+
return render404();
33+
```
34+
35+
With structured URLs, routing is deterministic — no resolution needed:
36+
37+
```javascript
38+
// Structured URL - instant routing
39+
const prefix = path.split('/')[1]; // "product"
40+
// Route directly to product handler
41+
```
42+
43+
A case study documented the real-world impact: every page required 2 backend
44+
calls (one succeeds, one fails), 404s wasted 2 calls each, and infrastructure
45+
costs were 40% higher than projected.
46+
47+
Flat URLs also require enforcing slug uniqueness across all entity types at the
48+
database level — a product and category cannot share the same slug. Structured
49+
URLs allow independent namespaces per type.
50+
51+
## Resolution
52+
53+
- You **SHOULD** use structured/prefixed URLs for new projects (e.g., `/p/slug` or `/product/slug`).
54+
55+
## Links
56+
57+
- [The Hidden Cost of URL Design](https://alfy.blog/2025/10/16/hidden-cost-of-url-design.html) - Case study referenced in Context

src/adrs/4615273139/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ defmodule Umbrella.Web.Graphql.Schema do
136136
field :deposit_account, non_null(:deposit_account) do
137137
resolve &Query.DepositAccount.resolve/3
138138
end
139-
139+
140140
# Fields imported from banking_queries object
141141
import_fields(:banking_queries)
142142
end

0 commit comments

Comments
 (0)