Bag Tracker is a tool designed to help users track their cryptocurrency investments. It allows users to input their bag holdings and provides insights into their investment performance.
-
Clone the repository:
git clone https://github.com/gearbox/bagtracker.git
-
Navigate to the project directory:
cd bagtracker
-
Run the application using the following command:
docker-compose up --build
This command will build the Docker images and start the application.
-
Stop the application:
docker-compose down
To set up a development environment, follow these steps:
-
Install the UV packet manager following the Instruction (standalone version is recommended)
-
Clone the repository (pass if you already did):
git clone https://github.com/gearbox/bagtracker.git
-
Install the project dependancies Run the below commands in the project root directory:
uv venv uv sync
For developers it is recommended to install the
dev
dependencies as well:uv sync --group dev
-
Activate the virtual environment:
source .venv/bin/activate
-
Run the application:
- Using Fastapi:
fastapi run backend/asgi.py --proxy-headers --port 80
- Using asgi.py
python -m backend.asgi
- Using direct Uvicorn
python -m uvicorn backend.asgi:app --reload --host 0.0.0.0 --port 8080
- Using Fastapi:
We use the pyproject.toml
project fields name
and version
(semver versioning syle).
During the Docker container build process docker runs the scripts/extract_version.py
script and generates backend/_version.py
with the corresponding version.
If you run the project locally and there is no generated backend/_version.py
file, it will fall back to the 0.0.0-dev
version (will be shown in the Swagger UI). If you would like to see the actual app version, you can run the scripts/extract_version.py
script manually by running the following command in your terminal from the root directory of the project:
python scripts/extract_version.py
-
Automatic run using
pre-commit
Runpre-commit install
in the project root directory.This way commands
ruff check --fix
andruff format
will run after each commit using configuration from thepyproject.toml
-
Manual run Run the below commands in the project root directory:
ruff check --fix ruff format
-
To create a new migration:
alembic revision --autogenerate -m "Your migration message"
-
To apply migrations:
alembic upgrade head
-
To downgrade migrations:
alembic downgrade -1
or
alembic downgrade base
-
To view the current migration status:
alembic current
The Uvicorn configuration is located in the uvicorn_config.py
file.
It is recommended to verify the config validity after any manual changes using the scripts/verify_uvicorn_config.py
script by running the command from the project root directory:
python scripts/verify_uvicorn_config.py
To seed the database with initial data, use the following command:
python -m backend.seeds.seed <table_name> <action>
Replace <table_name>
with the name of the table you want to seed (e.g., users
, chains
, tokens
), now supports chains
.
You can write your own seeders in the backend/seeds/data
directory.
Replace <action>
with the desired action (supporting seed
, clear
, status
).
For example:
- to seed the
chains
table, run:python -m backend.seeds.seed chains seed
- to clear the
chains
table, run:python -m backend.seeds.seed chains clear
- to check the status of the
chains
table, run:python -m backend.seeds.seed chains status
The project uses locally hosted OpenAPI/Swagger UI assets for reliability. These files are stored in static/openapi/
and include:
swagger-ui-bundle.js
- Swagger UI JavaScript bundleswagger-ui.css
- Swagger UI stylesredoc.standalone.js
- ReDoc standalone bundlefavicon.png
- FastAPI favicon
# Update to latest versions
python scripts/update_openapi_assets.py
# Update to specific versions
python scripts/update_openapi_assets.py --swagger-version 5.10.0 --redoc-version 2.1.0
# Skip favicon download
python scripts/update_openapi_assets.py --skip-favicon
# View help
python scripts/update_openapi_assets.py --help
Requirements: requests
library (already in project dependencies)
If you prefer to manually download the files:
-
Swagger UI: Visit https://github.com/swagger-api/swagger-ui/releases
- Download
swagger-ui-bundle.js
andswagger-ui.css
from thedist
folder
- Download
-
ReDoc: Visit https://github.com/Redocly/redoc/releases
- Download
redoc.standalone.js
from the bundles
- Download
-
Place all files in the
static/openapi/
directory
After updating, test the documentation endpoints:
- Swagger UI: http://localhost:8080/docs
- ReDoc: http://localhost:8080/redoc
The assets should load without errors in the browser console.