Skip to content

Commit

Permalink
Shorten architecture docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rogup committed Oct 28, 2024
1 parent 503e9b0 commit 9cb4853
Showing 1 changed file with 2 additions and 59 deletions.
61 changes: 2 additions & 59 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,71 +45,14 @@ in the UI, including the vocabs (translations of data IDs), default sidebar pane
appearance. This config is not generated into the above folder structure, but kept in source control
in the `@mykomap/config` library.

### Example file contents

`locations.json`:

```
[ [1.21419, 50.45254], [0.21002, 49.33954], … ]
```

`searchable.json`:

```
{
"fields": ["coun", "sz", "searchString"],
"values": [
["GB", "Small", "some co-op 2 green lane london n4 9qr"],
["GB", "Large", "another co-op 15 brown street sheffield s7 0hg"],
...
]
}
```
See the [`back-end test data`](https://github.com/DigitalCommons/mykomap-monolith/tree/main/apps/back-end/test/data/) for example file contents.

#### Potential optimisation:

Since there will be one row per item, with 100k items, every 10 characters adds a new megabyte. The really bulky bit is the text searchString part, so maybe it could be kept in its own plain text file, with one line per item. Searching it could be done by streaming it from disk, which avoids loading the entire file permanently into memory (for each dataset).
The `searchable.json` will be loaded into the back-end server's memory. Since there will be one row per item, with 100k items, every 10 characters adds a new megabyte. The really bulky bit is the text searchString part, so maybe it could be kept in its own plain text file, with one line per item. Searching it could be done by streaming it from disk, which avoids loading the entire file permanently into memory (for each dataset).

For instance, this [SO thread](https://stackoverflow.com/questions/20187145/how-to-search-stream-for-string-in-node-js) has some sample stream-searching code, and a reference to a module which performs the streaming by what appears to be a fast non-buffering algorithm.

`0.json`:

```
{ name: "Some Co-op", "desc": "A co-op that sells stuff", "lng": 1.21419, "lat": 50.45254, "coun": "GB", "sz": "Small", ... }
```

`config.json`:

```
{
"prefixes": {
"https://example.com/sizes/1.1/": "sz",
...
},
"vocabs": {
"sz": {
"EN": {
"title": "Sizes",
"terms": {
"large": "Large",
"medium": "Medium",
"small": "Small"
}
}
},
...
},
"popupFields": {
"sz": "text",
"websites": "clickable-list",
...
},
"ui": { ... },
...
}
```

### Data generation

These directories of JSONs, including the searchable strings in the `searchable.json` files, need to be pre-generated by a script. This script will be written in JS/TS and live in the monorepo, to be run on the back-end server.
Expand Down

0 comments on commit 9cb4853

Please sign in to comment.