# pkpio/fitbit-googlefit architecture

> Architecture diagram of the GitHub repository pkpio/fitbit-googlefit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pkpio/fitbit-googlefit
- Repository: https://github.com/pkpio/fitbit-googlefit

## Overview

This is a Fitbit-to-Google Fit data exporter. The main workflow reads configuration and authenticated clients, then syncs a date range: Fitbit records are fetched, converted to Google Fit points or sessions, and written to Google Fit. Separate paths handle intraday and daily logs, sleep, and activity sessions; the README also documents minute-level steps, distance, calories, and sleep, plus second-level heart rate. Authentication scripts establish credentials for both services. Relationships below follow shown calls or README statements; unsampled implementation details are not inferred.

Main entry points: [`remote.py`](https://github.com/pkpio/fitbit-googlefit/blob/master/remote.py) (Remote sync coordinator), [`app.py`](https://github.com/pkpio/fitbit-googlefit/blob/master/app.py) (Sync entry point), [`helpers.py`](https://github.com/pkpio/fitbit-googlefit/blob/master/helpers.py) (API client helper), [`convertors.py`](https://github.com/pkpio/fitbit-googlefit/blob/master/convertors.py) (Point and session conversion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_run["Sync orchestration"]
  node_entry["Sync entry point<br/>[app.py]"]
  node_settings["Sync configuration<br/>[config.ini]"]
  node_remote["Remote sync coordinator<br/>[remote.py]"]
  node_intraday["Intraday metrics<br/>[remote.py]"]
  node_dailylogs["Daily logs<br/>[remote.py]"]
  node_sleep["Sleep sync<br/>[remote.py]"]
  node_activities["Activity sessions<br/>[remote.py]"]
end

subgraph group_transform["Data conversion"]
  node_convertor["Point and session conversion<br/>[convertors.py]"]
end

subgraph group_identity["Authentication"]
  node_clients["API client helper<br/>[helpers.py]"]
  node_fitbitauth["Fitbit OAuth<br/>[auth_fitbit.py]"]
  node_googleauth["Google OAuth<br/>[auth_google.py]"]
end

subgraph group_services["External services"]
  node_fitbit{{"Fitbit API"}}
  node_googlefit{{"Google Fit API"}}
end

node_user(("Operator"))

node_user -->|"starts sync"| node_entry
node_entry -->|"reads settings"| node_settings
node_entry -->|"creates clients"| node_clients
node_entry -->|"initializes"| node_convertor
node_entry -->|"dispatches sync"| node_remote
node_remote -->|"dispatches intraday"| node_intraday
node_remote -->|"dispatches logs"| node_dailylogs
node_remote -->|"dispatches sleep"| node_sleep
node_entry -->|"syncs activities"| node_activities
node_intraday -->|"fetches metrics"| node_fitbit
node_dailylogs -->|"fetches logs"| node_fitbit
node_sleep -->|"fetches sleep"| node_fitbit
node_activities -->|"fetches activities"| node_fitbit
node_intraday -->|"converts points"| node_convertor
node_dailylogs -->|"converts logs"| node_convertor
node_sleep -->|"converts sleep"| node_convertor
node_activities -->|"converts sessions"| node_convertor
node_remote -->|"creates data sources"| node_googlefit
node_remote -->|"writes points"| node_googlefit
node_remote -->|"writes sessions"| node_googlefit
node_user -->|"authorizes Fitbit"| node_fitbitauth
node_user -->|"authorizes Google"| node_googleauth
node_fitbitauth -->|"provides credentials"| node_clients
node_googleauth -->|"provides credentials"| node_clients
node_clients -->|"builds client"| node_fitbit
node_clients -->|"builds client"| node_googlefit

click node_entry "https://github.com/pkpio/fitbit-googlefit/blob/master/app.py"
click node_settings "https://github.com/pkpio/fitbit-googlefit/blob/master/config.ini"
click node_remote "https://github.com/pkpio/fitbit-googlefit/blob/master/remote.py"
click node_intraday "https://github.com/pkpio/fitbit-googlefit/blob/master/remote.py"
click node_dailylogs "https://github.com/pkpio/fitbit-googlefit/blob/master/remote.py"
click node_sleep "https://github.com/pkpio/fitbit-googlefit/blob/master/remote.py"
click node_activities "https://github.com/pkpio/fitbit-googlefit/blob/master/remote.py"
click node_convertor "https://github.com/pkpio/fitbit-googlefit/blob/master/convertors.py"
click node_clients "https://github.com/pkpio/fitbit-googlefit/blob/master/helpers.py"
click node_fitbitauth "https://github.com/pkpio/fitbit-googlefit/blob/master/auth/auth_fitbit.py"
click node_googleauth "https://github.com/pkpio/fitbit-googlefit/blob/master/auth/auth_google.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_settings,node_remote,node_intraday,node_dailylogs,node_sleep,node_activities toneBlue
class node_convertor toneAmber
class node_clients,node_fitbitauth,node_googleauth toneMint
class node_fitbit,node_googlefit toneRose
class node_user toneIndigo
```

## Components

### Sync orchestration

- [Sync entry point](https://github.com/pkpio/fitbit-googlefit/blob/master/app.py): `app.py`
- [Sync configuration](https://github.com/pkpio/fitbit-googlefit/blob/master/config.ini): `config.ini`
- [Remote sync coordinator](https://github.com/pkpio/fitbit-googlefit/blob/master/remote.py): `remote.py`
- [Intraday metrics](https://github.com/pkpio/fitbit-googlefit/blob/master/remote.py): `remote.py`
- [Daily logs](https://github.com/pkpio/fitbit-googlefit/blob/master/remote.py): `remote.py`
- [Sleep sync](https://github.com/pkpio/fitbit-googlefit/blob/master/remote.py): `remote.py`
- [Activity sessions](https://github.com/pkpio/fitbit-googlefit/blob/master/remote.py): `remote.py`

### Data conversion

- [Point and session conversion](https://github.com/pkpio/fitbit-googlefit/blob/master/convertors.py): `convertors.py`

### Authentication

- [API client helper](https://github.com/pkpio/fitbit-googlefit/blob/master/helpers.py): `helpers.py`
- [Fitbit OAuth](https://github.com/pkpio/fitbit-googlefit/blob/master/auth/auth_fitbit.py): `auth/auth_fitbit.py`
- [Google OAuth](https://github.com/pkpio/fitbit-googlefit/blob/master/auth/auth_google.py): `auth/auth_google.py`

### External services

- **Fitbit API**
- **Google Fit API**

### Other components

- **Operator**

## Connections

- Operator → Sync entry point: starts sync (evidence: `README.md`)
- Sync entry point → Sync configuration: reads settings (evidence: `app.py`)
- Sync entry point → API client helper: creates clients (evidence: `app.py`)
- Sync entry point → Point and session conversion: initializes (evidence: `app.py`)
- Sync entry point → Remote sync coordinator: dispatches sync (evidence: `app.py`)
- Remote sync coordinator → Intraday metrics: dispatches intraday (evidence: `remote.py`)
- Remote sync coordinator → Daily logs: dispatches logs (evidence: `remote.py`)
- Remote sync coordinator → Sleep sync: dispatches sleep (evidence: `remote.py`)
- Sync entry point → Activity sessions: syncs activities (evidence: `app.py`)
- Intraday metrics → Fitbit API: fetches metrics (evidence: `remote.py`)
- Daily logs → Fitbit API: fetches logs (evidence: `remote.py`)
- Sleep sync → Fitbit API: fetches sleep (evidence: `remote.py`)
- Activity sessions → Fitbit API: fetches activities (evidence: `remote.py`)
- Intraday metrics → Point and session conversion: converts points (evidence: `remote.py`)
- Daily logs → Point and session conversion: converts logs (evidence: `remote.py`)
- Sleep sync → Point and session conversion: converts sleep (evidence: `remote.py`)
- Activity sessions → Point and session conversion: converts sessions (evidence: `remote.py`)
- Remote sync coordinator → Google Fit API: creates data sources (evidence: `remote.py`)
- Remote sync coordinator → Google Fit API: writes points (evidence: `remote.py`)
- Remote sync coordinator → Google Fit API: writes sessions (evidence: `remote.py`)
- Operator → Fitbit OAuth: authorizes Fitbit (evidence: `README.md`)
- Operator → Google OAuth: authorizes Google (evidence: `README.md`)
- Fitbit OAuth → API client helper: provides credentials (evidence: `README.md`)
- Google OAuth → API client helper: provides credentials (evidence: `README.md`)
- API client helper → Fitbit API: builds client (evidence: `helpers.py`)
- API client helper → Google Fit API: builds client (evidence: `helpers.py`)
