<h1>Installation<aclass="headerlink"href="#installation"title="Permalink to this headline">¶</a></h1>
<p>This application is written in Python (API) and Javascript (client):</p>
<ulclass="simple">
<li><dlclass="simple">
<dt>API:</dt><dd><ul>
<li><p>Flask</p></li>
<li><p><aclass="reference external"href="https://github.com/tkrajina/gpxpy">gpxpy</a> to parse gpx files</p></li>
<li><p><aclass="reference external"href="https://github.com/komoot/staticmap">staticmap</a> to generate a static map image from gpx coordinates</p></li>
<li><p><aclass="reference external"href="https://github.com/ZeevG/python-forecast.io">python-forecast.io</a> to fetch weather data from <aclass="reference external"href="https://darksky.net">Dark Sky</a> (former forecast.io)</p></li>
<li><p><aclass="reference external"href="https://flask-dramatiq.readthedocs.io/en/latest/">dramatiq</a> for task queue</p></li>
</ul>
</dd>
</dl>
</li>
<li><dlclass="simple">
<dt>Client:</dt><dd><ul>
<li><p>React/Redux</p></li>
<li><p><aclass="reference external"href="https://leafletjs.com/">Leaflet</a> to display map</p></li>
<li><p><aclass="reference external"href="https://github.com/recharts/recharts">Recharts</a> to display charts with elevation and speed</p></li>
</ul>
</dd>
</dl>
</li>
</ul>
<p>Sports and weather icons are made by <aclass="reference external"href="https://www.freepik.com/">Freepik</a> from <aclass="reference external"href="https://www.flaticon.com/">www.flaticon.com</a>.</p>
<divclass="section"id="prerequisites">
<h2>Prerequisites<aclass="headerlink"href="#prerequisites"title="Permalink to this headline">¶</a></h2>
<ulclass="simple">
<li><p>PostgreSQL database (10+)</p></li>
<li><p>Redis for task queue</p></li>
<li><p>Python 3.7+</p></li>
<li><p><aclass="reference external"href="https://poetry.eustace.io">Poetry</a> (for installation from sources only)</p></li>
<li><p>API key from <aclass="reference external"href="https://darksky.net/dev">Dark Sky</a> [not mandatory]</p></li>
<li><p>SMTP provider</p></li>
<li><p><aclass="reference external"href="https://yarnpkg.com">Yarn</a> (for development only)</p></li>
<li><p>Docker (for development only, to start <aclass="reference external"href="https://github.com/mailhog/MailHog">MailHog</a> or evaluation purposes)</p></li>
<codeclass="sig-name descname"><spanclass="pre">FLASK_APP</span></code><aclass="headerlink"href="#envvar-FLASK_APP"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">HOST</span></code><aclass="headerlink"href="#envvar-HOST"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">PORT</span></code><aclass="headerlink"href="#envvar-PORT"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">APP_SETTINGS</span></code><aclass="headerlink"href="#envvar-APP_SETTINGS"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">APP_SECRET_KEY</span></code><aclass="headerlink"href="#envvar-APP_SECRET_KEY"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">APP_WORKERS</span></code><aclass="headerlink"href="#envvar-APP_WORKERS"title="Permalink to this definition">¶</a></dt>
<spanid="envvar-APP_LOG 🆕"></span><codeclass="sig-name descname"><spanclass="pre">APP_LOG</span><spanclass="pre">🆕</span></code><aclass="headerlink"href="#envvar-APP_LOG"title="Permalink to this definition">¶</a></dt>
<spanid="envvar-UPLOAD_FOLDER 🆕"></span><codeclass="sig-name descname"><spanclass="pre">UPLOAD_FOLDER</span><spanclass="pre">🆕</span></code><aclass="headerlink"href="#envvar-UPLOAD_FOLDER"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">DATABASE_URL</span></code><aclass="headerlink"href="#envvar-DATABASE_URL"title="Permalink to this definition">¶</a></dt>
<divclass="line">For example in dev environment : <codeclass="docutils literal notranslate"><spanclass="pre">postgresql://fittrackee:fittrackee@localhost:5432/fittrackee</span></code></div>
<spanid="envvar-DATABASE_DISABLE_POOLING 🆕"></span><codeclass="sig-name descname"><spanclass="pre">DATABASE_DISABLE_POOLING</span><spanclass="pre">🆕</span></code><aclass="headerlink"href="#envvar-DATABASE_DISABLE_POOLING"title="Permalink to this definition">¶</a></dt>
<p><spanclass="versionmodified added">New in version 0.4.0.</span></p>
</div>
<p>Disable pooling if needed (when starting application with <strong>FitTrackee</strong> entry point and not directly with <strong>Gunicorn</strong>),
see <aclass="reference external"href="https://docs.sqlalchemy.org/en/13/core/pooling.html#using-connection-pools-with-multiprocessing-or-os-fork">SqlAlchemy documentation</a>.</p>
<codeclass="sig-name descname"><spanclass="pre">UI_URL</span></code><aclass="headerlink"href="#envvar-UI_URL"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">EMAIL_URL</span></code><aclass="headerlink"href="#envvar-EMAIL_URL"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">SENDER_EMAIL</span></code><aclass="headerlink"href="#envvar-SENDER_EMAIL"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">REDIS_URL</span></code><aclass="headerlink"href="#envvar-REDIS_URL"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">WORKERS_PROCESSES</span></code><aclass="headerlink"href="#envvar-WORKERS_PROCESSES"title="Permalink to this definition">¶</a></dt>
<spanid="envvar-TILE_SERVER_URL 🆕"></span><codeclass="sig-name descname"><spanclass="pre">TILE_SERVER_URL</span><spanclass="pre">🆕</span></code><aclass="headerlink"href="#envvar-TILE_SERVER_URL"title="Permalink to this definition">¶</a></dt>
<spanid="envvar-MAP_ATTRIBUTION 🆕"></span><codeclass="sig-name descname"><spanclass="pre">MAP_ATTRIBUTION</span><spanclass="pre">🆕</span></code><aclass="headerlink"href="#envvar-MAP_ATTRIBUTION"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">WEATHER_API_KEY</span></code><aclass="headerlink"href="#envvar-WEATHER_API_KEY"title="Permalink to this definition">¶</a></dt>
<p><spanclass="versionmodified changed">Changed in version 0.4.0: </span>⚠️ replaces <codeclass="docutils literal notranslate"><spanclass="pre">WEATHER_API</span></code></p>
</div>
<p><strong>Dark Sky</strong> API key for weather data (not mandatory).</p>
<codeclass="sig-name descname"><spanclass="pre">REACT_APP_API_URL</span></code><aclass="headerlink"href="#envvar-REACT_APP_API_URL"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">REACT_APP_GPX_LIMIT_IMPORT</span></code><aclass="headerlink"href="#envvar-REACT_APP_GPX_LIMIT_IMPORT"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">REACT_APP_MAX_SINGLE_FILE_SIZE</span></code><aclass="headerlink"href="#envvar-REACT_APP_MAX_SINGLE_FILE_SIZE"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">REACT_APP_MAX_ZIP_FILE_SIZE</span></code><aclass="headerlink"href="#envvar-REACT_APP_MAX_ZIP_FILE_SIZE"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">REACT_APP_ALLOW_REGISTRATION</span></code><aclass="headerlink"href="#envvar-REACT_APP_ALLOW_REGISTRATION"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname"><spanclass="pre">REACT_APP_THUNDERFOREST_API_KEY</span></code><aclass="headerlink"href="#envvar-REACT_APP_THUNDERFOREST_API_KEY"title="Permalink to this definition">¶</a></dt>
<p><spanclass="versionmodified deprecated">Deprecated since version 0.4.0: </span>see <aclass="reference external"href="installation.html#envvar-TILE_SERVER_URL">TILE_SERVER_URL</a></p>
</div>
<p>ThunderForest API key.</p>
</dd></dl>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<divclass="line-block">
<divclass="line">Since FitTrackee 0.3.0, some applications parameters are now stored in database.</div>
<divclass="line">Related environment variables are needed to initialize database when upgrading from version prior 0.3.0.</div>
</div>
</div>
</div>
<divclass="section"id="emails">
<h3>Emails<aclass="headerlink"href="#emails"title="Permalink to this headline">¶</a></h3>
<divclass="versionadded">
<p><spanclass="versionmodified added">New in version 0.3.0.</span></p>
</div>
<p>To send emails, a valid <codeclass="docutils literal notranslate"><spanclass="pre">EMAIL_URL</span></code> must be provided:</p>
<ulclass="simple">
<li><p>with an unencrypted SMTP server: <codeclass="docutils literal notranslate"><spanclass="pre">smtp://username:password@smtp.example.com:25</span></code></p></li>
<h3>Map tile server<aclass="headerlink"href="#map-tile-server"title="Permalink to this headline">¶</a></h3>
<divclass="versionadded">
<p><spanclass="versionmodified added">New in version 0.4.0.</span></p>
</div>
<p>Default tile server is now <strong>OpenStreetMap</strong>’s standard tile layer (if environment variables are not initialized).
The tile server can be changed by updating <codeclass="docutils literal notranslate"><spanclass="pre">TILE_SERVER_URL</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">MAP_ATTRIBUTION</span></code> variables (<aclass="reference external"href="https://wiki.openstreetmap.org/wiki/Tile_servers">list of tile servers</a>).</p>
<p>To keep using <strong>ThunderForest Outdoors</strong>, the configuration is:</p>
<ulclass="simple">
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">TILE_SERVER_URL=https://{s}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=XXXX</span></code> where <strong>XXXX</strong> is <strong>ThunderForest</strong> API key</p></li>
<li><p>Initialize environment variables, see <aclass="reference external"href="installation.html#environment-variables">Environment variables</a></p></li>
</ul>
<p>For instance, copy and update <codeclass="docutils literal notranslate"><spanclass="pre">.env</span></code> file from <codeclass="docutils literal notranslate"><spanclass="pre">.env.example</span></code> and source the file.</p>
<divclass="line">To start application and workers with <strong>systemd</strong> service, see <aclass="reference external"href="installation.html#deployment">Deployment</a></div>
</div>
</div>
</div>
<divclass="section"id="upgrade">
<h3>Upgrade<aclass="headerlink"href="#upgrade"title="Permalink to this headline">¶</a></h3>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<divclass="line-block">
<divclass="line">Before upgrading, make a backup of all data:</div>
<divclass="line">- database (with <aclass="reference external"href="https://www.postgresql.org/docs/11/app-pgdump.html">pg_dump</a> for instance)</div>
<divclass="line">- upload directory (see <aclass="reference external"href="installation.html#environment-variables">Environment variables</a>)</div>
<li><p>Create <strong>Makefile.custom.config</strong> from example and update it
(see <aclass="reference external"href="installation.html#environment-variables">Environment variables</a>).</p></li>
<li><p>Install Python virtualenv, React and all related packages and
initialize the database:</p></li>
</ul>
<divclass="highlight-bash notranslate"><divclass="highlight"><pre><span></span>$ make install-dev
$ make install-db
</pre></div>
</div>
<ulclass="simple">
<li><p>Start the server and the client:</p></li>
</ul>
<divclass="highlight-bash notranslate"><divclass="highlight"><pre><span></span>$ make serve
</pre></div>
</div>
<ulclass="simple">
<li><p>Run dramatiq workers:</p></li>
</ul>
<divclass="highlight-bash notranslate"><divclass="highlight"><pre><span></span>$ make run-workers
</pre></div>
</div>
<p>Open <aclass="reference external"href="http://localhost:3000">http://localhost:3000</a> and log in (the email is <codeclass="docutils literal notranslate"><spanclass="pre">admin@example.com</span></code>
and the password <codeclass="docutils literal notranslate"><spanclass="pre">mpwoadmin</span></code>) or register</p>
</div>
<divclass="section"id="production-environment">
<h4>Production environment<aclass="headerlink"href="#production-environment"title="Permalink to this headline">¶</a></h4>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<divclass="line-block">
<divclass="line">Note that FitTrackee is under heavy development, some features may be unstable.</div>
</div>
</div>
<ulclass="simple">
<li><p>Download the last release (for now, it is the release v0.4.0):</p></li>
<li><p>Create <strong>Makefile.custom.config</strong> from example and update it
(see <aclass="reference external"href="installation.html#environment-variables">Environment variables</a>).</p></li>
<li><p>Install Python virtualenv and all related packages:</p></li>
</ul>
<divclass="highlight-bash notranslate"><divclass="highlight"><pre><span></span>$ make install-python
</pre></div>
</div>
<ulclass="simple">
<li><p>Initialize the database (<strong>after updating</strong><codeclass="docutils literal notranslate"><spanclass="pre">db/create.sql</span></code><strong>to change
database credentials</strong>):</p></li>
</ul>
<divclass="highlight-bash notranslate"><divclass="highlight"><pre><span></span>$ make install-db
</pre></div>
</div>
<ulclass="simple">
<li><p>Start the server and dramatiq workers:</p></li>
</ul>
<divclass="highlight-bash notranslate"><divclass="highlight"><pre><span></span>$ make run
</pre></div>
</div>
<p>Open <aclass="reference external"href="http://localhost:5000">http://localhost:5000</a>, log in as admin (the email is
<codeclass="docutils literal notranslate"><spanclass="pre">admin@example.com</span></code> and the password <codeclass="docutils literal notranslate"><spanclass="pre">mpwoadmin</span></code>) and change the
password</p>
</div>
</div>
<divclass="section"id="id3">
<h3>Upgrade<aclass="headerlink"href="#id3"title="Permalink to this headline">¶</a></h3>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<divclass="line-block">
<divclass="line">Before upgrading, make a backup of all data:</div>
<divclass="line">- database (with <aclass="reference external"href="https://www.postgresql.org/docs/11/app-pgdump.html">pg_dump</a> for instance)</div>
<divclass="line">- upload directory (see <aclass="reference external"href="installation.html#environment-variables">Environment variables</a>)</div>
</div>
</div>
<divclass="section"id="id4">
<h4>Dev environment<aclass="headerlink"href="#id4"title="Permalink to this headline">¶</a></h4>
<ulclass="simple">
<li><p>Stop the application and pull the repository:</p></li>
<p>Open <aclass="reference external"href="http://localhost:5000">http://localhost:5000</a>, log in as admin (the email is <cite>admin@example.com</cite> and the password <cite>mpwoadmin</cite>) or register.</p>