Skip to content

Commit a93b27c

Browse files
committed
docs: start architecture decision log and add ADR for fetch library decision
1 parent 4ad048d commit a93b27c

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Use Markdown Architectural Decision Records
2+
3+
## Context and Problem Statement
4+
5+
We want to record architectural decisions made in this project independent whether decisions concern the architecture ("architectural decision record"), the code, or other fields.
6+
Which format and structure should these records follow?
7+
8+
## Considered Options
9+
10+
- [MADR](https://adr.github.io/madr/) 4.0.0 – The Markdown Architectural Decision Records
11+
- [Michael Nygard's template](http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions) – The first incarnation of the term "ADR"
12+
- [Sustainable Architectural Decisions](https://www.infoq.com/articles/sustainable-architectural-design-decisions) – The Y-Statements
13+
- Other templates listed at <https://github.com/joelparkerhenderson/architecture_decision_record>
14+
- Formless – No conventions for file format and structure
15+
16+
## Decision Outcome
17+
18+
Chosen option: "MADR 4.0.0", because
19+
20+
- Implicit assumptions should be made explicit.
21+
Design documentation is important to enable people understanding the decisions later on.
22+
See also ["A rational design process: How and why to fake it"](https://doi.org/10.1109/TSE.1986.6312940).
23+
- MADR allows for structured capturing of any decision.
24+
- The MADR format is lean and fits our development style.
25+
- The MADR structure is comprehensible and facilitates usage & maintenance.
26+
- The MADR project is vivid.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
# These are optional metadata elements. Feel free to remove any of them.
3+
status: "accepted"
4+
date: 2025-09-18
5+
decision-makers: @gadomski @AliceR
6+
---
7+
8+
# Use a fetch library for caching
9+
10+
## Context and Problem Statement
11+
12+
Currently, `stac-react` uses the native `fetch` API for all STAC requests, with no built-in caching or request deduplication. As the library is intended for use in applications that may navigate between many STAC resources, efficient caching and request management are important for performance and developer experience.
13+
14+
## Decision Drivers
15+
16+
- Improve performance by caching repeated requests.
17+
- Reduce network usage and latency.
18+
- Provide a more robust API for request state, error handling, and background updates.
19+
- Align with common React ecosystem practices.
20+
21+
## Considered Options
22+
23+
- Continue using native `fetch` with custom caching logic.
24+
- Use TanStack Query (`@tanstack/react-query`) for fetching and caching.
25+
- Use another fetch/caching library (e.g., SWR, Axios with custom cache).
26+
27+
## Decision Outcome
28+
29+
**Chosen option:** Use TanStack Query (`@tanstack/react-query`).
30+
31+
**Justification:**
32+
TanStack Query is widely adopted, well-documented, and provides robust caching, request deduplication, background refetching, and React integration. It will make `stac-react` more attractive to downstream applications and reduce the need for custom caching logic.
33+
34+
### Consequences
35+
36+
- **Good:** Improved performance and developer experience; less custom code for caching and request state.
37+
- **Bad:** Adds a new dependency and requires refactoring existing hooks to use TanStack Query.
38+
39+
### Confirmation
40+
41+
- Implementation will be confirmed by refactoring hooks to use TanStack Query and verifying caching behavior in tests and example app.
42+
- Code review will ensure correct usage and integration.
43+
44+
## Pros and Cons of the Options
45+
46+
### TanStack Query
47+
48+
- **Good:** Robust caching, request deduplication, background updates, React integration.
49+
- **Good:** Well-supported and documented.
50+
- **Neutral:** Adds a dependency, but it is widely used.
51+
- **Bad:** Requires refactoring and learning curve for maintainers.
52+
53+
### Native Fetch
54+
55+
- **Good:** No new dependencies.
56+
- **Bad:** No built-in caching, more custom code required, less robust for complex scenarios.
57+
58+
### Other Libraries (SWR, Axios)
59+
60+
- **Good:** Some provide caching, but less feature-rich or less adopted for React.
61+
- **Bad:** May require more custom integration.
62+
63+
## More Information
64+
65+
- [TanStack Query documentation](https://tanstack.com/query/latest/docs/framework/react/overview)
66+
- This ADR will be revisited if TanStack Query no longer meets project needs or if a better alternative emerges.

0 commit comments

Comments
 (0)