golem-stats-backend/: Django + Celery backend for stats.golem.network; Dockerfiles and Makefile for images. |-stats-backend/: project root with apps:api(public endpoints),api2(newer endpoints/commands),collector(data ingestion, Celery tasks),core(settings/URLs/shared utils),metamask,healthcheck,yapapi, andstatic/.- Tests:
stats-backend/api/testsandstats-backend/collector/tests. Docker build contexts live indockerfiles/.
- Install deps:
cd golem-stats-backend && pip install -r requirements.pip. - Run dev server:
cd stats-backend && python manage.py runserver 0.0.0.0:8000. - Database:
python manage.py migrate; create superuser if needed withpython manage.py createsuperuser. - Celery:
celery -A core worker -l infoandcelery -A core beat -l info(fromstats-backend). - Tests:
python manage.py test(or target app:python manage.py test api). - Docker:
make build-amd64(builds Django/Celery/Beat/Yagna images) andmake push-amd64(publish; login first withmake login). Local stack:docker-compose -f docker-compose-dev.yml up.
- PEP 8, 4-space indents;
snake_casefor modules/functions/vars,PascalCasefor classes. - Keep views and tasks small; move shared logic to
core/helpers. Prefer DRF serializers for validation. - Add type hints to new/modified code. Configure via env vars (no secrets in code); keep logging consistent with existing handlers.
- Add tests near the code they cover (app-level
tests/). Name filestest_*.pyand functionstest_<behavior>. - Mock external services (Redis, Yagna, HTTP) to keep tests deterministic. Aim to cover model logic plus API responses.
- Quick commands:
python manage.py test api.tests.test_modelsorpython manage.py test collector.
- Commits: concise, imperative subjects (repo history shows short titles like “Update main.yml”; prefer explicit ones).
- PRs: state intent, key changes, and verification (
python manage.py test, manual endpoint checks). Link issues; include sample API responses or screenshots for user-facing changes. Call out migrations or ops steps.
- Never commit wallet/key files (
key-*.json, yagna artifacts); mount via volumes/env. - Set
ALLOWED_HOSTSappropriately; keepDEBUGoff outside local dev. Ensure Redis/Postgres are reachable before starting workers to avoid reconnect churn.