Update docs with dev env setup logic

This commit is contained in:
João Vitória Silva
2025-02-25 14:44:54 +00:00
parent 49be057de3
commit 7fd4d6f7a7
2 changed files with 134 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -2,6 +2,128 @@
---
## Setup a dev environment
Bellow are the steps to create a dev environment. Examples bellow will use Endurain repo, but you should adapt those for your scenario (forked repo, etc).
- Clone the repo to your dev machine:
```
$ cd <folder_to_store_code>
$ git clone https://github.com/joaovitoriasilva/endurain.git # this will clone the repo structure to the previous folder inside a folder called endurain
```
### Docker image and backend logic
Make sure Docker is installed, more info [here](https://docs.docker.com/get-started/introduction/get-docker-desktop/).
- On the project root folder, create a new Docker image, the example bellow uses `unified-image` as the image name:
```
$ docker build -f docker/Dockerfile -t unified-image .
```
- Go to the project root folder and create a file called `docker-compose.yml` and adapt it to your needs. Example bellow:
```
services:
endurain:
container_name: endurain
image: unified-image # based on image that will be created above
environment:
- TZ=Europe/Lisbon # change if needed. Default is UTC
- DB_TYPE=postgres
- DB_HOST=postgres
- DB_PORT=5432
- DB_PASSWORD=changeme
- SECRET_KEY=changeme
- GEOCODES_MAPS_API=changeme
- ENDURAIN_HOST=http://localhost:8080 # change if needed
- BEHIND_PROXY=false
volumes:
- <path_to_project_root_folder>/backend/app:/app/backend/ # this will replace the backend code logic with yours. Any changes in the code need a container reboot for them to apply
ports:
- "8080:8080" # change if needed
depends_on:
postgres:
condition: service_healthy
restart: unless-stopped
postgres:
image: postgres:latest
container_name: postgres
environment:
- POSTGRES_PASSWORD=changeme
- POSTGRES_DB=endurain
- POSTGRES_USER=endurain
- PGDATA=/var/lib/postgresql/data/pgdata
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U endurain"]
interval: 5s
timeout: 5s
retries: 5
volumes:
- <path_to_container_folders>/postgres:/var/lib/postgresql/data
restart: unless-stopped
adminer:
container_name: adminer
image: adminer
ports:
- 8081:8080
restart: unless-stopped
```
- Start your project based on the docker compose file created before:
```
$ docker compose up -d
```
- To stop the project:
```
$ docker compose down
```
- To remove the create `unified-image` Docker image:
```
$ docker image remove unified-image
```
- Backend uses [Poetry](https://python-poetry.org/) for dependency management. You may need to install Python and Poetry if dependency management is necessary.
### Frontend
Make sure you have an up-to-date version of [Node.js](https://nodejs.org/) installed.
- Go to the root of the project and move to frontend/app folder and install the dependencies:
```
$ cd frontend/app
$ npm install
```
- Create a file called `.env.local` inside frontend/app and add the following to it:
```
VITE_ENDURAIN_HOST=http://localhost:8080 # Adapt this based on the docker compose of your dev environment
VITE_STRAVA_CLIENT_ID=MY_APP_STRAVA_CLIENT_ID
```
- After the dependencies are installed run the frontend:
```
$ npm run dev
```
- After the frontend starts running, it should be available in the port `5173`. You should now be able to access the dev environment at `http://localhost:5173`. Screenshot bellow shows the output from the `npm run dev`. Adapt the port based on the command output.
![Frontend running](assets/developer-guide/npm_run_dev.png)
- Some processes, like token refresh may redirect your dev env from port `5173` to `8080` (or other, depending on your compose file). If this happens simply navigate again to `5173`.
## API Integration (v0.3.0+)
Endurain supports integration with other apps:
@@ -28,7 +150,7 @@ The API is reachable under `/api/v1`. Below are some example endpoints. All endp
| **Set Weight** | `/health/weight` | JSON {'weight': <number>, 'created_at': `yyyy-MM-dd`} |
### Supported activity types
## Supported activity types
The table bellow details the activity types supported by Endurain:
| Name | Value |
@@ -49,4 +171,14 @@ The table bellow details the activity types supported by Endurain:
| Yoga | 14 |
| Alpine ski | 15 |
| Nordic Ski | 16 |
| Snowboard | 17 |
| Snowboard | 17 |
## Supported gear types
The table bellow details the gear types supported by Endurain:
| Name | Value |
| ---- | --- |
| Bike | 1 |
| Shoes | 2 |
| Wetsuit | 3 |