makerundev-server 0.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- makerundev_server-0.6.0/LICENSE +202 -0
- makerundev_server-0.6.0/PKG-INFO +146 -0
- makerundev_server-0.6.0/README.md +117 -0
- makerundev_server-0.6.0/pyproject.toml +50 -0
- makerundev_server-0.6.0/pyproject.toml.orig +41 -0
- makerundev_server-0.6.0/src/makerundev_server/__init__.py +3 -0
- makerundev_server-0.6.0/src/makerundev_server/app.py +399 -0
- makerundev_server-0.6.0/src/makerundev_server/charts.py +197 -0
- makerundev_server-0.6.0/src/makerundev_server/config.py +26 -0
- makerundev_server-0.6.0/src/makerundev_server/cross_site.py +33 -0
- makerundev_server-0.6.0/src/makerundev_server/db.py +144 -0
- makerundev_server-0.6.0/src/makerundev_server/garmin.py +148 -0
- makerundev_server-0.6.0/src/makerundev_server/garmin_store.py +129 -0
- makerundev_server-0.6.0/src/makerundev_server/garmin_sync.py +182 -0
- makerundev_server-0.6.0/src/makerundev_server/main.py +12 -0
- makerundev_server-0.6.0/src/makerundev_server/matching.py +35 -0
- makerundev_server-0.6.0/src/makerundev_server/migrations/env.py +36 -0
- makerundev_server-0.6.0/src/makerundev_server/migrations/script.py.mako +15 -0
- makerundev_server-0.6.0/src/makerundev_server/migrations/versions/0001_activities.py +36 -0
- makerundev_server-0.6.0/src/makerundev_server/migrations/versions/0002_athlete_settings.py +31 -0
- makerundev_server-0.6.0/src/makerundev_server/migrations/versions/0003_activity_identity.py +36 -0
- makerundev_server-0.6.0/src/makerundev_server/migrations/versions/0004_strava_connection.py +33 -0
- makerundev_server-0.6.0/src/makerundev_server/migrations/versions/0005_activity_laps.py +17 -0
- makerundev_server-0.6.0/src/makerundev_server/migrations/versions/0006_garmin_connection.py +32 -0
- makerundev_server-0.6.0/src/makerundev_server/settings.py +129 -0
- makerundev_server-0.6.0/src/makerundev_server/static/apple-touch-icon.png +0 -0
- makerundev_server-0.6.0/src/makerundev_server/static/favicon-dark.png +0 -0
- makerundev_server-0.6.0/src/makerundev_server/static/favicon-light.png +0 -0
- makerundev_server-0.6.0/src/makerundev_server/static/style.css +198 -0
- makerundev_server-0.6.0/src/makerundev_server/store.py +464 -0
- makerundev_server-0.6.0/src/makerundev_server/strava.py +171 -0
- makerundev_server-0.6.0/src/makerundev_server/sync.py +124 -0
- makerundev_server-0.6.0/src/makerundev_server/sync_state.py +57 -0
- makerundev_server-0.6.0/src/makerundev_server/templates/activity.html +111 -0
- makerundev_server-0.6.0/src/makerundev_server/templates/base.html +22 -0
- makerundev_server-0.6.0/src/makerundev_server/templates/garmin.html +76 -0
- makerundev_server-0.6.0/src/makerundev_server/templates/index.html +48 -0
- makerundev_server-0.6.0/src/makerundev_server/templates/load.html +81 -0
- makerundev_server-0.6.0/src/makerundev_server/templates/settings.html +59 -0
- makerundev_server-0.6.0/src/makerundev_server/templates/strava.html +75 -0
- makerundev_server-0.6.0/src/makerundev_server/training.py +69 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: makerundev-server
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Self-hosted web app for your running data, built on makerundev.
|
|
5
|
+
Keywords: running,fit,gpx,tcx,garmin,strava,training-load,self-hosted
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
9
|
+
Classifier: Environment :: Web Environment
|
|
10
|
+
Classifier: Framework :: FastAPI
|
|
11
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
14
|
+
Requires-Dist: makerundev==0.6.0
|
|
15
|
+
Requires-Dist: alembic>=1.20.1
|
|
16
|
+
Requires-Dist: fastapi>=0.165
|
|
17
|
+
Requires-Dist: jinja2>=3.1.6
|
|
18
|
+
Requires-Dist: python-multipart>=0.0.34
|
|
19
|
+
Requires-Dist: sqlalchemy>=2.1
|
|
20
|
+
Requires-Dist: tzdata>=2025.2
|
|
21
|
+
Requires-Dist: uvicorn>=0.54
|
|
22
|
+
Requires-Dist: httpx2>=2.16
|
|
23
|
+
Requires-Python: >=3.12
|
|
24
|
+
Project-URL: Homepage, https://github.com/tanhtruong/makerundev
|
|
25
|
+
Project-URL: Documentation, https://github.com/tanhtruong/makerundev/tree/main/apps/server#readme
|
|
26
|
+
Project-URL: Issues, https://github.com/tanhtruong/makerundev/issues
|
|
27
|
+
Project-URL: Source, https://github.com/tanhtruong/makerundev
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# makerundev-server
|
|
31
|
+
|
|
32
|
+
A self-hosted web app for your running data, built on the [`makerundev`](https://pypi.org/project/makerundev/) library. Import FIT, GPX and TCX files, browse your activities and see pace, heart-rate and elevation charts, time in heart-rate zones and training load. Everything stays on your machine: there are no accounts, no external services and no CDN assets.
|
|
33
|
+
|
|
34
|
+
## Run it
|
|
35
|
+
|
|
36
|
+
With [uv](https://docs.astral.sh/uv/), straight from PyPI:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
uvx makerundev-server
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Then open http://127.0.0.1:8000. The database and your files are kept in `data/` under the folder you start it from, so start it from the same folder next time or set `MAKERUNDEV_DATA_DIR`. `pip install makerundev-server` installs the same `makerundev-server` command.
|
|
43
|
+
|
|
44
|
+
With Docker, from the image published with each release:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
docker run --name makerundev -p 127.0.0.1:8000:8000 -v makerundev-data:/data ghcr.io/tanhtruong/makerundev-server
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
From a clone of the repository, to work on it:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
uv sync
|
|
54
|
+
uv run makerundev-server
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`docker compose up` in the clone builds the image from the checkout instead.
|
|
58
|
+
|
|
59
|
+
## Configuration
|
|
60
|
+
|
|
61
|
+
| Variable | Default | What it does |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| `MAKERUNDEV_DATA_DIR` | `./data` (`/data` in the image) | Where the database and imported files are kept |
|
|
64
|
+
| `MAKERUNDEV_HOST` | `127.0.0.1` (`0.0.0.0` in the image) | Address to listen on |
|
|
65
|
+
| `MAKERUNDEV_PORT` | `8000` | Port to listen on |
|
|
66
|
+
| `MAKERUNDEV_STRAVA_CLIENT_ID` | unset | Client id of your own Strava API application; enables [Strava sync](#strava-sync) |
|
|
67
|
+
| `MAKERUNDEV_STRAVA_CLIENT_SECRET` | unset | Its client secret |
|
|
68
|
+
|
|
69
|
+
The project was called pacelab up to 0.2.0. `PACELAB_DATA_DIR`, `PACELAB_HOST` and `PACELAB_PORT` are still read when the `MAKERUNDEV_` variable is not set. The image sets all three `MAKERUNDEV_` variables, so override those there.
|
|
70
|
+
|
|
71
|
+
There is no login. Keep the app on `127.0.0.1` or behind a reverse proxy that adds authentication; the bundled `compose.yml` only publishes the port on localhost.
|
|
72
|
+
|
|
73
|
+
So that another website cannot make your browser change anything here, every request other than `GET`, `HEAD` and `OPTIONS` is refused with 403 when the browser marks it as coming from another site (`Sec-Fetch-Site` other than `same-origin` or `none`), or, from a browser that does not send that header, when its `Origin` names a different host and port than the request's `Host`. A request with neither header, such as one from curl or a script, goes through. Behind a reverse proxy, make sure it passes the original `Host` header.
|
|
74
|
+
|
|
75
|
+
## Data
|
|
76
|
+
|
|
77
|
+
The data directory holds:
|
|
78
|
+
|
|
79
|
+
- `makerundev.db` - a SQLite database with one row per activity and its summary, your athlete settings, and your Strava tokens, Garmin key and sync progress once connected. A data directory created under the old name keeps its `pacelab.db`, which is used as it is. The app upgrades it to the latest schema on startup, so a newer version can open an older data directory, but not the other way round.
|
|
80
|
+
- `originals/` - each imported file as uploaded (for a ZIP, the file inside), named by its SHA-256, and each synced Strava activity's stream as gzipped JSON, named `strava-<id>`
|
|
81
|
+
- `streams/` - the normalised record stream of each activity as Parquet
|
|
82
|
+
|
|
83
|
+
Importing the same file twice is detected by its hash and skipped. Uploads are capped at 64 MB per file. To back up, copy the whole directory; with Docker, `docker cp makerundev:/data ./makerundev-backup` (`docker compose cp` from a clone).
|
|
84
|
+
|
|
85
|
+
## Strava sync
|
|
86
|
+
|
|
87
|
+
Create a Strava API application under [Settings → My API Application](https://www.strava.com/settings/api), set its **Authorization Callback Domain** to the host you open the app on (`127.0.0.1` and `localhost` are always allowed by Strava), and start the app with `MAKERUNDEV_STRAVA_CLIENT_ID` and `MAKERUNDEV_STRAVA_CLIENT_SECRET`. The **Strava** page then offers **Connect with Strava** and **Sync now**. Behind a reverse proxy, make sure it passes the original host and scheme, because the OAuth redirect address is built from the request.
|
|
88
|
+
|
|
89
|
+
- **What a sync does.** It fetches activities newer than the newest one synced, then continues back through your history, newest first, with one request per activity for its streams. It runs in the background; the page refreshes while it does.
|
|
90
|
+
- **Rate limits.** Strava allows a new application 100 read requests per 15 minutes and 1,000 per day. A sync stops before either runs out and the next one continues where it stopped.
|
|
91
|
+
- **Files win.** A Strava activity is matched to one you imported from a file by the Strava id in a bulk-export filename, or by starting within 60 s and covering the same distance within 5% or 200 m, whichever is larger. The file's data is kept and gains a "View on Strava" link. Importing the file after a sync replaces the synced stream.
|
|
92
|
+
- **What is not synced.** Activities without streams, such as manual entries, are listed on the page and not tried again. The device name is not fetched. Edits and deletions made on Strava after an activity was synced are not picked up.
|
|
93
|
+
- **Disconnect.** Revokes the app's access and deletes the tokens and every activity that came only from Strava. Activities matched to a file stay.
|
|
94
|
+
- **Tokens.** They are stored unencrypted in the database in your data directory, and nowhere else.
|
|
95
|
+
|
|
96
|
+
## Garmin sync
|
|
97
|
+
|
|
98
|
+
Create a Personal API key in Garmin Connect on the web under **Settings → Personal API Key**, open the **Garmin** page and paste it. Saving exchanges the key for a 24-hour token at once, so a mistyped or expired key is turned away before it is stored. The page then offers **Sync now**.
|
|
99
|
+
|
|
100
|
+
- **What a sync does.** It fetches activities newer than the newest one synced, then continues back through your history, newest first. It walks Garmin's list by date window, not by position, so activities added or deleted on Garmin during a sync do not make it skip others. Each activity's original file is downloaded and imported exactly like an upload: a ZIP is stored as the file inside, under its own name, and deduplicated by its SHA-256. A file whose name would be all digits is stored as `garmin-<id>.<ext>`, so it is never mistaken for a Strava id. It runs in the background; the page refreshes while it does.
|
|
101
|
+
- **Pacing.** Garmin publishes no rate limits, so a sync waits a second between requests and stops when Garmin answers 429, saying when to try again if Garmin does. The next sync continues where it stopped.
|
|
102
|
+
- **Already here.** An activity that starts within 60 s of one you already have from a file, and covers the same distance within 5% or 200 m, is not downloaded. One that came only from Strava is replaced by the Garmin file, which keeps the Strava link.
|
|
103
|
+
- **What is not synced.** Manual entries have no file, and a download that cannot be read, such as a multi-sport ZIP holding several files or a file not sent as a ZIP, is skipped. Both are listed on the page and not tried again. Edits and deletions made on Garmin Connect after a sync are not picked up.
|
|
104
|
+
- **An expired key.** Keys last 30 to 365 days. When Garmin stops accepting yours, the sync stops and the page explains how to create a new one; paste it in and sync again.
|
|
105
|
+
- **Remove key.** Deletes the key, the token and the sync progress. Activities imported from Garmin stay, because they are ordinary files.
|
|
106
|
+
- **The key.** It is stored unencrypted in the database in your data directory, and nowhere else. It is never shown on a page.
|
|
107
|
+
|
|
108
|
+
## Routes
|
|
109
|
+
|
|
110
|
+
| Method and path | What it returns |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| `GET /` | Activity list and import form |
|
|
113
|
+
| `POST /activities` | Import one or more files (multipart field `files`) |
|
|
114
|
+
| `GET /activities/{id}` | Activity page with charts, best efforts, time in zones and TRIMP |
|
|
115
|
+
| `GET /load?days=90\|180\|365\|all` | Fitness, fatigue and form from daily TRIMP (default 180 days) |
|
|
116
|
+
| `GET /settings` | Athlete settings form |
|
|
117
|
+
| `POST /settings` | Save athlete settings and recompute TRIMP if needed |
|
|
118
|
+
| `GET /strava` | Strava connection, sync status and skipped activities |
|
|
119
|
+
| `POST /strava/connect` | Start connecting: redirects to Strava's authorisation page |
|
|
120
|
+
| `GET /strava/callback` | Where Strava sends you back after authorising |
|
|
121
|
+
| `POST /strava/sync` | Start a sync in the background |
|
|
122
|
+
| `POST /strava/disconnect` | Revoke access and delete Strava-only activities |
|
|
123
|
+
| `GET /garmin` | Garmin key form, sync status and skipped activities |
|
|
124
|
+
| `POST /garmin/key` | Check a Personal API key with Garmin and save it (form field `key`) |
|
|
125
|
+
| `POST /garmin/sync` | Start a sync in the background |
|
|
126
|
+
| `POST /garmin/remove` | Delete the key and sync progress; imported activities stay |
|
|
127
|
+
| `GET /api/activities` | All activities with their summaries and TRIMP, as JSON |
|
|
128
|
+
| `GET /api/activities/{id}/records` | The activity's record stream, as JSON |
|
|
129
|
+
|
|
130
|
+
## Development
|
|
131
|
+
|
|
132
|
+
The app is FastAPI with Jinja templates and inline SVG charts; there is no front-end build step. `make check` at the repository root runs its tests along with the library's. See [CONTRIBUTING.md](https://github.com/tanhtruong/makerundev/blob/main/CONTRIBUTING.md) and [ADR 4](https://github.com/tanhtruong/makerundev/blob/main/docs/adr/0004-server-rendered-self-hosted-app.md).
|
|
133
|
+
|
|
134
|
+
### Changing the database schema
|
|
135
|
+
|
|
136
|
+
The schema is managed by Alembic migrations in `src/makerundev_server/migrations/versions/`, numbered `0001`, `0002`, and so on. After changing the models in `db.py`, from `apps/server`:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
MAKERUNDEV_DATA_DIR=/tmp/makerundev-dev uv run alembic upgrade head
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
MAKERUNDEV_DATA_DIR=/tmp/makerundev-dev uv run alembic revision --autogenerate --rev-id NNNN -m "describe the change"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`NNNN` is the next number after the newest file in `versions/`. Read the generated file before committing: autogenerate misses some changes, such as renames, and SQLite changes run in batch mode, which copies the table. `tests/test_migrations.py` fails while the models and the migrations disagree, and checks that a 0.1.0 database still upgrades.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# makerundev-server
|
|
2
|
+
|
|
3
|
+
A self-hosted web app for your running data, built on the [`makerundev`](https://pypi.org/project/makerundev/) library. Import FIT, GPX and TCX files, browse your activities and see pace, heart-rate and elevation charts, time in heart-rate zones and training load. Everything stays on your machine: there are no accounts, no external services and no CDN assets.
|
|
4
|
+
|
|
5
|
+
## Run it
|
|
6
|
+
|
|
7
|
+
With [uv](https://docs.astral.sh/uv/), straight from PyPI:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
uvx makerundev-server
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then open http://127.0.0.1:8000. The database and your files are kept in `data/` under the folder you start it from, so start it from the same folder next time or set `MAKERUNDEV_DATA_DIR`. `pip install makerundev-server` installs the same `makerundev-server` command.
|
|
14
|
+
|
|
15
|
+
With Docker, from the image published with each release:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
docker run --name makerundev -p 127.0.0.1:8000:8000 -v makerundev-data:/data ghcr.io/tanhtruong/makerundev-server
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
From a clone of the repository, to work on it:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
uv sync
|
|
25
|
+
uv run makerundev-server
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`docker compose up` in the clone builds the image from the checkout instead.
|
|
29
|
+
|
|
30
|
+
## Configuration
|
|
31
|
+
|
|
32
|
+
| Variable | Default | What it does |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| `MAKERUNDEV_DATA_DIR` | `./data` (`/data` in the image) | Where the database and imported files are kept |
|
|
35
|
+
| `MAKERUNDEV_HOST` | `127.0.0.1` (`0.0.0.0` in the image) | Address to listen on |
|
|
36
|
+
| `MAKERUNDEV_PORT` | `8000` | Port to listen on |
|
|
37
|
+
| `MAKERUNDEV_STRAVA_CLIENT_ID` | unset | Client id of your own Strava API application; enables [Strava sync](#strava-sync) |
|
|
38
|
+
| `MAKERUNDEV_STRAVA_CLIENT_SECRET` | unset | Its client secret |
|
|
39
|
+
|
|
40
|
+
The project was called pacelab up to 0.2.0. `PACELAB_DATA_DIR`, `PACELAB_HOST` and `PACELAB_PORT` are still read when the `MAKERUNDEV_` variable is not set. The image sets all three `MAKERUNDEV_` variables, so override those there.
|
|
41
|
+
|
|
42
|
+
There is no login. Keep the app on `127.0.0.1` or behind a reverse proxy that adds authentication; the bundled `compose.yml` only publishes the port on localhost.
|
|
43
|
+
|
|
44
|
+
So that another website cannot make your browser change anything here, every request other than `GET`, `HEAD` and `OPTIONS` is refused with 403 when the browser marks it as coming from another site (`Sec-Fetch-Site` other than `same-origin` or `none`), or, from a browser that does not send that header, when its `Origin` names a different host and port than the request's `Host`. A request with neither header, such as one from curl or a script, goes through. Behind a reverse proxy, make sure it passes the original `Host` header.
|
|
45
|
+
|
|
46
|
+
## Data
|
|
47
|
+
|
|
48
|
+
The data directory holds:
|
|
49
|
+
|
|
50
|
+
- `makerundev.db` - a SQLite database with one row per activity and its summary, your athlete settings, and your Strava tokens, Garmin key and sync progress once connected. A data directory created under the old name keeps its `pacelab.db`, which is used as it is. The app upgrades it to the latest schema on startup, so a newer version can open an older data directory, but not the other way round.
|
|
51
|
+
- `originals/` - each imported file as uploaded (for a ZIP, the file inside), named by its SHA-256, and each synced Strava activity's stream as gzipped JSON, named `strava-<id>`
|
|
52
|
+
- `streams/` - the normalised record stream of each activity as Parquet
|
|
53
|
+
|
|
54
|
+
Importing the same file twice is detected by its hash and skipped. Uploads are capped at 64 MB per file. To back up, copy the whole directory; with Docker, `docker cp makerundev:/data ./makerundev-backup` (`docker compose cp` from a clone).
|
|
55
|
+
|
|
56
|
+
## Strava sync
|
|
57
|
+
|
|
58
|
+
Create a Strava API application under [Settings → My API Application](https://www.strava.com/settings/api), set its **Authorization Callback Domain** to the host you open the app on (`127.0.0.1` and `localhost` are always allowed by Strava), and start the app with `MAKERUNDEV_STRAVA_CLIENT_ID` and `MAKERUNDEV_STRAVA_CLIENT_SECRET`. The **Strava** page then offers **Connect with Strava** and **Sync now**. Behind a reverse proxy, make sure it passes the original host and scheme, because the OAuth redirect address is built from the request.
|
|
59
|
+
|
|
60
|
+
- **What a sync does.** It fetches activities newer than the newest one synced, then continues back through your history, newest first, with one request per activity for its streams. It runs in the background; the page refreshes while it does.
|
|
61
|
+
- **Rate limits.** Strava allows a new application 100 read requests per 15 minutes and 1,000 per day. A sync stops before either runs out and the next one continues where it stopped.
|
|
62
|
+
- **Files win.** A Strava activity is matched to one you imported from a file by the Strava id in a bulk-export filename, or by starting within 60 s and covering the same distance within 5% or 200 m, whichever is larger. The file's data is kept and gains a "View on Strava" link. Importing the file after a sync replaces the synced stream.
|
|
63
|
+
- **What is not synced.** Activities without streams, such as manual entries, are listed on the page and not tried again. The device name is not fetched. Edits and deletions made on Strava after an activity was synced are not picked up.
|
|
64
|
+
- **Disconnect.** Revokes the app's access and deletes the tokens and every activity that came only from Strava. Activities matched to a file stay.
|
|
65
|
+
- **Tokens.** They are stored unencrypted in the database in your data directory, and nowhere else.
|
|
66
|
+
|
|
67
|
+
## Garmin sync
|
|
68
|
+
|
|
69
|
+
Create a Personal API key in Garmin Connect on the web under **Settings → Personal API Key**, open the **Garmin** page and paste it. Saving exchanges the key for a 24-hour token at once, so a mistyped or expired key is turned away before it is stored. The page then offers **Sync now**.
|
|
70
|
+
|
|
71
|
+
- **What a sync does.** It fetches activities newer than the newest one synced, then continues back through your history, newest first. It walks Garmin's list by date window, not by position, so activities added or deleted on Garmin during a sync do not make it skip others. Each activity's original file is downloaded and imported exactly like an upload: a ZIP is stored as the file inside, under its own name, and deduplicated by its SHA-256. A file whose name would be all digits is stored as `garmin-<id>.<ext>`, so it is never mistaken for a Strava id. It runs in the background; the page refreshes while it does.
|
|
72
|
+
- **Pacing.** Garmin publishes no rate limits, so a sync waits a second between requests and stops when Garmin answers 429, saying when to try again if Garmin does. The next sync continues where it stopped.
|
|
73
|
+
- **Already here.** An activity that starts within 60 s of one you already have from a file, and covers the same distance within 5% or 200 m, is not downloaded. One that came only from Strava is replaced by the Garmin file, which keeps the Strava link.
|
|
74
|
+
- **What is not synced.** Manual entries have no file, and a download that cannot be read, such as a multi-sport ZIP holding several files or a file not sent as a ZIP, is skipped. Both are listed on the page and not tried again. Edits and deletions made on Garmin Connect after a sync are not picked up.
|
|
75
|
+
- **An expired key.** Keys last 30 to 365 days. When Garmin stops accepting yours, the sync stops and the page explains how to create a new one; paste it in and sync again.
|
|
76
|
+
- **Remove key.** Deletes the key, the token and the sync progress. Activities imported from Garmin stay, because they are ordinary files.
|
|
77
|
+
- **The key.** It is stored unencrypted in the database in your data directory, and nowhere else. It is never shown on a page.
|
|
78
|
+
|
|
79
|
+
## Routes
|
|
80
|
+
|
|
81
|
+
| Method and path | What it returns |
|
|
82
|
+
| --- | --- |
|
|
83
|
+
| `GET /` | Activity list and import form |
|
|
84
|
+
| `POST /activities` | Import one or more files (multipart field `files`) |
|
|
85
|
+
| `GET /activities/{id}` | Activity page with charts, best efforts, time in zones and TRIMP |
|
|
86
|
+
| `GET /load?days=90\|180\|365\|all` | Fitness, fatigue and form from daily TRIMP (default 180 days) |
|
|
87
|
+
| `GET /settings` | Athlete settings form |
|
|
88
|
+
| `POST /settings` | Save athlete settings and recompute TRIMP if needed |
|
|
89
|
+
| `GET /strava` | Strava connection, sync status and skipped activities |
|
|
90
|
+
| `POST /strava/connect` | Start connecting: redirects to Strava's authorisation page |
|
|
91
|
+
| `GET /strava/callback` | Where Strava sends you back after authorising |
|
|
92
|
+
| `POST /strava/sync` | Start a sync in the background |
|
|
93
|
+
| `POST /strava/disconnect` | Revoke access and delete Strava-only activities |
|
|
94
|
+
| `GET /garmin` | Garmin key form, sync status and skipped activities |
|
|
95
|
+
| `POST /garmin/key` | Check a Personal API key with Garmin and save it (form field `key`) |
|
|
96
|
+
| `POST /garmin/sync` | Start a sync in the background |
|
|
97
|
+
| `POST /garmin/remove` | Delete the key and sync progress; imported activities stay |
|
|
98
|
+
| `GET /api/activities` | All activities with their summaries and TRIMP, as JSON |
|
|
99
|
+
| `GET /api/activities/{id}/records` | The activity's record stream, as JSON |
|
|
100
|
+
|
|
101
|
+
## Development
|
|
102
|
+
|
|
103
|
+
The app is FastAPI with Jinja templates and inline SVG charts; there is no front-end build step. `make check` at the repository root runs its tests along with the library's. See [CONTRIBUTING.md](https://github.com/tanhtruong/makerundev/blob/main/CONTRIBUTING.md) and [ADR 4](https://github.com/tanhtruong/makerundev/blob/main/docs/adr/0004-server-rendered-self-hosted-app.md).
|
|
104
|
+
|
|
105
|
+
### Changing the database schema
|
|
106
|
+
|
|
107
|
+
The schema is managed by Alembic migrations in `src/makerundev_server/migrations/versions/`, numbered `0001`, `0002`, and so on. After changing the models in `db.py`, from `apps/server`:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
MAKERUNDEV_DATA_DIR=/tmp/makerundev-dev uv run alembic upgrade head
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
MAKERUNDEV_DATA_DIR=/tmp/makerundev-dev uv run alembic revision --autogenerate --rev-id NNNN -m "describe the change"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`NNNN` is the next number after the newest file in `versions/`. Read the generated file before committing: autogenerate misses some changes, such as renames, and SQLite changes run in batch mode, which copies the table. `tests/test_migrations.py` fails while the models and the migrations disagree, and checks that a 0.1.0 database still upgrades.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "makerundev-server"
|
|
3
|
+
version = "0.6.0"
|
|
4
|
+
description = "Self-hosted web app for your running data, built on makerundev."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.12"
|
|
9
|
+
keywords = [
|
|
10
|
+
"running",
|
|
11
|
+
"fit",
|
|
12
|
+
"gpx",
|
|
13
|
+
"tcx",
|
|
14
|
+
"garmin",
|
|
15
|
+
"strava",
|
|
16
|
+
"training-load",
|
|
17
|
+
"self-hosted",
|
|
18
|
+
]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
21
|
+
"Environment :: Web Environment",
|
|
22
|
+
"Framework :: FastAPI",
|
|
23
|
+
"Intended Audience :: End Users/Desktop",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"makerundev==0.6.0",
|
|
29
|
+
"alembic>=1.20.1",
|
|
30
|
+
"fastapi>=0.165",
|
|
31
|
+
"jinja2>=3.1.6",
|
|
32
|
+
"python-multipart>=0.0.34",
|
|
33
|
+
"sqlalchemy>=2.1",
|
|
34
|
+
"tzdata>=2025.2",
|
|
35
|
+
"uvicorn>=0.54",
|
|
36
|
+
"httpx2>=2.16",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/tanhtruong/makerundev"
|
|
41
|
+
Documentation = "https://github.com/tanhtruong/makerundev/tree/main/apps/server#readme"
|
|
42
|
+
Issues = "https://github.com/tanhtruong/makerundev/issues"
|
|
43
|
+
Source = "https://github.com/tanhtruong/makerundev"
|
|
44
|
+
|
|
45
|
+
[project.scripts]
|
|
46
|
+
makerundev-server = "makerundev_server.main:run"
|
|
47
|
+
|
|
48
|
+
[build-system]
|
|
49
|
+
requires = ["uv_build>=0.13.8,<0.14"]
|
|
50
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "makerundev-server"
|
|
3
|
+
version = "0.6.0"
|
|
4
|
+
description = "Self-hosted web app for your running data, built on makerundev."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.12"
|
|
9
|
+
keywords = ["running", "fit", "gpx", "tcx", "garmin", "strava", "training-load", "self-hosted"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
12
|
+
"Environment :: Web Environment",
|
|
13
|
+
"Framework :: FastAPI",
|
|
14
|
+
"Intended Audience :: End Users/Desktop",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
17
|
+
]
|
|
18
|
+
dependencies = [
|
|
19
|
+
"makerundev==0.6.0",
|
|
20
|
+
"alembic>=1.20.1",
|
|
21
|
+
"fastapi>=0.165",
|
|
22
|
+
"jinja2>=3.1.6",
|
|
23
|
+
"python-multipart>=0.0.34",
|
|
24
|
+
"sqlalchemy>=2.1",
|
|
25
|
+
"tzdata>=2025.2",
|
|
26
|
+
"uvicorn>=0.54",
|
|
27
|
+
"httpx2>=2.16",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/tanhtruong/makerundev"
|
|
32
|
+
Documentation = "https://github.com/tanhtruong/makerundev/tree/main/apps/server#readme"
|
|
33
|
+
Issues = "https://github.com/tanhtruong/makerundev/issues"
|
|
34
|
+
Source = "https://github.com/tanhtruong/makerundev"
|
|
35
|
+
|
|
36
|
+
[project.scripts]
|
|
37
|
+
makerundev-server = "makerundev_server.main:run"
|
|
38
|
+
|
|
39
|
+
[build-system]
|
|
40
|
+
requires = ["uv_build>=0.13.8,<0.14"]
|
|
41
|
+
build-backend = "uv_build"
|