-
Notifications
You must be signed in to change notification settings - Fork 1
Description
This issue proposes an API that allows querying health information for Diamond or 0xd14
.
Architecture
---
title: Architecture Diagram
---
%%{
init: {
"theme": "neutral",
"fontFamily": "monospace",
"flowchart": {
"defaultRenderer": "elk"
}
}
}%%
flowchart LR
subgraph Server["Backend Server"]
api("API Backend")
vic("VictoriaMetrics")
caddy("Caddy")
end
subgraph Desktop["Desktop"]
db("GadgetBridge DB")
subgraph Telegraf
in("GadgetBridge Input")
end
end
subgraph S3["Phone"]
gg("GadgetBridge")
fs("FolderSync")
end
fossil["Smartwatch"]
fossil --> gg
gg --- fs
fs --> db
db --> in
in --> vic
api --- vic
api --> caddy
caddy --> Public["Public View"]
Database Ingestor
Currently, Diamond wears a Fossil hybrid smartwatch paired to its phone using Gadgetbridge, which automatically exports a SQLite database hourly into a folder that is then synced via FolderSync to its desktop. A service (named Database Ingestor) should be created to export data from this database to an external database server.
This service should do ensure that the VictoriaMetrics database is up to date with the local SQLite database. Note that VictoriaMetrics loads its data using the InfluxDB API.
The backend can then simply consume the VictoriaMetrics database and render a JSON containing the health data that is useful for client consumption.
Backend Server
This proposal indirectly proposes a new microservice-architecture backend for serving the API. Its code shall live in /backend
.
Backend Endpoint
The backend's base endpoint is https://libdb.so/api/
. Components become part of the backend API with the URL https://libdb.so/api/<component>[/<version>]
. Note that the version path is optional but is strongly recommended.
API Specs
The API specification must eventually be declared using OpenAPI.
/api/health/v1
- the base endpointGET /api/health/v1/latest.json
- the latest health data in JSON, schema yet to be defined
/api/_all.json
- pseudo-endpoint that fetches all data locally then returns it to avoid roundtrip timeGET /api/_all.json
- the above data.
Action Items
- Initialize backend boilerplate code and build outputs
- Write up OpenAPI schema for API
- Set up backend infrastructure on server
- Set up VictoriaMetrics infrastructure on server
- Implement database ingestor service
- Deploy database ingestor service on desktop
- Publish OpenAPI documentation at
/api/docs
.