Commit 4139cb4
authored
feat: Add /catalogs route for Federated STAC API Support (#547)
**Related Issue(s):**
- #520
- #308
- radiantearth/stac-api-spec#239
- radiantearth/stac-api-spec#329
-
stac-api-extensions/stac-api-extensions.github.io#7
- https://github.com/Healy-Hyperspatial/stac-api-extensions-catalogs
#### Description
This PR introduces the **Catalogs Extension**, enabling a federated "Hub
and Spoke" architecture within `stac-fastapi`.
Currently, the API assumes a single Root Catalog containing a flat list
of Collections. This works for simple deployments but becomes unwieldy
for large-scale implementations aggregating multiple providers,
missions, or projects. This change adds a `/catalogs` endpoint that acts
as a **Registry**, allowing the API to serve multiple distinct
sub-catalogs from a single infrastructure.
#### Key Features
* **New Endpoints:** Implements the full suite of hierarchical
endpoints:
* `GET /catalogs` (List all sub-catalogs)
* `POST /catalogs` (Create new sub-catalog)
* `DELETE /catalogs/{catalog_id}` (Delete a catalog (supports
?cascade=true to delete child collections))
* `GET /catalogs/{catalog_id}` (Sub-catalog Landing Page)
* `GET /catalogs/{catalog_id}/collections` (Scoped collections)
* `POST /catalogs/{catalog_id}/collections` (Create a new collection
directly linked to a specific catalog)
* `GET /catalogs/{catalog_id}/collections/{collection_id}` (Get one
collection)
* `GET /catalogs/{catalog_id}/collections/{collection_id}/items` (Scoped
item search)
* `GET
/catalogs/{catalog_id}/collections/{collection_id}/items/{item_id}` (Get
one item)
* **Serialization:** Updates Pydantic models and serializers to support
`type: "Catalog"` objects within the API tree (previously restricted to
Collections).
* **Configuration:** Controlled via `ENABLE_CATALOGS_ROUTE` environment
variable (default: `false`).
#### Storage Strategy (Non-Breaking)
To ensure **zero breaking changes** and avoid complex database
migrations, this implementation stores `Catalog` objects within the
existing `collections` index.
* **Differentiation:** Objects are distinguished using the `type` field
(`type: "Catalog"` vs. `type: "Collection"`).
* **Backward Compatibility:** Existing queries for Collections remain
unaffected as they continue to function on the same index structure.
* **No Overhead:** No new Elasticsearch/OpenSearch indices or
infrastructure changes are required to enable this feature.
#### Architectural Alignment
This implementation follows the proposed **[STAC API Catalogs Endpoint
Extension](https://github.com/Healy-Hyperspatial/stac-api-extensions-catalogs-endpoint)**
(Community Extension).
It addresses the "Data Silo" problem by allowing organizations to host
distinct catalogs on a single API instance, rather than deploying
separate containers for every project or provider.
#### Changes
* `stac_fastapi/core/extensions/catalogs.py`: Added the main extension
logic and router.
* `stac_fastapi/core/models/`: Added `Catalog` Pydantic models.
* `stac_fastapi/elasticsearch/database_logic.py`: Added CRUD logic
filtering by `type: "Catalog"`.
* `tests/`: Added comprehensive test suite (`test_catalogs.py`) covering
CRUD operations and hierarchical navigation.
**PR Checklist:**
- [x] Code is formatted and linted (run `pre-commit run --all-files`)
- [x] Tests pass (run `make test`)
- [x] Documentation has been updated to reflect changes, if applicable
- [x] Changes are added to the changelog1 parent f99c6e6 commit 4139cb4
File tree
17 files changed
+2099
-5
lines changed- stac_fastapi
- core/stac_fastapi/core
- extensions
- models
- elasticsearch/stac_fastapi/elasticsearch
- opensearch/stac_fastapi/opensearch
- tests
- api
- data
- extensions
17 files changed
+2099
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
168 | 169 | | |
169 | 170 | | |
170 | 171 | | |
| 172 | + | |
| 173 | + | |
171 | 174 | | |
172 | 175 | | |
173 | 176 | | |
| |||
227 | 230 | | |
228 | 231 | | |
229 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
230 | 323 | | |
231 | 324 | | |
232 | 325 | | |
| |||
360 | 453 | | |
361 | 454 | | |
362 | 455 | | |
| 456 | + | |
363 | 457 | | |
364 | 458 | | |
365 | 459 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
28 | 32 | | |
29 | 33 | | |
30 | 34 | | |
| |||
81 | 85 | | |
82 | 86 | | |
83 | 87 | | |
| 88 | + | |
84 | 89 | | |
85 | 90 | | |
86 | 91 | | |
87 | 92 | | |
88 | 93 | | |
89 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
90 | 106 | | |
91 | 107 | | |
92 | 108 | | |
| |||
150 | 166 | | |
151 | 167 | | |
152 | 168 | | |
| 169 | + | |
153 | 170 | | |
154 | 171 | | |
155 | 172 | | |
| |||
207 | 224 | | |
208 | 225 | | |
209 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
210 | 237 | | |
211 | 238 | | |
212 | 239 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
11 | 13 | | |
0 commit comments