diff --git a/README.md b/README.md index a6fbadae2..b8a2644c5 100644 --- a/README.md +++ b/README.md @@ -14,29 +14,14 @@ Endurain Screenshot -> [!WARNING] -> This project is currently in **Alpha** state. You can try it out at your own risk, but be aware that things might break and **DATA LOSS** may occur. - ## Table of Contents +- Endurain documentation - [What is Endurain?](#what-is-endurain) -- [Features](#features) -- [Planned Features](#planned-features) -- [Deployment Instructions](#deployment-instructions) -- [API Integration](#api-integration-v030) -- [Configuration](#configuration) - - [Frontend Environment Variables](#frontend-environment-variables) - - [Backend Environment Variables](#backend-environment-variables) -- [Volumes](#volumes) -- [Bulk import and file upload](#bulk-import-and-file-upload) -- [Strava Integration](#strava-integration) -- [Garmin Connect Integration](#garmin-connect-integration) -- [Log files](#log-files) - [Sponsors](#sponsors) - [Contributing](#contributing) - [License](#license) - [Help Translate](#help-translate) -- [Community & Support](#community--support) ## What is Endurain? @@ -49,157 +34,7 @@ Endurain is a self-hosted fitness tracking service designed to give users full c To deploy Endurain, Docker images are available, and a comprehensive example can be found in the "docker-compose.yml.example" file provided. Configuration is facilitated through environment variables, ensuring flexibility and ease of customization. More details bellow. -### Developer's Note - -As a non-professional developer, my journey with Endurain involved learning and implementing new technologies and concepts, with invaluable assistance from ChatGPT. The primary motivation behind this project was to gain hands-on experience and expand my understanding of modern development practices. Second motivation is that I'm an amateur triathlete and I want to keep track of my gear and gear components usage. - -If you have any recommendations or insights on improving any aspect of Endurain, whether related to technology choices, user experience, or any other relevant area, I would greatly appreciate your input. The goal is to create a reliable and user-friendly fitness tracking solution that caters to the needs of individuals who prefer self-hosted applications. Your constructive feedback will undoubtedly contribute to the refinement of Endurain. - -## Features - -Endurain currently supports: - -- Multi-user functionality -- Admin and user profiles with adaptable interfaces -- Activity import via manual or bulk upload (.gpx and .fit files) -- Strava integration for syncing activities and gear -- Garmin Connect integration for syncing activities -- Personalized activity feeds and statistics (week/month) -- Basic activity privacy settings -- Gear tracking (wetsuits, bicycles, shoes) -- User pages with stats and activity histories -- Follower features (view activities) -- Multi-language support (currently English only) -- Dark/light theme switcher -- Third-party app support -- Weight logging - -## Planned Features - -Upcoming features (in no particular order): - -- Simplified Docker images -- Live tracking -- Default gear for activity types -- Gear component tracking (e.g., track when components like bike chains need replacing) -- Activity comments and likes -- Notification system -- Potential ActivityPub integration - -## Deployment Instructions - -### Default Credentials - -- **Username:** admin -- **Password:** admin - -### Docker Deployment - -Endurain provides Docker images for simplified deployment. To get started, check out the `docker-compose.yml.example` file and adjust it according to your setup. -Supported tags are: -- **latest:** contains the latest released version; -- **version, example "v0.3.0":** contains the app state available at the time of the version specified; -- **development version, example "dev_06092024":** contains a development version of the app at the date specified. This is not a stable released and may contain issues and bugs. Please do not open issues if using a version like this unless asked by me. - -## API Integration (v0.3.0+) - -Endurain supports integration with other apps: - -- For **web apps**, the backend sends access/refresh tokens as HTTP-only cookies. -- For **mobile apps**, tokens are included in the response body. - -### API Requirements - -- **Add a header:** Every request must include an `X-Client-Type` header with either `web` or `mobile` as the value. Requests with other values will receive a `403` error. -- **Activity Upload:** Use the `/api/v1/activities/create/upload` endpoint (expects a .gpx or .fit file). - -## Configuration - -### Frontend Environment Variables -Table below shows supported environment variables. Variables marked with optional "No" should be set to avoid errors. - -| Environment variable | Default value | Optional | Notes | -| --- | --- | --- | --- | -| MY_APP_BACKEND_PROTOCOL | http | Yes | Needs to be `https` if you want to enable Strava integration. Strava callback relies on this. You may need to update this variable based on docker image spin up (api host or local ip (example: http://192.168.1.10:98)) | -| MY_APP_BACKEND_HOST | localhost:98 | Yes | Needs to be set and be Internet faced/resolved if you want to enable Strava integration. Strava callback relies on this. You may need to update this variable based on docker image spin up (api host or local ip (example: http://192.168.1.10:98)) | -| MY_APP_STRAVA_CLIENT_ID | changeme | Yes | Needs to be set with your Strava API Client ID if you want to enable Strava integration. | - -Frontend dependencies: -- To check npm dependencies used, use npm file (package.json) -- User avatars create using DiceBear (https://www.dicebear.com) avataaars style. -- Logo created on Canva - -### Backend Environment Variables -Table below shows supported environment variables. Variables marked with optional "No" should be set to avoid errors. - -Environment variable | Default value | Optional | Notes | ---- | --- | --- | --- | -| DB_HOST | mariadb | Yes | N/A | -| DB_PORT | 3306 | Yes | N/A | -| DB_USER | endurain | Yes | N/A | -| DB_PASSWORD | changeme | `No` | N/A | -| DB_DATABASE | endurain | Yes | N/A | -| SECRET_KEY | changeme | `No` | Run "openssl rand -hex 32" on a terminal to get a secret | -| ALGORITHM | HS256 | Yes | Currently only HS256 is supported | -| ACCESS_TOKEN_EXPIRE_MINUTES | 15 | Yes | Time in minutes | -| REFRESH_TOKEN_EXPIRE_DAYS | 7 | Yes | Time in days | -| STRAVA_CLIENT_ID | changeme | `No` | Needed if you want to enable the Strava integration | -| STRAVA_CLIENT_SECRET | changeme | `No` | Needed if you want to enable the Strava integration | -| STRAVA_AUTH_CODE | changeme | `No` | Needed if you want to enable the Strava integration | -| JAEGER_ENABLED | false | Yes | N/A | -| JAEGER_PROTOCOL | http | Yes | N/A | -| JAEGER_HOST | jaeger | Yes | N/A | -| JAGGER_PORT | 4317 | Yes | N/A | -| STRAVA_DAYS_ACTIVITIES_ONLINK | 30 | Yes | On Strava integration setup the number of days (including today) to get activities. Strava free API limitations can limit number of days you can query in a given time | -| FRONTEND_PROTOCOL | http | Yes | Needs to be set if you want to enable Strava integration. You may need to update this variable based on docker image spin up (frontend host or local ip (example: http://192.168.1.10:8080)) | -| FRONTEND_HOST | frontend:8080 | Yes | Needs to be set if you want to enable Strava integration. You may need to update this variable based on docker image spin up (frontend host or local ip (example: http://192.168.1.10:8080)) | -| GEOCODES_MAPS_API | changeme | `No` | Geocode maps offers a free plan consisting of 1 Request/Second. Registration necessary. | - -Table below shows the obligatory environment variables for mariadb container. You should set them based on what was also set for backend container. - -| Environemnt variable | Default value | Optional | Notes | -| --- | --- | --- | --- -| MYSQL_ROOT_PASSWORD | changeme | `No` | N/A | -| MYSQL_DATABASE | endurain | `No` | N/A | -| MYSQL_USER | endurain | `No` | N/A | -| MYSQL_PASSWORD | changeme | `No` | N/A | - -To check Python backend dependencies used, use poetry file (pyproject.toml) - -## Volumes - -It is recommended to configure the following volumes for data persistence: - -| Volume | Path | Notes | -| --- | --- | --- | -| /app/files/bulk_import | /endurain/backend/files/bulk_import:/app/files/bulk_import | Necessary to enable bulk import of activities. Place here your activities files | -| /app/files/processed | /endurain/backend/files/processed:/app/files/processed | Necessary for processed original files persistence on container image updates | -| /app/user_images | /endurain/backend/user_images:/app/user_images | Necessary for user image persistence on container image updates | -| /app/logs | /endurain/backend/logs:/app/logs | Log files for the backend | - -## Bulk import and file upload - -.fit files are preferred. I noticed that Strava/Garmin Connect process of converting .fit to .gpx introduces additional data to the activity file leading to minor variances in the data, like for example additional meters in distance and elevation gain. -Some notes: -- After the files are processed, the files are moved to the processed folder. -- GEOCODES API has a limit of 1 Request/Second on the free plan, so if you have a large number of files, it might not be possible to import all in the same action. - -## Strava Integration - -To enable Strava integration, ensure your API endpoint is accessible from the internet and follow Strava's [API setup guide](https://developers.strava.com/docs/getting-started/). After the integration is successful the access and refresh tokens are stored in the DB. Each user will have his/hers own pair. - -## Garmin Connect Integration - -To enable Garmin Connect integration, Endurain will ask for your Garmin Connect credentials. These credentials are not stored, but the authentication tokens (access and refresh tokens) are stored in the DB, similar to the Strava integration. The credentials are sent from the frontend to the backend in plain text, so the use of HTTPS is highly recommended. - -## Log files - -The table bellow details the log files available. These logs are available in the /app/logs folder: - -| Log | Description | -| --- | --- | -| app.log | General log | -| migrations.log | File detailing migrations operations | +For more information please see the Endurain's [documentation](https://docs.endurain.com). ## Sponsors diff --git a/backend/Dockerfile b/backend/Dockerfile index 7fe2646d9..fd0c558d6 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -51,7 +51,6 @@ ENV JAEGER_ENABLED="false" ENV JAEGER_HOST="jaeger" ENV JAEGER_PROTOCOL="http" ENV JAGGER_PORT=4317 -ENV STRAVA_DAYS_ACTIVITIES_ONLINK=30 ENV FRONTEND_PROTOCOL="http" ENV FRONTEND_HOST="localhost:8080" ENV GEOCODES_MAPS_API="changeme" diff --git a/backend/app/main.py b/backend/app/main.py index ecef61b9c..5a34d2063 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -136,7 +136,6 @@ required_env_vars = [ "JAEGER_PROTOCOL", "JAEGER_HOST", "JAGGER_PORT", - "STRAVA_DAYS_ACTIVITIES_ONLINK", "FRONTEND_PROTOCOL", "FRONTEND_HOST", "GEOCODES_MAPS_API", diff --git a/backend/app/users/crud.py b/backend/app/users/crud.py index 1a84ef5a5..11b6a77c2 100644 --- a/backend/app/users/crud.py +++ b/backend/app/users/crud.py @@ -281,9 +281,7 @@ def edit_user(user_id: int, user: users_schema.User, db: Session): detail="User not found", headers={"WWW-Authenticate": "Bearer"}, ) - - # Update the user - + # Dictionary of the fields to update if they are not None user_data = user.dict(exclude_unset=True) # Iterate over the fields and update the db_user dynamically diff --git a/docs/developer-guide.md b/docs/developer-guide.md new file mode 100644 index 000000000..e638f0bd6 --- /dev/null +++ b/docs/developer-guide.md @@ -0,0 +1,16 @@ +# Developer guide + +--- + +## API Integration (v0.3.0+) + +Endurain supports integration with other apps: + +- For **web apps**, the backend sends access/refresh tokens as HTTP-only cookies. +- For **mobile apps**, tokens are included in the response body. + +### API Requirements + +- **Add a header:** Every request must include an `X-Client-Type` header with either `web` or `mobile` as the value. Requests with other values will receive a `403` error. +- **Login and refresh endpoint**: `/api/v1/token` and `/api/v1/refresh`. +- **Activity Upload:** Use the `/api/v1/activities/create/upload` endpoint (expects a .gpx or .fit file). \ No newline at end of file diff --git a/docs/getting-started.md b/docs/getting-started.md index e69de29bb..7c46d55bf 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -0,0 +1,87 @@ +# Getting started + +--- + +## Default Credentials + +- **Username:** admin +- **Password:** admin + +## Docker Deployment + +Endurain provides Docker images for simplified deployment. To get started, check out the `docker-compose.yml.example` file in the project repository and adjust it according to your setup. +Supported tags are: + +- **latest:** contains the latest released version; +- **version, example "v0.3.0":** contains the app state available at the time of the version specified; +- **development version, example "dev_06092024":** contains a development version of the app at the date specified. This is not a stable released and may contain issues and bugs. Please do not open issues if using a version like this unless asked by me. + +## Frontend Environment Variables +Table below shows supported environment variables. Variables marked with optional "No" should be set to avoid errors. + +| Environment variable | Default value | Optional | Notes | +| --- | --- | --- | --- | +| MY_APP_BACKEND_PROTOCOL | http | Yes | Needs to be `https` if you want to enable Strava integration. Strava callback relies on this. You may need to update this variable based on docker image spin up (api host or local ip (example: http://192.168.1.10:98)) | +| MY_APP_BACKEND_HOST | localhost:98 | Yes | Needs to be set and be Internet faced/resolved if you want to enable Strava integration. Strava callback relies on this. You may need to update this variable based on docker image spin up (api host or local ip (example: http://192.168.1.10:98)) | +| MY_APP_STRAVA_CLIENT_ID | changeme | Yes | Needs to be set with your Strava API Client ID if you want to enable Strava integration. | + +Frontend dependencies: + +- To check npm dependencies used, use npm file (package.json) +- User avatars create using DiceBear (https://www.dicebear.com) avataaars style. +- Logo created on Canva + +## Backend Environment Variables +Table below shows supported environment variables. Variables marked with optional "No" should be set to avoid errors. + +Environment variable | Default value | Optional | Notes | +| --- | --- | --- | --- | +| DB_HOST | mariadb | Yes | N/A | +| DB_PORT | 3306 | Yes | N/A | +| DB_USER | endurain | Yes | N/A | +| DB_PASSWORD | changeme | `No` | N/A | +| DB_DATABASE | endurain | Yes | N/A | +| SECRET_KEY | changeme | `No` | Run "openssl rand -hex 32" on a terminal to get a secret | +| ALGORITHM | HS256 | Yes | Currently only HS256 is supported | +| ACCESS_TOKEN_EXPIRE_MINUTES | 15 | Yes | Time in minutes | +| REFRESH_TOKEN_EXPIRE_DAYS | 7 | Yes | Time in days | +| STRAVA_CLIENT_ID | changeme | `No` | Needed if you want to enable the Strava integration | +| STRAVA_CLIENT_SECRET | changeme | `No` | Needed if you want to enable the Strava integration | +| STRAVA_AUTH_CODE | changeme | `No` | Needed if you want to enable the Strava integration | +| JAEGER_ENABLED | false | Yes | N/A | +| JAEGER_PROTOCOL | http | Yes | N/A | +| JAEGER_HOST | jaeger | Yes | N/A | +| JAGGER_PORT | 4317 | Yes | N/A | +| FRONTEND_PROTOCOL | http | Yes | Needs to be set if you want to enable Strava integration. You may need to update this variable based on docker image spin up (frontend host or local ip (example: http://192.168.1.10:8080)) | +| FRONTEND_HOST | frontend:8080 | Yes | Needs to be set if you want to enable Strava integration. You may need to update this variable based on docker image spin up (frontend host or local ip (example: http://192.168.1.10:8080)) | +| GEOCODES_MAPS_API | changeme | `No` | Geocode maps offers a free plan consisting of 1 Request/Second. Registration necessary. | + +Table below shows the obligatory environment variables for mariadb container. You should set them based on what was also set for backend container. + +| Environemnt variable | Default value | Optional | Notes | +| --- | --- | --- | --- | +| MYSQL_ROOT_PASSWORD | changeme | `No` | N/A | +| MYSQL_DATABASE | endurain | `No` | N/A | +| MYSQL_USER | endurain | `No` | N/A | +| MYSQL_PASSWORD | changeme | `No` | N/A | + +To check Python backend dependencies used, use poetry file (pyproject.toml) + +## Volumes + +It is recommended to configure the following volumes for data persistence: + +| Volume | Path | Notes | +| --- | --- | --- | +| /app/files/bulk_import | /endurain/backend/files/bulk_import:/app/files/bulk_import | Necessary to enable bulk import of activities. Place here your activities files | +| /app/files/processed | /endurain/backend/files/processed:/app/files/processed | Necessary for processed original files persistence on container image updates | +| /app/user_images | /endurain/backend/user_images:/app/user_images | Necessary for user image persistence on container image updates | +| /app/logs | /endurain/backend/logs:/app/logs | Log files for the backend | + +## Bulk import and file upload + +.fit files are preferred. I noticed that Strava/Garmin Connect process of converting .fit to .gpx introduces additional data to the activity file leading to minor variances in the data, like for example additional meters in distance and elevation gain. +Some notes: + +- After the files are processed, the files are moved to the processed folder. +- GEOCODES API has a limit of 1 Request/Second on the free plan, so if you have a large number of files, it might not be possible to import all in the same action. \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index df2b72cb0..0dc301d5d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,24 +1,91 @@ -

