|
1 |
| -# flush-log |
| 1 | +# Flush Log |
| 2 | +Flush Log is Progressive Web App that can be used to track your bowel movements |
| 3 | +it is available at https://pgulb.github.io/flush-log/ |
2 | 4 |
|
| 5 | +## Why |
| 6 | +You can improve your toilet habits, for example reduce time mindlessly scrolling through |
| 7 | +Social Media if you see how much time it takes |
| 8 | +FL allows you to track stats like time, number/% of times with phone, mean time, mean rating etc |
| 9 | + |
| 10 | +## What is Progressive Web App |
| 11 | +In short it's a web app that allows itself to be 'installed' both on desktop and mobile devices |
| 12 | +as an app, option to install appears usually at the right side of searchbar, and on mobile |
| 13 | +in the three dot menu |
| 14 | + |
| 15 | +PWAs aim to look more like native application than a regular website, they also cache themselves on |
| 16 | +user's device to load faster and notify user when an app can be updated |
| 17 | + |
| 18 | +### Initial diagram for how it should work (now slightly modified) |
3 | 19 | <img src="./systems.png" alt="app diagram" align="center"/>
|
4 | 20 |
|
5 |
| -## development |
| 21 | +## development info |
| 22 | + |
| 23 | +flush-log uses Taskfile (https://taskfile.dev/) to automate commands used to |
| 24 | +develop and test its components |
| 25 | +Components are: |
| 26 | +- PWA (Go + go-app https://go-app.dev/) |
| 27 | +- REST API (Python + FastAPI https://fastapi.tiangolo.com/) |
| 28 | +- MongoDB (At production it's MongoDB Atlas free tier https://www.mongodb.com/docs/atlas/reference/free-shared-limitations/) |
| 29 | + |
| 30 | +### App server vs static website |
| 31 | +Go-app can be compiled to executable to run as a server, or compiled to static content |
| 32 | +In production I compile it to static and deploy to Github Pages |
| 33 | +Tests and local development is done with server version (pipeline tests with Docker) |
| 34 | + |
| 35 | +--- |
| 36 | +### List all available tasks |
| 37 | +```sh |
| 38 | +task |
| 39 | +``` |
| 40 | +--- |
| 41 | +### Prepare venv |
| 42 | +I use uv https://github.com/astral-sh/uv to create venv and install dependencies while developing |
| 43 | +Tests are run using venv |
| 44 | +```sh |
| 45 | +task init-uv-venv |
| 46 | +``` |
| 47 | +--- |
| 48 | +### Spin up whole stack in Docker locally and watch logs |
| 49 | + |
6 | 50 | ```sh
|
7 |
| -docker compose up --build |
| 51 | +task dev |
8 | 52 | ```
|
9 | 53 | And go to http://localhost:8080 for hot-reloading app
|
| 54 | +API is located at http://localhost:6789 |
| 55 | +and Mongo at mongodb://localhost:27017 |
10 | 56 |
|
11 | 57 | ---
|
12 |
| -Run only FastAPI by using: |
| 58 | +### Remove containers |
| 59 | +```sh |
| 60 | +task cleanup |
| 61 | +``` |
| 62 | +--- |
| 63 | +### API tests |
| 64 | +unit |
| 65 | +```sh |
| 66 | +task test-api-unit |
| 67 | +``` |
| 68 | +mocked |
| 69 | +```sh |
| 70 | +task test-api-mock |
| 71 | +``` |
| 72 | +with local mongo |
| 73 | +```sh |
| 74 | +task test-api-integration |
| 75 | +``` |
| 76 | +--- |
| 77 | +### PWA tests |
| 78 | +unit |
| 79 | +```sh |
| 80 | +task test-pwa-unit |
| 81 | +``` |
| 82 | +integration (with go-rod https://go-rod.github.io/#/) |
| 83 | +```sh |
| 84 | +task test-pwa-integration |
| 85 | +``` |
| 86 | +integration with visible browser window |
13 | 87 | ```sh
|
14 |
| -docker compose up flush-api --build |
| 88 | +task test-pwa-integration-show-window |
15 | 89 | ```
|
| 90 | +## Github Workflows |
| 91 | +- test-api.yml - run tests for API on each push |
| 92 | +- test-pwa.yml - build docker image and run tests for PWA on each push |
| 93 | +- publish-api-image.yml - build and publish API docker image after tests complete (on main branch) |
| 94 | +- deploy-api.yml - deploy API image after build (currently to VPS through ssh) (on main branch) |
| 95 | +- deploy-pwa.yml - build static content and deploy to Github Pages after tests complete (on main branch) |
0 commit comments