Web API written in Python FastAPI for use with the Silver Fund dashboard.
Install Python 3.13+ and pip.
Create and activate a virtual environment:
python -m venv .venvsource .venv/bin/activate
# On Windows:
.venv\Scripts\Activate.ps1Install runtime and development dependencies:
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txtInstall pre-commit hooks (optional):
pre-commit installView installed dependencies:
pip listAdd a new dependency:
pip install package-nameFreeze dependencies after dependency changes:
pip freeze > requirements.txtFor development-only packages, update requirements-dev.txt.
Run the FastAPI app
uvicorn app.main:app --reloadAPI routes are listed at to http://127.0.0.1:8000/docs
Sensitive routes (for example, POST /covariance-matrix/latest) are protected using AWS Cognito JWTs.
Configure the following environment variables in each environment (Dev/Prod) to point at the appropriate user pool and app client:
COGNITO_REGION– AWS region of the Cognito user pool (e.g.us-east-1).COGNITO_USER_POOL_ID– ID of the Cognito User Pool.COGNITO_APP_CLIENT_ID– App client ID whose tokens are accepted by the API.
The backend expects an Authorization: Bearer <JWT> header containing a valid Cognito access or ID token. In the browser, ensure your frontend obtains the token from Cognito (e.g. via Amplify/Auth) and forwards it on API requests.
We use Ruff for both linting and formatting. Make sure to lint and format before pushing to Github. Github Actions is set up to fail ruff fails.
Format all Python files:
ruff formatCheck formatting without making changes:
ruff format --checkRun linter:
ruff checkAuto-fix linting issues:
ruff check --fixWe use pre-commit to automatically run Ruff linting and formatting before every commit.
After installing dependencies, install pre-commit hooks:
pre-commit installHooks run automatically on git commit. You can also run manually:
# Run on all files
pre-commit run --all-files
# Run on staged files only
pre-commit run
# Update hook versions
pre-commit autoupdategit commit --no-verify -m "emergency commit"