- -

-

- Endurain -

+
+

+ +

-

- - Crowdin - - License - - GitHub release - - - GitHub stars - -

+

+ + Crowdin + + License + + GitHub release + + + GitHub stars + +

-**A self-hosted fitness tracking service** -Visit Endurain's [Mastodon profile](https://fosstodon.org/@endurain). +

+ Endurain +

+

+ A self-hosted fitness tracking service - Mastodon profile. +

+
-Under construction, please visit project [README](https://github.com/joaovitoriasilva/endurain) in the GitHub repository. \ No newline at end of file +## What is Endurain? + +Endurain is a self-hosted fitness tracking service designed to give users full control over their data and hosting environment. It's similar to Strava but focused on privacy and customization. Built with: + +- **Frontend:** Vue.js, Notivue and Bootstrap CSS +- **Backend:** Python FastAPI, Alembic, SQLAlchemy, stravalib and python-garminconnect for Strava and Garmin Connect integration, gpxpy and fitdecode for .gpx and .fit file import respectively +- **Database:** MariaDB for efficient user data management +- **Observability:** Jaeger for basic tracing and monitoring + +To deploy Endurain, Docker images are available, and a comprehensive example can be found in the "docker-compose.yml.example" file provided in the project repository. Configuration is facilitated through environment variables, ensuring flexibility and ease of customization. More details bellow. + +## Developer's Note + +As a non-professional developer, my journey with Endurain involved learning and implementing new technologies and concepts, with invaluable assistance from ChatGPT. The primary motivation behind this project was to gain hands-on experience and expand my understanding of modern development practices. Second motivation is that I'm an amateur triathlete and I want to keep track of my gear and gear components usage. + +If you have any recommendations or insights on improving any aspect of Endurain, whether related to technology choices, user experience, or any other relevant area, I would greatly appreciate your input. The goal is to create a reliable and user-friendly fitness tracking solution that caters to the needs of individuals who prefer self-hosted applications. Your constructive feedback will undoubtedly contribute to the refinement of Endurain. + +## Features + +Endurain currently supports: + +- Multi-user functionality +- Admin and user profiles with adaptable interfaces +- Activity import via manual or bulk upload (.gpx and .fit files) +- Strava integration for syncing activities and gear +- Garmin Connect integration for syncing activities +- Personalized activity feeds and statistics (week/month) +- Basic activity privacy settings +- Gear tracking (wetsuits, bicycles, shoes) +- User pages with stats and activity histories +- Follower features (view activities) +- Multi-language support (currently English only) +- Dark/light theme switcher +- Third-party app support +- Weight logging + +## Planned Features + +Upcoming features (in no particular order): + +- Simplified Docker images +- Live tracking +- Default gear for activity types +- Gear component tracking (e.g., track when components like bike chains need replacing) +- Activity comments and likes +- Notification system +- Potential ActivityPub integration + +## Sponsors + +A huge thank you to our sponsors! Your support helps keep this project going. + +Consider [sponsoring Endurain on GitHub](https://github.com/sponsors/joaovitoriasilva) to ensure continuous development. + +## Contributing + +Contributions are welcomed! Please open an issue to discuss any changes or improvements before submitting a PR. Check out the [Contributing Guidelines](https://github.com/joaovitoriasilva/endurain/blob/master/CONTRIBUTING.md) for more details. + +## License + +This project is licensed under the GPL-3.0 License - see the [LICENSE](https://github.com/joaovitoriasilva/endurain/tree/master?tab=GPL-3.0-1-ov-file) file for details. + +## Help Translate + +Endurain has multi-language support, and you can help translate it into more languages via [Crowdin](https://crowdin.com/project/endurain). Currently, only English is available. \ No newline at end of file diff --git a/docs/integrations/3rd-party-apps.md b/docs/integrations/3rd-party-apps.md new file mode 100644 index 000000000..8e6ac4c0e --- /dev/null +++ b/docs/integrations/3rd-party-apps.md @@ -0,0 +1,9 @@ +# 3rd party services + +--- + +## RunnerUp Integration + +[RunnerUp](https://github.com/jonasoreland/runnerup) an app for tracking your sport activities with your Android phone, can automatically sync your activities recorded with it to your Endurain instance. + +RunnerUp is supported until version v0.5.3 of Endurain. An [issue](https://github.com/jonasoreland/runnerup/issues/1205) is opened to get support for v0.6.0+. \ No newline at end of file diff --git a/docs/integrations/3rd-party-services.md b/docs/integrations/3rd-party-services.md new file mode 100644 index 000000000..7de01037b --- /dev/null +++ b/docs/integrations/3rd-party-services.md @@ -0,0 +1,17 @@ +# 3rd party services + +--- + +## Strava Integration + +To enable Strava integration, ensure your API endpoint is accessible from the internet and follow Strava's [API setup guide](https://developers.strava.com/docs/getting-started/). After the integration is successful the access and refresh tokens are stored in the DB. Each user will have his/hers own pair. + +On Strava unlink action every data imported from Strava, i.e. activities and gears, will be deleted according to Strava [API Agreement](https://www.strava.com/legal/api). + +For Strava integration [stravalib](https://github.com/stravalib/stravalib) Python module is used. + +## Garmin Connect Integration + +To enable Garmin Connect integration, Endurain will ask for your Garmin Connect credentials. These credentials are not stored, but the authentication tokens (access and refresh tokens) are stored in the DB, similar to the Strava integration. The credentials are sent from the frontend to the backend in plain text, so the use of HTTPS is highly recommended. + +For Garmin Connect integration [python-garminconnect](https://github.com/cyberjunky/python-garminconnect) Python module is used. \ No newline at end of file diff --git a/docs/integrations/apple-automations.md b/docs/integrations/apple-automations.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/docs/integrations/garmin-connect.md b/docs/integrations/garmin-connect.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/docs/integrations/runnerup.md b/docs/integrations/runnerup.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/docs/integrations/strava.md b/docs/integrations/strava.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/frontend/app/src/components/FooterComponent.vue b/frontend/app/src/components/FooterComponent.vue index e4b3383b9..0f3357e01 100644 --- a/frontend/app/src/components/FooterComponent.vue +++ b/frontend/app/src/components/FooterComponent.vue @@ -29,7 +29,7 @@
-

© {{ new Date().getFullYear() === 2023 ? '2023' : '2023 - ' + new Date().getFullYear() }} Endurain • • v0.6.0

+

© {{ new Date().getFullYear() === 2023 ? '2023' : '2023 - ' + new Date().getFullYear() }} Endurain • • v0.6.0

Compatible with STRAVA imageWorks with Garmin Connect image

diff --git a/mkdocs.yml b/mkdocs.yml index bc6968069..7a67bf7f6 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -8,11 +8,8 @@ nav: - Home: index.md - Getting started: getting-started.md - Integrations: - - 3rd party apps: - - RunnerUp: integrations/runnerup.md - - Apple automations: integrations/apple-automations.md - - 3rd party services: - - Garmin Connect: integrations/garmin-connect.md - - Strava: integrations/strava.md + - 3rd party apps: integrations/3rd-party-apps.md + - 3rd party services: integrations/3rd-party-services.md + - Developer guide: developer-guide.md - About: - License: about/license.md \ No newline at end of file