Skip to content

Commit 03519bc

Browse files
committed
docs: add architecture and a prop drilling adr
1 parent 0d1d566 commit 03519bc

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ yarn test
5050

5151
## Contributing
5252

53+
We have some [architecture documentation](./docs/architecture.md) to help you get the lay of the land.
5354
We use Github [Pull Requests](https://github.com/developmentseed/stac-map/pulls) to propose changes, and [Issues](https://github.com/developmentseed/stac-map/issues) to report bugs and request features.
5455

5556
We use [semantic-release](https://github.com/semantic-release/semantic-release?tab=readme-ov-file) to create [releases](https://github.com/developmentseed/stac-map/releases).

docs/architecture.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Architecture
2+
3+
What follows is some light documentation on how **stac-map** is built.
4+
5+
## Core concepts
6+
7+
Here's the two core concepts of **stac-map**.
8+
9+
### Everything starts with the `href`
10+
11+
**stac-map** is driven by one (and only one) `href` value, which is a URI to a remote file _or_ the name of an uploaded file.
12+
The `href` is stored in the app state and is synchronized with a URL parameter, which allows the sharing of links to **stac-map** pointed at a specific STAC value.
13+
14+
### The value could be (almost) anything
15+
16+
Once the `href` is set, the data at the `href` is loaded into the app as a single `value`.
17+
The `value` could be:
18+
19+
- A STAC [Catalog](https://github.com/radiantearth/stac-spec/blob/master/catalog-spec/catalog-spec.md), [Collection](https://github.com/radiantearth/stac-spec/blob/master/collection-spec/collection-spec.md), or [Item](https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md)
20+
- A STAC [API](https://github.com/radiantearth/stac-api-spec)
21+
- A GeoJSON [FeatureCollection](https://datatracker.ietf.org/doc/html/rfc7946#section-3.3) with STAC Items as its `features` (commonly referred to as an `ItemCollection`, though no such term exists in the STAC specification)
22+
- A [stac-geoparquet](https://github.com/stac-utils/stac-geoparquet) file, which is treated as an `ItemCollection`.
23+
24+
The behaviors of the app are then driven by the attributes of the `value`.
25+
26+
## Concept diagram
27+
28+
Any values that don't have a parent are set by the user, either directly (e.g. `href`) or by interacting with the app (e.g. `bbox`).
29+
30+
```mermaid
31+
flowchart TD
32+
h[href] --> value;
33+
value --> catalogs;
34+
value --> collections;
35+
collections --> filteredCollections;
36+
bbox --> filteredCollections;
37+
datetimeBounds --> filteredCollections;
38+
value --> linkedItems;
39+
linkedItems -- if no user items --> items;
40+
search --> userItems;
41+
userItems --> items;
42+
items --> filteredItems;
43+
bbox --> filteredItems;
44+
datetimeBounds --> filteredItems;
45+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Drill the props
2+
3+
## Context and Problem Statement
4+
5+
There's a lot of state that we need to synchronize between the map and the rest of the application.
6+
7+
## Considered Options
8+
9+
- Use a custom context and provider
10+
- Use dispatch
11+
- Use a state management framework
12+
- Just [prop drill](https://react.dev/learn/passing-data-deeply-with-context#the-problem-with-passing-props)
13+
14+
## Decision Outcome
15+
16+
We tried both dispatch and a custom context, and while both were fine, they felt complicated to manage as the app changed state.
17+
We rejected a state management framework as "too heavy" for this simple of an app.
18+
As of v0.7, we went back to prop drilling.
19+
20+
### Consequences
21+
22+
- Good, because it encourages us to have a flatter, simpler component hierarchy
23+
- Bad, because it leads to components with _lots_ of props at a high level

0 commit comments

Comments
 (0)